Skip to content

Rename MCP and Mastra tools at register time - #569

Open
andrelandgraf wants to merge 5 commits into
mainfrom
tools-t9-adapter-names
Open

andrelandgraf wants to merge 5 commits into
mainfrom
tools-t9-adapter-names

Conversation

@andrelandgraf

@andrelandgraf andrelandgraf commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator

Problem

registerNeonTools and toMastraTools iterate Object.values(tools) and publish tool.id. A host that remaps the catalog ({ listProjects: tools.list_projects }) still publishes list_projects. Renaming meant going back to createNeonTools({ names }). Two tools that collide on id failed inside the MCP SDK, not in Neon.

Solution

Optional { name?: (tool) => string } on both adapters. Duplicate published names throw before registerTool.

registerNeonTools(server, tools, { name: (tool) => `neon_${tool.id}` });

toMastraTools(tools, { name: (tool) => `neon_${tool.id}` });

Default is still tool.id. toMastraTools(tools) stays keyed by Tool["id"]. toMastraTools(tools, { name }) returns Record<string, { id: string; … }>.

Verification

  • pnpm --filter @neon/sdk build
  • pnpm --filter @neon/tools tsc
  • pnpm --filter @neon/tools exec vitest run
  • MCP listTools publishes neon_list_projects when name prefixes tool.id
  • Duplicate name() results throw Duplicate published tool name "same" with zero registerTool calls
  • Mastra id follows the same name function
  • Type tests: default catalog has list_projects; { name } types neon_list_projects.id as string

Gaps

createNeonTools({ names }) is unchanged. This option is only the adapter publish name.

A name function's return type is string, so TypeScript cannot prove a specific key like "neon_list_projects" is the only key.

createNeonTools({ names }) is too early for a host that only sees the catalog at registerNeonTools / toMastraTools.
toMastraTools({ name }) published neon_list_projects at runtime while TypeScript still typed list_projects.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant