| Crates.io | solidmcp |
| lib.rs | solidmcp |
| version | 0.5.0-alpha.3 |
| created_at | 2025-07-19 22:36:54.529689+00 |
| updated_at | 2025-08-01 13:50:21.077675+00 |
| description | A high-level Rust toolkit for building Model Context Protocol (MCP) servers with type safety and minimal boilerplate. Supports tools, resources, and prompts with automatic JSON schema generation. |
| homepage | https://github.com/jupitersoftco/solidmcp |
| repository | https://github.com/jupitersoftco/solidmcp |
| max_upload_size | |
| id | 1760583 |
| size | 1,469,780 |
A high-level Rust toolkit for building Model Context Protocol (MCP) servers with minimal boilerplate and maximum type safety.
Add SolidMCP to your Cargo.toml:
[dependencies]
solidmcp = { git = "https://github.com/jupitersoftco/solidmcp.git" }
anyhow = "1.0"
schemars = "0.8"
serde = { version = "1.0", features = ["derive"] }
tokio = { version = "1.0", features = ["full"] }
Create a simple MCP server:
use anyhow::Result;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use solidmcp::framework::McpServerBuilder;
use std::sync::Arc;
// Define your application context
#[derive(Debug)]
struct MyContext {
name: String,
}
// Define input/output schemas with automatic JSON schema generation
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
struct GreetInput {
name: String,
}
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
struct GreetOutput {
message: String,
}
#[tokio::main]
async fn main() -> Result<()> {
let context = MyContext { name: "MyApp".to_string() };
let mut server = McpServerBuilder::new(context, "my-mcp-server", "1.0.0")
.with_tool(
"greet",
"Greet someone by name",
|input: GreetInput, ctx: Arc<MyContext>, notify| async move {
notify.info(&format!("Greeting {}", input.name))?;
Ok(GreetOutput {
message: format!("Hello, {}! Welcome to {}", input.name, ctx.name),
})
},
)
.build()
.await?;
server.start(3000).await?;
Ok(())
}
That's it! Your MCP server is now running with:
SolidMCP features an intelligent transport system that automatically detects and negotiates capabilities:
Upgrade: websocket headers and establishes WebSocket connections// Server automatically detects client capabilities from headers:
// - Connection: upgrade + Upgrade: websocket → WebSocket transport
// - Accept: application/json → HTTP JSON-RPC transport
// - GET request → Transport capability discovery response
| Transport | Status | Description |
|---|---|---|
| WebSocket | ✅ Full Support | Real-time bidirectional communication |
| HTTP JSON-RPC | ✅ Full Support | Request/response with session management |
| Server-Sent Events | 🔮 Future Work | Streaming responses (architecture ready) |
| Custom Transports | 🔮 Planned | Plugin system for extensions |
For a comprehensive example demonstrating all MCP features (tools, resources, and prompts), see the toy notes server example. It shows how to build a complete note-taking MCP server with:
note:// URIsRun the example:
cd examples/toy
cargo run
Then connect with Claude Desktop or any MCP client at ws://localhost:3002/mcp or http://localhost:3002/mcp.
SolidMCP implements core MCP functionality with comprehensive transport support:
2025-03-26 and 2025-06-18tools/list, tools/call)resources/list, resources/read)prompts/list, prompts/get)notifications/cancelSolidMCP focuses on the server-side of MCP, providing everything needed to build robust MCP servers that work with existing MCP clients like Claude Desktop, with intelligent transport negotiation for optimal compatibility.
Expose your application data as MCP resources:
use async_trait::async_trait;
use solidmcp::framework::ResourceProvider;
use solidmcp::handler::{ResourceContent, ResourceInfo};
struct MyResourceProvider;
#[async_trait]
impl ResourceProvider<MyContext> for MyResourceProvider {
async fn list_resources(&self, context: Arc<MyContext>) -> Result<Vec<ResourceInfo>> {
Ok(vec![ResourceInfo {
uri: "data://example".to_string(),
name: "example".to_string(),
description: Some("Example resource".to_string()),
mime_type: Some("text/plain".to_string()),
}])
}
async fn read_resource(&self, uri: &str, context: Arc<MyContext>) -> Result<ResourceContent> {
Ok(ResourceContent {
uri: uri.to_string(),
mime_type: Some("text/plain".to_string()),
content: "Hello from resource!".to_string(),
})
}
}
// Add to your server
let server = McpServerBuilder::new(context, "my-server", "1.0.0")
.with_resource_provider(Box::new(MyResourceProvider))
.build()
.await?;
Provide dynamic templates for AI interactions:
use solidmcp::framework::PromptProvider;
use solidmcp::handler::{PromptContent, PromptInfo, PromptMessage};
struct MyPromptProvider;
#[async_trait]
impl PromptProvider<MyContext> for MyPromptProvider {
async fn list_prompts(&self, context: Arc<MyContext>) -> Result<Vec<PromptInfo>> {
// Return available prompts
}
async fn get_prompt(&self, name: &str, arguments: Option<Value>, context: Arc<MyContext>) -> Result<PromptContent> {
// Generate prompt content based on arguments
}
}
The framework supports various configuration options:
// Custom port
server.start(8080).await?;
// Environment variables
// PORT=8080 - Server port
// RUST_LOG=debug - Logging level
SolidMCP uses the latest stable versions of core dependencies for optimal performance and security:
All dependencies are regularly updated and tested for compatibility.
SolidMCP is built with a modular architecture featuring intelligent transport handling:
framework.rs) - High-level builder API for easy server creationhandler.rs) - Core traits for tools, resources, and promptsshared.rs) - MCP protocol implementation and message routingwebsocket.rs, http.rs) - WebSocket and HTTP server implementationstransport.rs) - Smart transport negotiation and discoverycore.rs) - Server lifecycle and connection managementThe library abstracts away the complexity of the MCP protocol while providing full access to all its features, with automatic transport detection ensuring compatibility across different MCP clients.
SolidMCP is a server-focused implementation. Some limitations to be aware of:
These limitations reflect our focus on providing an excellent server development experience. Client features and advanced capabilities are on the roadmap.
SolidMCP includes a comprehensive test suite with 99+ tests covering all functionality:
# Run all tests (99+ tests)
cargo test
# Run library tests specifically
cargo test --lib
# Run integration tests
cargo test --test "*integration*"
# Run with logging
RUST_LOG=debug cargo test
# Test transport capability detection
cargo test transport::tests
# Test HTTP functionality
cargo test http::tests
Test Coverage:
Contributions are welcome! Please see our Contributing Guidelines for details.
MIT