Skip to content

Conversation

@PederHP
Copy link
Member

@PederHP PederHP commented Jan 14, 2026

Motivation and Context

Going through logs of an MCP server not advertising prompts during capabilities negotiation, I noticed listPrompts requests from a client causing a lot of noise. I was about to create an issue with the client, but on second thought, I think the SDK shouldn't require clients to check capabilities manually before calling list methods. I can't think when it would ever be a good idea to send the request to a server that doesn't advertise the capability, so the SDK should make it easy to call the methods without causing server noise and just get an empty list anyway.

Per the MCP spec, "Both parties SHOULD respect capability negotiation." Previously, calling listPrompts/listResources/listTools on a server that didn't advertise those capabilities would still send the request, causing servers to log warnings and creating unnecessary traffic.

Now the Client respects capability negotiation by default:

  • listPrompts() returns { prompts: [] } if server lacks prompts capability
  • listResources() returns { resources: [] } if server lacks resources capability
  • listResourceTemplates() returns { resourceTemplates: [] } if server lacks resources capability
  • listTools() returns { tools: [] } if server lacks tools capability

Each logs a debug message when this occurs for visibility. Let me know if you want this removed - I was unsure whether to add it.

The existing enforceStrictCapabilities option is preserved - when set to true, these methods will still throw errors as before.

Also fixed three subtle test bugs with incorrect capability declaration.

How Has This Been Tested?

Added tests.

Breaking Changes

None

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

@PederHP PederHP requested a review from a team as a code owner January 14, 2026 20:04
@changeset-bot
Copy link

changeset-bot bot commented Jan 14, 2026

🦋 Changeset detected

Latest commit: 51ddff5

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

This PR includes changesets to release 1 package
Name Type
@modelcontextprotocol/client 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

pkg-pr-new bot commented Jan 14, 2026

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/client@1386

@modelcontextprotocol/server

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/server@1386

@modelcontextprotocol/express

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/express@1386

@modelcontextprotocol/hono

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/hono@1386

@modelcontextprotocol/node

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/node@1386

commit: 51ddff5

Per the MCP spec, "Both parties SHOULD respect capability negotiation."
Previously, calling listPrompts/listResources/listTools on a server that
didn't advertise those capabilities would still send the request, causing
servers to log warnings and creating unnecessary traffic.

Now the Client respects capability negotiation by default:
- listPrompts() returns { prompts: [] } if server lacks prompts capability
- listResources() returns { resources: [] } if server lacks resources capability
- listResourceTemplates() returns { resourceTemplates: [] } if server lacks resources capability
- listTools() returns { tools: [] } if server lacks tools capability

Each logs a debug message when this occurs for visibility.

The existing enforceStrictCapabilities option is preserved - when set to
true, these methods will still throw errors as before.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@PederHP PederHP force-pushed the respect-capability-negotiation-in-list-methods branch from 87ed7c6 to 8fcec13 Compare January 14, 2026 20:22
PederHP and others added 3 commits January 14, 2026 21:26
These tests were setting up servers with tools capability in the constructor
but then returning empty capabilities in the InitializeRequestSchema handler.
Now that the client respects capability negotiation, listTools() was returning
empty lists since no tools capability was advertised.

Fixed by returning { tools: {} } in the InitializeRequestSchema handlers.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
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.

2 participants