Skip to content

fix(client): respect session group capabilities#2861

Open
he-yufeng wants to merge 1 commit into
modelcontextprotocol:mainfrom
he-yufeng:fix/session-group-capabilities
Open

fix(client): respect session group capabilities#2861
he-yufeng wants to merge 1 commit into
modelcontextprotocol:mainfrom
he-yufeng:fix/session-group-capabilities

Conversation

@he-yufeng

Copy link
Copy Markdown

Fixes #2689.

ClientSessionGroup was querying prompts, resources, and tools on every connection, even when the server did not advertise those capabilities during initialize. For a tools-only server that meant two extra JSON-RPC calls that came back as Method not found warnings.

This changes _aggregate_components to use negotiated capabilities when an initialize_result is available:

  • skip list_prompts() when capabilities.prompts is absent
  • skip list_resources() when capabilities.resources is absent
  • skip list_tools() when capabilities.tools is absent
  • preserve the existing fallback behavior when no initialize result is available

I also added a regression test for a tools-only server session: it still aggregates the advertised tool, and list_prompts / list_resources are not awaited.

Validation:

uv run python -m py_compile src/mcp/client/session_group.py tests/client/test_session_group.py
uv run ruff check src/mcp/client/session_group.py tests/client/test_session_group.py
uv run ruff format --check src/mcp/client/session_group.py tests/client/test_session_group.py
uv run pyright src/mcp/client/session_group.py tests/client/test_session_group.py
uv run pytest tests/client/test_session_group.py -q

@he-yufeng he-yufeng force-pushed the fix/session-group-capabilities branch from 2334d95 to e729d1b Compare June 14, 2026 01:46
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