Skip to content

fix(server): sync resource and template title on metadata updates (#3103) - #3141

Open
SameRainbows wants to merge 4 commits into
modelcontextprotocol:mainfrom
SameRainbows:fix/resource-metadata-title-sync-3103
Open

SameRainbows wants to merge 4 commits into
modelcontextprotocol:mainfrom
SameRainbows:fix/resource-metadata-title-sync-3103

Conversation

@SameRainbows

Copy link
Copy Markdown

Problem

Fixes #3103.

In packages/server/src/server/mcp.ts, _createRegisteredResource and _createRegisteredResourceTemplate synchronized title into metadata.title when updates.title !== undefined. However, when updating metadata alone without an explicit updates.title:

  • If updates.metadata.title is defined, registeredResource.title was not updated and remained stale.
  • If updates.metadata omitted title, the existing title in metadata was replaced, causing resources/list and resources/templates/list (which spread ...resource.metadata) to drop the title.

Solution

In _createRegisteredResource and _createRegisteredResourceTemplate:

  • When updates.metadata.title is defined, synchronize it to title.
  • When updates.metadata omits title but title exists on the registered item, preserve the existing title in metadata.
  • Retain existing precedence where an explicit updates.title wins.

Testing

Added unit tests in packages/server/test/server/resourceMetadataTitleSync.test.ts covering:

  1. registeredResource.update metadata-only update preserving top-level title.
  2. registeredResource.update metadata update with new title synchronizing to top-level title.
  3. registeredResourceTemplate.update metadata-only update preserving template title.
  4. registeredResourceTemplate.update metadata update with new title synchronizing to template title.

Included patch changeset for @modelcontextprotocol/server.

@SameRainbows
SameRainbows requested a review from a team as a code owner November 1, 2026 15:51
@changeset-bot

changeset-bot Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d87854d

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

This PR includes changesets to release 6 packages
Name Type
@modelcontextprotocol/server Patch
@modelcontextprotocol/client Patch
@modelcontextprotocol/codemod Patch
@modelcontextprotocol/core Patch
@modelcontextprotocol/server-legacy Patch
@modelcontextprotocol/core-internal 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

pkg-pr-new Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@modelcontextprotocol/client

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

@modelcontextprotocol/codemod

npm i https://pkg.pr.new/@modelcontextprotocol/codemod@3141

@modelcontextprotocol/core

npm i https://pkg.pr.new/@modelcontextprotocol/core@3141

@modelcontextprotocol/server

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

@modelcontextprotocol/server-legacy

npm i https://pkg.pr.new/@modelcontextprotocol/server-legacy@3141

@modelcontextprotocol/express

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

@modelcontextprotocol/fastify

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

@modelcontextprotocol/hono

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

@modelcontextprotocol/node

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

commit: d87854d

@claude claude Bot added the v2 Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixes label Nov 2, 2026

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

v2 Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

server: registeredResource.update and registeredResourceTemplate.update desync title and metadata.title when updating metadata alone

1 participant