Skip to content

fix(mcp): gate text payload omission on negotiated protocol version - #1388

Merged
cameri merged 1 commit into
cameri:rewrite/mainfrom
tirthraj01:fix/1324-mcp-text-content
Dec 4, 2026
Merged

cameri merged 1 commit into
cameri:rewrite/mainfrom
tirthraj01:fix/1324-mcp-text-content

Conversation

@tirthraj01

@tirthraj01 tirthraj01 commented Dec 4, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #1324

Summary

  • 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+.

Verification

  • cargo fmt --all --check
  • cargo clippy -p nostream-mcp --all-targets --all-features -- -D warnings
  • cargo 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::panic
  • cargo 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-features

Summary by CodeRabbit

  • New Features
    • 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.

@coderabbitai

coderabbitai Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

Commits

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.

Changes: MCP text fallback

Layer / File(s) Summary
Version-gated tool response fallback
crates/nostream-mcp/src/server.rs, .changeset/mcp-text-content-fallback.md
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.
Protocol-version compatibility tests
crates/nostream-mcp/tests/common/mod.rs, crates/nostream-mcp/tests/tool_payloads.rs
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: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed 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 Passed 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 Passed 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.

Share

Recent review info

Run configuration

Commits

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.

@greptile-apps

greptile-apps Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5RetriggerView in Greptile

[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.

Reviews (2) · Last reviewed commit: "Merge branch 'rewrite/main' into fix/132..." · Reviewed by Greptile

Comment thread crates/nostream-mcp/src/server.rs Resolved
@changeset-bot

changeset-bot Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 47463c3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@tirthraj01
tirthraj01 force-pushed the fix/1324-mcp-text-content branch from 44c751a to 47463c3 Compare December 4, 2026 15:59
@cameri
cameri merged commit 4c4f6a6 into cameri:rewrite/main Dec 4, 2026
17 checks passed
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.

2 participants