Conversation
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
The direct LLM protocol implementation and lifecycle negotiation warrant final human validation despite strong smoke-test coverage.
Review effort: Balanced
Findings: None
What changed in this PR
Updates the Rust MCP examples for modern protocol negotiation and direct Anthropic Messages API integration.
Changes:
- Adds MCP
2026-07-28negotiation with legacy fallback. - Replaces
genaiwithreqwest, preserving thinking blocks and tool errors. - Upgrades Rust dependencies and adds tool-loop smoke coverage.
| File | Description |
|---|---|
mcp-client-rust/src/main.rs |
Implements negotiation and direct Messages API calls. |
mcp-client-rust/Cargo.toml |
Updates and simplifies dependencies. |
mcp-client-rust/Cargo.lock |
Records client dependency changes. |
mcp-client-rust/README.md |
Documents API access and negotiation. |
weather-server-rust/src/main.rs |
Migrates to ServerConfig. |
weather-server-rust/Cargo.toml |
Upgrades and removes unused dependencies. |
weather-server-rust/Cargo.lock |
Records server dependency changes. |
tests/smoke-test.sh |
Adds Rust tool-loop testing. |
tests/README.md |
Documents complete client coverage. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Motivation and Context
Three problems in the Rust examples, all found while reviewing #200.
1. The client could not reach protocol
2026-07-28. rmcp'sserveonly performs the legacyinitializehandshake, andProtocolVersion::LATESTis still2025-11-25even in rmcp 3.4, so bumpingthe SDK does not fix this on its own. Under
2025-11-25a server cannot offer this era's features, so theclient could not call any tool with an array-rooted
outputSchema— includingget_alerts, which everyweather server in this repo declares that way. Against the Python server it failed at
tools/list;against the TypeScript server and the test mock it failed at
tools/call.2. The
genaicrate could not express three things the client needs. The first was raised by Copiloton #200:
genai0.4.2 keeps Anthropic'sthinking/redacted_thinkingblocks out ofChatResponse.contentand does not retain the signature, so the follow-up request after a thinking turncould not echo them back as the API requires.
ToolResponsehas nois_errorfield, so a failed tool call reached the model lookinglike a successful one.
client was the one client excluded from the tool-loop smoke test added in Fix the tool-use loop in the Go, Rust, and Ruby clients and add a tool-loop smoke test #200.
I checked whether a
genaibump would solve any of this. It does not: as of 0.6.5 the Anthropic adapterstill drops
ThoughtSignatureparts when sending, andToolResponsestill has onlycall_idandcontent.3. Both examples were several rmcp releases behind, 3.1.2 against 3.4.0, and each carried
tracingandtracing-subscriberdependencies that no source file references.What changed
mcp-client-rustserve_with_lifecycleandClientLifecycleMode::Auto: oneserver/discoverprobe for2026-07-28, falling back to the2025-11-25initializehandshake. This is rmcp's equivalent of theautomode the Python and TypeScript clients already use. The negotiated revision is printed onconnect, as the Python client does.
clientInfoviaClientConfig. It previously identified itself asrmcp3.4.0.genaiwith a directreqwestcall to the Messages API. There is no official Anthropic SDKfor Rust, and calling the endpoint directly is what makes the other two fixes possible: an assistant
turn is kept as raw content blocks and fed back byte-for-byte, signatures included, and a tool result
carries a real
is_error.ANTHROPIC_BASE_URLnow overrides the endpoint, matching the official SDKs.rmcpto 3.4,jsonschemato 0.56,reqwestto 0.13,tokioto 1.53, and drops thetracing,tracing-subscriberandserver-feature dependencies, none of which were referenced. Droppinggenaitakes the lockfile from 312 crates to 256.
{:#}), so a wrapped cause is no longer hidden.weather-server-rustrmcpto 3.4,tokioto 1.53,reqwestto 0.13, and drops the unreferencedtracingandtracing-subscriberdependencies.ServerInfoalias, which rmcp 3.4 deprecates in favour ofServerConfig.Tests
Note that rmcp 3.4's MSRV is 1.88, which is exactly the "Rust 1.88+" the READMEs already asked for. That
requirement is now justified rather than arbitrary.
How Has This Been Tested?
thinking blocks come back with their signature and the one that requires
is_error. It could not havepassed any of those before this change.
Connected over protocol 2026-07-28against the Python, TypeScript and Rust weatherservers. The Python server previously rejected its
tools/listoutright../tests/smoke-test.shpasses every step my machine has a toolchain for, which is all of them exceptGo and Ruby; those two were exercised in
golang:1.25andruby:3.4containers and are unaffected bythis PR.
cargo buildis clean, no warnings, for both examples in debug and release.Breaking Changes
None for anyone running the examples. The client's command line, output and no-key behaviour are
unchanged. Worth flagging for reviewers: this swaps the Rust client's LLM library, so the diff in
src/main.rsis larger than a dependency bump would suggest.Types of changes
Checklist
AI assistance
The investigation, code changes and this description were prepared with Claude Code and
reviewed by me.