Skip to content

fix(client): skip unsupported capability requests in ClientSessionGroup#2810

Open
bobby-nandigam wants to merge 3 commits into
modelcontextprotocol:mainfrom
bobby-nandigam:fix-2689-capability-negotiation
Open

fix(client): skip unsupported capability requests in ClientSessionGroup#2810
bobby-nandigam wants to merge 3 commits into
modelcontextprotocol:mainfrom
bobby-nandigam:fix-2689-capability-negotiation

Conversation

@bobby-nandigam
Copy link
Copy Markdown

MCP Python SDK Contribution – Issue #2689

Respect Negotiated Capabilities in ClientSessionGroup

Overview

This contribution improves capability negotiation behavior in the MCP Python SDK.

Previously, ClientSessionGroup._aggregate_components() attempted to retrieve prompts, resources, and tools from every connected server regardless of the capabilities negotiated during initialization.

Problem

During server initialization, MCP servers advertise their supported capabilities. However, the existing implementation attempted to call:

  • list_prompts()
  • list_resources()
  • list_tools()

without verifying whether those capabilities were available.

Solution

The implementation now checks the negotiated capabilities before requesting server components.

New Behavior

  • Query prompts only when prompt capabilities are advertised.
  • Query resources only when resource capabilities are advertised.
  • Query tools only when tool capabilities are advertised.

This ensures that ClientSessionGroup interacts only with features explicitly supported by the connected server.

Testing

Added regression test:

test_client_session_group_skips_unsupported_capabilities

Validation

uv run pytest tests/client/test_session_group.py -v

Output:

12 passed

Files Modified

  • src/mcp/client/session_group.py
  • tests/client/test_session_group.py

Benefits

  • Better protocol compliance
  • Reduced unnecessary RPC requests
  • Improved compatibility with capability-limited MCP servers
  • More predictable client behavior

Related Issue

Fixes #2689

Author

Bobby Nandigam

@bobby-nandigam bobby-nandigam changed the title Respect negotiated capabilities in ClientSessionGroup fix(client): skip unsupported capability requests in ClientSessionGroup Jun 7, 2026
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.

ClientSessionGroup attempts to use capabilities that were not advertised

1 participant