-
Notifications
You must be signed in to change notification settings - Fork 515
Feat/turbomcp #843
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Feat/turbomcp #843
Conversation
Resolves #750 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor queries on the implementation design, primarily around the use of Arc/implementing the turbo MCP client for a Mutex.
Other than that, you basically just need to make the CI pass and that's it.
Really appreciate the feedback @joshua-mo-143! The TurboMCP client has had the least attention of all the crates in the library. We've just implemented a comprehensive solution to address this exact concern and I'm shipping this now. SharedClient Pattern: Instead of requiring users to manually wrap clients in Arc<Mutex<>> // Before (what you saw in the PR):
let client = Arc::new(Mutex::new(turbomcp_client::Client::new(transport)));
// After (clean API):
let client = SharedClient::new(turbomcp_client::Client::new(transport));
let client_clone = client.clone(); // Easy sharing across tasks We've implemented this pattern for all major components:
Key benefits for Rig integration:
For this specific case: // Instead of Arc<dyn TurboMcpClient>, you can now use:
pub struct TurboMcpTool<C = SharedClient<StdioTransport>> {
definition: turbomcp_protocol::types::Tool,
client: C, // Generic over client type, defaults to SharedClient
}
// Or keep it simple with the shared wrapper:
pub struct TurboMcpTool {
definition: turbomcp_protocol::types::Tool,
client: SharedClient<impl Transport>, // Clean, clone-able, thread-safe
} This addresses both the Arc concern (no more exposed Arc types) and the generic request (you can make it generic over the client type while still having a sensible default). The design maintains strict MCP protocol compliance while providing the ergonomic async-friendly APIs that Rig needs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs CI to pass then we can merge this in
Sounds great! Clippy and fmt look good and all tests pass locally. I just need to kick off another CI pass. |
Looks like one more round of CI (you might need to use |
0ecf905
to
ef530a5
Compare
Seems like the rmcp dep bumped to 0.6.4 which adds these properties to the client info: icons: None,
title: None,
website_url: None, |
51a356a
to
c27f201
Compare
Appreciate your patience on this! We had a big release up coming so I paused the integration until we shipped! In any case, I rebased so it should be a clean FF, though I suspect you'll want to squash this for a nice clean commit history. |
Comparing the ergonomics, I hope this enables your users to ship mcp support without all the boilerplate! |
//! The server provides a `sum` tool that adds two numbers, along with | ||
//! sample resources demonstrating the MCP protocol capabilities. | ||
#![cfg(feature = "turbomcp")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This macro is not required because of requiring the example already have the turbomcp
feature
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one very final small change (edit: and a CI pass) then this can get merged
- Add turbomcp-client, turbomcp-protocol, turbomcp-transport, turbomcp-core v1.0.8 - Add turbomcp feature flag for optional TurboMCP integration - Add all-mcp feature flag combining rmcp and turbomcp features - Update Cargo.lock with new dependencies including OAuth 2.1 compliance libraries
- Add TurboMcpTool struct implementing ToolDyn trait for Rig integration - Add TurboMcpClient trait abstraction for transport-agnostic client access - Support TurboMCP v1.0.8 plugin system (retry, cache, metrics) - Implement automatic plugin middleware benefits (retry logic, caching, metrics) - Add comprehensive error handling and logging for tool calls - Support all MCP content types (text, image, resource, audio) - Add conversion traits from TurboMCP Tool to Rig ToolDefinition - Include comprehensive test suite for TurboMCP integration - Maintain API compatibility with existing RMCP integration patterns
- Add turbomcp_tool() method to AgentBuilder for seamless TurboMCP integration - Support adding TurboMCP tools with client abstraction for transport flexibility - Maintain consistent API with existing rmcp_tool() method - Enable agent to use TurboMCP tools with automatic plugin middleware benefits - Add proper feature gating and documentation attributes
- Add mcp_demo.rs: Side-by-side comparison of RMCP vs TurboMCP integration - Add turbomcp_simple_demo.rs: Basic TurboMCP integration with Rig - Add turbomcp_plugin_demo.rs: Advanced plugin system demonstration - Demonstrate identical API patterns between RMCP and TurboMCP - Showcase TurboMCP v1.0.8 features: plugin middleware, OAuth 2.1, enhanced APIs - Include transport flexibility examples (stdio, HTTP, WebSocket, TCP, Unix) - Provide comprehensive documentation and usage examples - Demonstrate automatic plugin benefits: retry logic, caching, metrics collection
update to turbomcp 1.1.0
c27f201
to
076715b
Compare
We are shipping 2.0 very soon, really appreciate your patience on this! The api has significantly improved and ossified. |
Add TurboMCP Support to Rig: Alternative MCP Implementation with Advanced Features
Summary
This PR adds TurboMCP as an alternative MCP implementation option in Rig, providing users with a choice between two high-quality MCP libraries. TurboMCP offers additional features like OAuth 2.1 compliance, enterprise plugins, and enhanced content type support while maintaining identical APIs to the existing RMCP integration.
Changes Made to Rig
New Feature Flag:
turbomcp
Users can now choose their preferred MCP implementation:
Code Changes
1.
rig-core/Cargo.toml
2.
rig-core/src/tool.rs
turbomcp
module alongside existingrmcp
moduleTurboMcpTool
struct with identical interface toMcpTool
3.
rig-core/src/agent/builder.rs
turbomcp_tool()
method with identical signature tormcp_tool()
4. Examples Added
mcp_demo.rs
: Shows both RMCP and TurboMCP side-by-sideturbomcp_simple_demo.rs
: Basic TurboMCP integrationturbomcp_plugin_demo.rs
: Demonstrates advanced plugin featuresAPI Compatibility
The integration maintains perfect API compatibility:
Both methods:
Feature Comparison in Rig
Implementation Benefits for Rig Users
Choice and Flexibility
Enhanced Capabilities (Optional)
Risk Mitigation
Backward Compatibility
Zero breaking changes:
Testing Strategy
Compilation Testing
Feature Isolation
turbomcp
feature is enabledCode Quality Standards
Consistency with Rig Patterns
Documentation
Why This Approach?
User-Centric Design
Instead of forcing users to one MCP implementation, Rig now:
Engineering Best Practices
Future Considerations
Monitoring Adoption
API Evolution
Breaking Changes
None. This is a purely additive change:
Files Changed
Core Integration
rig-core/Cargo.toml
- Added TurboMCP dependenciesrig-core/src/tool.rs
- Added TurboMCP modulerig-core/src/agent/builder.rs
- Added turbomcp_tool() methodExamples
rig-core/examples/mcp_demo.rs
- Enhanced to show both implementationsrig-core/examples/turbomcp_simple_demo.rs
- New basic demorig-core/examples/turbomcp_plugin_demo.rs
- New advanced demoChecklist