feat: implement bidirectional communication for MCP conformance#88
Merged
feat: implement bidirectional communication for MCP conformance#88
Conversation
Add ToolContext trait and real-time SSE streaming to support server-to-client requests (sampling, elicitation) and notifications (progress, logging) during tool execution. Key changes: - ToolContext trait with send_log, send_progress, request_sampling - Real-time SSE streaming for POST responses - Support for numeric and string progressToken - Sync RwLock for pending request correlation Closes #86, #87
Code Coverage Report 📊Local Coverage: 21.66%
Coverage Details📋 Full Report: View on Codecov |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
PR Validation ResultsQuick Validation: ✅
Compatibility Check: ✅
Summary: ✅ All checks passed |
Add ~300 new tests covering: - ToolContext trait and implementations (tool_context_tests.rs) - StreamableHttp transport bidirectional features - Transport lib streaming context functions - Server configuration edge cases These tests improve coverage for the bidirectional communication feature implemented in the previous commit.
ConnectionError maps to Transport, SessionNotFound maps to RequestFailed.
Cover notification error mappings (SessionNotFound, ChannelClosed, NotSupported). Add tests for try_current_context, with_context, and create_tool_context edge cases.
Cover audio content, resource content (new signature), PromptMessage.new_resource, and CompleteResult.with_values constructors.
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
ToolContexttrait for server-to-client communication during tool executionKey Changes
New Features
ToolContexttrait withsend_log(),send_progress(),request_sampling(),request_elicitation()DefaultToolContextimplementation withTransportBridgefor transport-agnostic communicationexamples/conformance-server/)Bug Fixes
progressTokenextraction to handle both string and integer typespending_requestsfromtokio::sync::RwLocktostd::sync::RwLockto avoid "cannot block in async runtime" panicArchitecture
StreamingNotificationnow has optionalidfield to support both notifications (no id) and requests (with id for response correlation)TransportHandlewrapper inserver.rsnow delegatesregister_pending_request()to underlying transportTest Plan
cargo testpassescargo clippypassescargo fmtpassesRelated Issues
Closes #86, #87