Skip to content

feat(session-group): add read_resource and get_prompt routing - #3577

Closed
baselarw wants to merge 1 commit into
modelcontextprotocol:mainfrom
baselarw:feat/session-group-read-resource-get-prompt
Closed

baselarw wants to merge 1 commit into
modelcontextprotocol:mainfrom
baselarw:feat/session-group-read-resource-get-prompt

Conversation

@baselarw

@baselarw baselarw commented Sep 24, 2026

Copy link
Copy Markdown

Fixes #3579

Add ClientSessionGroup.read_resource() and ClientSessionGroup.get_prompt() so the
group can route resource reads and prompt fetches to the owning server, the same way
call_tool() already does.

Motivation and Context

ClientSessionGroup aggregates tools, resources, and prompts from every connected
server into one view, and call_tool(name, ...) resolves a name to the session that
owns it and forwards the call. But that routing existed only for tools. A caller who
wanted to read an aggregated resource or fetch an aggregated prompt had to track the
owning ClientSession themselves and bypass the group entirely — an asymmetry in an
otherwise "one object, one view" abstraction.

This adds the two missing routed calls:

  • read_resource(name, ...)
  • get_prompt(name, arguments, ...)

Both resolve the aggregate key (honoring component_name_hook) to the owning session
via new _resource_to_session / _prompt_to_session reverse indexes, then forward the
resource's real wire URI / the prompt's real wire name. They carry the same
allow_input_required overloads as ClientSession, so a server that needs input
mid-call behaves identically through the group. The reverse indexes are cleaned up in
disconnect_from_server, matching how _tool_to_session is already handled.

How Has This Been Tested?

  • Unit tests (mock sessions) asserting each method resolves the aggregate key to the
    owning session and forwards the correct wire identifier and arguments, plus KeyError
    for unknown names.
  • In-memory end-to-end tests using Client(server) against real MCPServer instances:
    one reads a resource (library://hours), one fetches a prompt, both routed through the
    group.
  • A disconnect test confirming the resource/prompt reverse indexes are cleared.
  • Full local gate per AGENTS.md: pytest, ruff format, ruff check, pyright,
    100% coverage on src/mcp/client/session_group.py, strict-no-cover, and markdownlint
    on the docs page. All green.

Breaking Changes

None. This only adds two methods to an existing public class and internal reverse
indexes. No existing signature or behavior changes.

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 am assigned to the linked issue (or it is labeled help wanted, or I'm a maintainer)
  • I have disclosed any AI assistance and can explain the change in my own words
  • 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

Additional context

read_resource/get_prompt deliberately mirror the existing call_tool design: same
reverse-index routing, same "aggregate key in, real wire identifier out" behavior, and
the same allow_input_required overload pair. Docs updated in
docs/client/session-groups.md with a new "Reading resources and prompts" section and a
recap line.

ClientSessionGroup could aggregate resources and prompts and call_tool
against them, but offered no routed way to actually read a resource or get a
prompt: callers had to track the owning session themselves.

Add read_resource(name, ...) and get_prompt(name, arguments, ...) mirroring
call_tool: they resolve the aggregate key (honoring component_name_hook) to
the owning session via new _resource_to_session / _prompt_to_session reverse
indexes and forward the resource's wire URI / prompt's wire name. Both carry
the same allow_input_required overloads as ClientSession. Reverse indexes are
cleaned up on disconnect_from_server. Adds unit + in-memory end-to-end tests
and documents the methods in the session-groups guide.
@github-actions github-actions Bot added the missing-issue-link Auto-closed: PR needs a linked issue assigned to its author (see CONTRIBUTING.md) label Sep 24, 2026
@github-actions

github-actions Bot commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

This PR has been closed automatically. This repo only keeps pull requests open when they come from a maintainer, or from a contributor a maintainer has assigned to the linked issue, and you aren't currently assigned to #3579.

If a maintainer assigns you to #3579, this PR reopens on its own and there's nothing more you need to do here. Assignment is a maintainer call based on capacity; comments that only ask to be assigned don't factor in. What does help is engaging on the issue itself by confirming the repro, explaining why it matters for your use case, or describing the approach you'd take.

You're welcome to keep pushing commits here (just avoid force-pushing, since GitHub can't reopen a rewritten branch), but that on its own won't get the PR reviewed or the issue assigned, and realistically most auto-closed PRs stay closed. There's no need to open a new PR either way.

CONTRIBUTING.md has the full reasoning, but in short:

  • We're a small team with very little capacity to review community PRs right now.
  • Many recent PRs are AI-generated with little human review, and reviewing one carefully still costs a maintainer as much time as it ever did. A well-described issue is usually more useful to us than the code.

Maintainers: reopen, remove missing-issue-link, or add bypass-issue-check to override.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

missing-issue-link Auto-closed: PR needs a linked issue assigned to its author (see CONTRIBUTING.md)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ClientSessionGroup has no routed read_resource / get_prompt (only call_tool)

1 participant