Repository navigation
feat(unstable): attribute mcp/message requests to a session and tool call - #2988
Merged
Merged
Conversation
…call `serverId` selects a server, but it does not say which ACP session or tool call an `mcp/message` request was sent for. The request can now carry optional `sessionId` and `toolCallId` fields in both protocol versions. - A provider can use `sessionId` to choose which session a request runs for, and can reject a request that has none with `-32602`. - `toolCallId` links the request to the tool call the Agent reports, so a Client can show its own view of the tool on that tool call. - The JSON Schema requires `sessionId` when `toolCallId` is present. The MCP-over-ACP RFD has the rules, the reasons, the alternatives and two open questions. The draft subagent pages name `mcp/message` as the one request for a child's work that can omit the child's `sessionId`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
An
mcp/messagerequest selects a server withserverId. Nothing says which ACP session or tool call the request was sent for. The same registration can be offered to several sessions, and a child session can use a server that was declared to its parent.This adds two optional fields to the unstable
mcp/messagerequest, in both protocol versions:sessionId: the session whose work caused the request. For a child session's work, that is the child's ID.toolCallId: the tool call in that session that the request is part of. It is only sent together withsessionId.Why
toolCallIda client can show its own view of the tool on that tool call, show output while the tool runs, tell concurrent calls with the same arguments apart, and tie the request to a permission request or elicitation for the same tool call.Rules
For the agent:
sessionIdunless the session is active on the connection, or is an announced child of an active session, and the server was declared to that session or to one of its ancestors.session/updatebefore it sends a request that names it.For the provider:
sessionIdto choose which session a request acts on, after it checks the session. A failed check is rejected with-32602.sessionIdwith-32602, when it needs the session to run the request.toolCallIdis missing or unknown.Changes
sessionIdandtoolCallIdonMessageMcpRequestin v1 and v2, anif/thenso thattoolCallIdrequiressessionId, and the v2x-scopehint.mcp/messageis the one request for a child's work that can omit the child'ssessionId.AGENTS.md(separate commit): the Node tests inscripts/schema-testsare only for JSON Schema validation.Open questions
Both are listed in the RFD.
sessionIdit rejects, and for a missing one it needs. This PR uses-32602for both.sessionIdcan tell atinitialize.Not in this PR
No implementation sends or checks the fields yet. An unpublished prototype test against the Claude Code adapter showed that an HTTP adapter can produce both.
Testing
cargo test --all-features, and the per-featureschema-generatorand schema crate runs from CInpm run test:json-schema, with a newmcp.test.mjsfor theif/thenrulecargo clippyin the three CI configurations,cargo fmt -- --check, Prettier, and the spellcheck