sovran_mcp
A synchronous Rust client for the Model Context Protocol (MCP).
Overview
sovran-mcp provides a clean, synchronous interface for interacting with MCP servers. It handles:
- Tool execution and discovery
- Prompt management
- Resource handling and subscriptions
- Server capability detection
Usage
Add to your Cargo.toml:
[]
= "0.3.1"
Basic example:
use ;
Features
Tool Operations
- List available tools
- Execute tools with arguments
- Handle tool responses (text, images, resources)
Prompt Management
- List available prompts
- Retrieve prompts with arguments
- Handle multi-part prompt messages
Resource Handling
- List available resources
- Read resource contents
- Subscribe to resource changes
- Handle resource update notifications
Server Capabilities
- Protocol version detection
- Feature availability checking
- Experimental feature support
Handler Support
Sampling Handler
Support for server-initiated LLM completions:
use *;
;
Notification Handler
Support for resource update notifications:
use *;
use Url;
;
Error Handling
The crate uses McpError for comprehensive error handling, covering:
- Transport errors (I/O, connection issues)
- Protocol errors (JSON-RPC, serialization)
- Capability errors (unsupported features)
- Request timeouts
- Command failures
License
MIT License
Contributing
Contributions welcome! Please feel free to submit a Pull Request.