Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/core/src/tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ function registrationError(tool: Tool.Info) {
if (error) return error
}
const name = normalizedName(tool)
if (!/^[A-Za-z0-9_-]{1,128}$/.test(name)) return new RegistrationError({ name, message: `Invalid tool name: ${name}` })
if (!/^[A-Za-z0-9_-]+$/.test(name)) return new RegistrationError({ name, message: `Invalid tool name: ${name}` })
const id = effectiveName(tool)
if (tool.options?.codemode === false && id === "execute")
return new RegistrationError({ name: id, message: 'Tool name "execute" is reserved for CodeMode' })
Expand All @@ -321,7 +321,7 @@ function registrationError(tool: Tool.Info) {
}

function namespaceError(name: string) {
if (name.split(".").every((segment) => /^[A-Za-z0-9_-]{1,64}$/.test(segment))) return
if (name.split(".").every((segment) => /^[A-Za-z0-9_-]+$/.test(segment))) return
return new RegistrationError({ name, message: `Invalid tool namespace: ${JSON.stringify(name)}` })
}

Expand Down
7 changes: 3 additions & 4 deletions packages/core/test/mcp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2106,7 +2106,7 @@ test("serializes concurrent MCP lifecycle operations", async () => {
)
})

testEffect(Layer.empty).live("isolates invalid MCP tools and preserves plugin transforms through catalog updates", () =>
testEffect(Layer.empty).live("preserves plugin transforms through MCP catalog updates", () =>
Effect.gen(function* () {
const tool = (server: string, name: string, description = name) =>
({
Expand All @@ -2117,8 +2117,7 @@ testEffect(Layer.empty).live("isolates invalid MCP tools and preserves plugin tr
inputSchema: { type: "object", properties: {} },
}) satisfies Mcp.Tool
const healthy = [tool("demo", "search"), tool("other", "lookup")]
const namespace = tool("x".repeat(65), "lookup")
const catalog = yield* Ref.make([tool("demo", "x".repeat(129)), ...healthy, namespace])
const catalog = yield* Ref.make(healthy)

yield* Effect.gen(function* () {
const registry = yield* Tool.Service
Expand Down Expand Up @@ -2147,7 +2146,7 @@ testEffect(Layer.empty).live("isolates invalid MCP tools and preserves plugin tr
editor.remove("repaired_lookup")
})

yield* Ref.set(catalog, [tool("demo", "y".repeat(129)), ...healthy, tool("demo", "added"), namespace])
yield* Ref.set(catalog, [...healthy, tool("demo", "added")])
yield* bus.publish(McpEvent.ToolsChanged, { server: "demo" })
yield* waitForTool(registry, "demo_added")
expect((yield* toolDefinitions(registry)).map((tool) => tool.name)).toEqual([
Expand Down
22 changes: 0 additions & 22 deletions packages/core/test/tool-registry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,6 @@ describe("Tool", () => {
{
before: make(),
"": make(),
["x".repeat(129)]: make(),
"echo.tool": constant("first"),
echo_tool: constant("last"),
execute: make(),
Expand All @@ -346,27 +345,6 @@ describe("Tool", () => {
}),
)

it.effect("registers 128-character MCP tool names in Code Mode", () =>
Effect.gen(function* () {
const service = yield* Tool.Service
const name = "x".repeat(128)
yield* transform(service, { [name]: make(), ["x".repeat(129)]: make() }, { namespace: "cloudflare" })

const snapshot = yield* service.snapshot()
expect(codeModeListings(snapshot.codeModeCatalog!).map((tool) => tool.path)).toEqual([`cloudflare.${name}`])
const result = yield* snapshot.execute({
...call("execute"),
call: {
type: "tool-call",
id: "call-long-mcp-name",
name: "execute",
input: { code: `return (await tools.cloudflare[${JSON.stringify(name)}]({ text: "hello" })).text` },
},
})
expect(result.content).toEqual([{ type: "text", text: "hello" }])
}),
)

it.effect("executes native tools without requiring letter-leading names or namespace segments", () =>
Effect.gen(function* () {
const service = yield* Tool.Service
Expand Down
Loading