Skip to content

fix(server): track renamed registered item keys#2114

Open
pragnyanramtha wants to merge 2 commits into
modelcontextprotocol:mainfrom
pragnyanramtha:pragnyan/fix-registered-item-renames
Open

fix(server): track renamed registered item keys#2114
pragnyanramtha wants to merge 2 commits into
modelcontextprotocol:mainfrom
pragnyanramtha:pragnyan/fix-registered-item-renames

Conversation

@pragnyanramtha
Copy link
Copy Markdown

Root cause

McpServer registered item update closures deleted entries using the original registration key captured at creation time. After a tool, prompt, resource, or resource template was renamed once, a second rename or later remove() still deleted the original key, leaving stale entries in the internal registries.

Change

Track the current registry key inside each registered item closure and update it when the item is renamed. Prompt handlers are regenerated with the current prompt name so validation errors also reflect the active name after a rename.

Focused regression coverage verifies repeated rename plus removal for registered tools, prompts, static resources, and resource templates.

Validation

  • pnpm --filter @modelcontextprotocol/server test -- mcp.compat.test.ts
  • pnpm --filter @modelcontextprotocol/server typecheck
  • pnpm --filter @modelcontextprotocol/server lint
  • git diff --check

Attempted the repository pre-push hook as well. It progressed through broad workspace checks but failed after ~9 minutes in packages/middleware/node build with tsdown exit status 134; the touched server package checks above passed.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 17, 2026

🦋 Changeset detected

Latest commit: 90525d4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@modelcontextprotocol/server Patch
@modelcontextprotocol/express Patch
@modelcontextprotocol/fastify Patch
@modelcontextprotocol/hono Patch
@modelcontextprotocol/node Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 17, 2026

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/@modelcontextprotocol/client@2114

@modelcontextprotocol/server

npm i https://pkg.pr.new/@modelcontextprotocol/server@2114

@modelcontextprotocol/express

npm i https://pkg.pr.new/@modelcontextprotocol/express@2114

@modelcontextprotocol/fastify

npm i https://pkg.pr.new/@modelcontextprotocol/fastify@2114

@modelcontextprotocol/hono

npm i https://pkg.pr.new/@modelcontextprotocol/hono@2114

@modelcontextprotocol/node

npm i https://pkg.pr.new/@modelcontextprotocol/node@2114

commit: 90525d4

@pragnyanramtha pragnyanramtha marked this pull request as ready for review May 17, 2026 01:06
@pragnyanramtha pragnyanramtha requested a review from a team as a code owner May 17, 2026 01:06
Copilot AI review requested due to automatic review settings May 17, 2026 01:06
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@BossChaos

This comment was marked as abuse.

@BossChaos

This comment was marked as abuse.

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.

3 participants