You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(mcp): gate text payload omission on negotiated protocol version - #1388
Gate the content omission on the client's negotiated MCP protocol version in ServerHandler::call_tool (crates/nostream-mcp/src/server.rs):
Clients negotiating 2025-06-18 (ProtocolVersion::V_2025_06_18) or newer keep receiving only structuredContent with an empty content array, preserving the wire-byte savings.
Clients on pre-structuredContent revisions (2024-11-05, 2025-03-26) or without a declared protocol version receive the serialized JSON in a TextContent block in content alongside structuredContent.
Add client_with_protocol in crates/nostream-mcp/tests/common/mod.rs, unit coverage in crates/nostream-mcp/src/server.rs, and a_pre_structured_client_receives_the_payload_as_text in crates/nostream-mcp/tests/tool_payloads.rs while keeping a_success_carries_one_copy_of_the_payload passing for 2025-06-18+.
Successful tool responses now include a JSON text block for clients using protocol versions earlier than 2025-06-18, or clients that don’t specify a version, when the response has no existing content.
Clients using 2025-06-18 or later continue to receive structured content without the additional text block. Error responses and incomplete results are unchanged.
Reviewing files that changed from the base of the PR and between 44c751a and 47463c3.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Walkthrough
Tool responses now include serialized JSON text for successful calls from clients using protocol versions before 2025-06-18 or no declared version. Newer clients continue to receive structured content without the text copy. Tests cover the version threshold and payload responses.
call_tool adds serialized structured content as text when a successful response has empty content and the client uses an older or undeclared protocol version. Newer versions retain structured-only responses. A unit test checks the version threshold.
The test client can connect with a selected protocol version. Payload tests verify that clients using 2024-11-05 or 2025-03-26 receive one text block matching structured_content, while newer versions use structuredContent only.
Suggested reviewers:chappie-daemon
Change: Bug fix · Severity of issue fixed: Medium
Merge Risk: Minimal · previous review 44c75
Successful tool calls from older or undeclared-version MCP clients now include the payload as a text block, and newer clients keep the structured-only responses. The change is small, guarded, and covered by unit and integration tests, so merge risk is minimal.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names the main change: the text payload omission in tool results is now gated on the negotiated MCP protocol version. The changeset adds text content fallback for clients older than 2025-06-…
Linked Issues check
Issue #1324 requires that text-only clients can read every successful tool payload, and that coverage either asserts a text block exists or verifies a negotiated-version gate. The PR gates the `conten…
Out of Scope Changes check
All changed areas connect to #1324. The changeset (.changeset/mcp-text-content-fallback.md) is a patch note for the same behavior change. The server.rs change gates the text fallback on protocol v…
Full details: Title check
Explanation
The title names the main change: the text payload omission in tool results is now gated on the negotiated MCP protocol version. The changeset adds text content fallback for clients older than 2025-06-18 or with no declared version, and the linked issue #1324 asks for text-only client support. The title is specific, follows the conventional commit style, and is under 70 characters.
Full details: Linked Issues check
Explanation
Issue #1324 requires that text-only clients can read every successful tool payload, and that coverage either asserts a text block exists or verifies a negotiated-version gate. The PR gates the content omission on the negotiated protocol version in ServerHandler::call_tool (crates/nostream-mcp/src/server.rs, per the PR description and raw summary). Clients on 2024-11-05, 2025-03-26, or with no declared version receive the serialized JSON in a TextContent block alongside structuredContent. Clients on 2025-06-18 or newer keep the structured-only result. The issue allows this gate as an alternative to always including one text copy. Coverage: a_pre_structured_client_receives_the_payload_as_text in tests/tool_payloads.rs asserts the text block for pre-structured clients, client_with_protocol in tests/common/mod.rs supplies the negotiated version, unit tests in server.rs cover the version threshold, and a_success_carries_one_copy_of_the_payload remains the check for 2025-06-18+. Limitation: the whole-PR diff could not be read (changed blobs unavailable in the checkout). This verdict relies on the PR description and summary, and on the head file's module content. The exact call_tool branch logic was not verified line by line.
Full details: Out of Scope Changes check
Explanation
All changed areas connect to #1324. The changeset (.changeset/mcp-text-content-fallback.md) is a patch note for the same behavior change. The server.rs change gates the text fallback on protocol version. The tests/common/mod.rs change adds client_with_protocol so tests can negotiate a specific version. The tests/tool_payloads.rs change adds the pre-structured client test and keeps the 2025-06-18+ duplication check. The raw summary reports no changes to exported or public declarations beyond the test helper method. The PR description's verification commands are consistent with these files. Limitation: the whole-PR diff could not be read, so the scope judgment relies on the summary and description.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Fix failing CI checks
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Reviewing files that changed from the base of the PR and between db0be6a and 44c751a.
Files selected for processing: 4
.changeset/mcp-text-content-fallback.md
crates/nostream-mcp/src/server.rs
crates/nostream-mcp/tests/common/mod.rs
crates/nostream-mcp/tests/tool_payloads.rs
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
[Medium impact] The PR appears safe to merge; no new actionable issues were found.
Summary
Adds a JSON text copy to successful tool responses for older clients or clients without a declared protocol version. Clients using 2025-06-18 or later keep the smaller response.
Older MCP clients now get tool results as readable text.
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
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.
Fixes #1324
Summary
contentomission on the client's negotiated MCP protocol version inServerHandler::call_tool(crates/nostream-mcp/src/server.rs):2025-06-18(ProtocolVersion::V_2025_06_18) or newer keep receiving onlystructuredContentwith an emptycontentarray, preserving the wire-byte savings.structuredContentrevisions (2024-11-05,2025-03-26) or without a declared protocol version receive the serialized JSON in aTextContentblock incontentalongsidestructuredContent.client_with_protocolincrates/nostream-mcp/tests/common/mod.rs, unit coverage incrates/nostream-mcp/src/server.rs, anda_pre_structured_client_receives_the_payload_as_textincrates/nostream-mcp/tests/tool_payloads.rswhile keepinga_success_carries_one_copy_of_the_payloadpassing for2025-06-18+.Verification
cargo fmt --all --checkcargo clippy -p nostream-mcp --all-targets --all-features -- -D warningscargo clippy -p nostream-mcp --lib --bins --all-features -- -D warnings -D clippy::unwrap_used -D clippy::expect_used -D clippy::todo -D clippy::unimplemented -D clippy::paniccargo test -p nostream-mcp --lib --test audit --test maintenance --test relay_status --test store_families --test tool_payloads --test tools_list --test write_tools --all-featuresSummary by CodeRabbit
2025-06-18, or clients that don’t specify a version, when the response has no existing content.2025-06-18or later continue to receive structured content without the additional text block. Error responses and incomplete results are unchanged.