Skip to content

fix: allow prototype property names in app tool registry - #862

Open
lj1166 wants to merge 1 commit into
modelcontextprotocol:mainfrom
lj1166:fix/app-tool-name-collisions
Open

lj1166 wants to merge 1 commit into
modelcontextprotocol:mainfrom
lj1166:fix/app-tool-name-collisions

Conversation

@lj1166

@lj1166 lj1166 commented Nov 18, 2026

Copy link
Copy Markdown

Fixes #861.

App.registerTool("constructor", ...) currently throws "already registered" on a fresh App because its tool registry inherits from Object.prototype. The same inherited entries hide page-registered WebMCP tools from tools/list and misroute tools/call.

Initialize the registry with Object.create(null). Add six integration regressions for constructor, toString and __proto__: App registration/listing/calling, genuine duplicate rejection and removal, plus listing/calling page-registered tools through the WebMCP bridge. The tests use linked real SDK InMemoryTransports and the existing WebMCP fixture.

Validation on Windows, Bun 1.3.10 / Node 24.19.0:

  • Both changed test files: 22 pass / 6 fail before the fix; 28 pass / 0 fail after it.
  • bun test src: 363 pass, 0 fail.
  • npm test: 454 pass, 4 skip, 2 fail. Both failures are existing PDF-example tests hitting EPERM at fs.symlinkSync; reproduced with the production change reverted.
  • npm run build, tsc --noEmit, TypeDoc link validation, changed-file Prettier and git diff --check: pass.
  • Repository-wide Prettier reports only unchanged CLAUDE.md: this Windows checkout materializes that tracked symlink as a plain file containing AGENTS.md.
  • Browser E2E and all-example builds were not run locally.

AI assistance: Codex found the bug during source review, implemented the patch, ran the reproduction/checks and drafted this PR under the account holder's instruction. Independent human review is not claimed.

This branch has not been deployed

No deployments
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.

App.registerTool rejects valid tool names inherited from Object.prototype

1 participant