allframe-mcp
MCP (Model Context Protocol) Server for AllFrame
Expose your AllFrame APIs as LLM-callable tools using the Model Context Protocol.
What is MCP?
The Model Context Protocol (MCP) is an open standard by Anthropic that enables AI assistants like Claude to safely interact with external data sources and tools. allframe-mcp automatically converts your AllFrame router handlers into MCP tools that LLMs can discover and call.
Features
- Automatic Tool Discovery - Handlers become callable tools automatically
- Type-Safe Integration - Leverages AllFrame's router architecture
- Zero Configuration - Works out of the box with any AllFrame router
- Flexible Deployment - Library-first design for maximum flexibility
- OpenAPI Integration - Converts OpenAPI schemas to JSON Schema for tools
Installation
Add to your Cargo.toml:
[]
= "0.1"
= "0.1"
= { = "1.48", = ["full"] }
Quick Start with Claude Desktop
Follow these steps to create an MCP server that Claude Desktop can use:
Step 1: Create a new project
Step 2: Add dependencies to Cargo.toml
[]
= "my-mcp-server"
= "0.1.0"
= "2021"
[]
= "0.1"
= "0.1"
= { = "1.48", = ["full"] }
= "1.0"
Step 3: Create your MCP server (src/main.rs)
use Router;
use ;
async
Step 4: Build the server
Step 5: Configure Claude Desktop
Edit ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
Step 6: Restart Claude Desktop
Quit and reopen Claude Desktop. Your tools will now be available!
Quick Start with Claude Code (CLI)
Claude Code uses a different configuration system than Claude Desktop. Follow these steps:
Step 1: Build your MCP server
# From your project directory
# Note the full path to your binary:
# /path/to/your/project/target/release/my-mcp-server
Step 2: Add to .mcp.json in your project root
Create or edit .mcp.json in your project directory:
Important: Use the absolute path to your compiled binary.
Step 3: Enable the server in Claude Code settings
Edit .claude/settings.local.json in your project directory:
Or if you have existing servers, add to the array:
Step 4: Restart Claude Code
Run /mcp in Claude Code to reconnect, or restart Claude Code entirely. Your tools will now be available.
Using the AllFrame Example Server
To use the built-in example server from the AllFrame repository:
# Clone and build
# The binary is at:
# ./target/release/examples/mcp_stdio_server
Then configure .mcp.json:
And .claude/settings.local.json:
Troubleshooting Claude Code
If the MCP server fails to connect:
-
Check the binary exists and is executable:
-
Test the server manually:
| \ -
Check for debug output (if
ALLFRAME_MCP_DEBUG=1):- Look in the Claude Code output panel
- Or set
ALLFRAME_MCP_LOG_FILEto log to a file
-
Verify configuration files exist:
-
Run
/mcpin Claude Code to see server status and reconnect
Debugging
Environment Variables
Enable debug logging with environment variables in your Claude Desktop config:
| Variable | Description |
|---|---|
ALLFRAME_MCP_DEBUG |
Enable debug output to stderr |
ALLFRAME_MCP_LOG_FILE |
Write logs to a file instead of stderr |
RUST_LOG |
Set log level when using the tracing feature (e.g., debug, info) |
Built-in Debug Tool
Enable the allframe/debug tool to get server diagnostics from Claude:
let config = default
.with_debug_tool;
When enabled, Claude can call allframe/debug to get:
- Server name and version
- Uptime and request count
- Tool count and PID
- Build information
Testing Manually
Test your MCP server from the command line:
# Test initialize
| \
# Test tools/list
| \
# Test a tool call
| \
Tracing Feature
For structured logging with tracing, build with the tracing feature:
[]
= { = "0.1", = ["tracing"] }
Then set RUST_LOG for log level control:
RUST_LOG=debug ALLFRAME_MCP_LOG_FILE=/tmp/mcp.log
Programmatic Usage
use Router;
use McpServer;
async
Usage Patterns
Pattern 1: Standalone MCP Server
Create a dedicated MCP server binary:
// src/main.rs
use Router;
use McpServer;
use ;
async
async
Configure in Claude Desktop (~/Library/Application Support/Claude/claude_desktop_config.json):
Pattern 2: Embedded in Web Application
Integrate MCP into an existing Axum web server:
use ;
use Router;
use McpServer;
use Arc;
async
async
async
Pattern 3: Serverless Deployment (AWS Lambda)
Deploy MCP server as a serverless function:
use ;
use Value;
use Router;
use McpServer;
use Arc;
async
async
API Overview
McpServer
The main MCP server struct that wraps an AllFrame Router.
StdioTransport
Production-ready stdio transport with debugging support.
StdioConfig
Configuration for the stdio transport.
McpTool
Represents a single MCP tool (derived from a router handler).
Schema Utilities
Convert between OpenAPI and JSON Schema formats:
/// Convert OpenAPI schema to JSON Schema
;
/// Validate input against a JSON schema
;
/// Coerce input to match expected type
;
/// Extract enum values from schema
;
Examples
See the examples/ directory for complete working examples:
mcp_server.rs- Basic MCP server setupmcp_stdio_server.rs- Full stdio transport implementation
Run an example:
Testing
All MCP functionality is fully tested:
# Run all tests
# Run with output
# Test specific module
Current test coverage: 33 tests passing
Architecture
Zero-Bloat Design
allframe-mcp is a separate crate from allframe-core, ensuring:
- Opt-in only: MCP code is never compiled unless you add it as a dependency
- No feature flags: Clean separation, no conditional compilation
- Zero overhead: Applications without MCP pay zero cost
How It Works
- Tool Discovery:
McpServerscans theRouterfor registered handlers - Schema Generation: Each handler becomes an
McpToolwith JSON Schema - Tool Execution: Calls are routed through the AllFrame router
- Response Mapping: Router responses are converted to MCP format
┌─────────────┐
│ LLM │ (Claude, GPT-4, etc.)
└──────┬──────┘
│ MCP Protocol
┌──────▼──────┐
│ McpServer │ (allframe-mcp)
└──────┬──────┘
│ Router API
┌──────▼──────┐
│ Router │ (allframe-core)
└──────┬──────┘
│
┌──────▼──────┐
│ Handlers │ (Your business logic)
└─────────────┘
Deployment Options
Docker
FROM rust:1.86 as builder
WORKDIR /app
COPY . .
RUN cargo build --release --bin my-mcp-server
FROM debian:bookworm-slim
COPY --from=builder /app/target/release/my-mcp-server /usr/local/bin/
CMD ["my-mcp-server"]
Kubernetes
apiVersion: apps/v1
kind: Deployment
metadata:
name: mcp-server
spec:
replicas: 3
template:
spec:
containers:
- name: mcp-server
image: my-mcp-server:latest
ports:
- containerPort: 3000
Fly.io
# fly.toml
= "my-mcp-server"
[]
= "paketobuildpacks/builder:base"
[[]]
= 3000
= "tcp"
Performance
MCP overhead is minimal:
- Tool Discovery: O(n) where n = number of handlers (one-time on startup)
- Tool Execution: Direct router call (no additional overhead)
- Memory: ~100 bytes per tool for metadata
Benchmark results (on MacBook Pro M1):
tool_discovery ... 1.2µs per handler
tool_call ... 45µs per call (includes router overhead)
list_tools ... 3.5µs (cached)
Roadmap
Phase 1 (Current)
- ✅ Basic MCP server implementation
- ✅ Tool discovery from router
- ✅ Simple tool execution
- ✅ Schema conversion utilities
Phase 2 (Planned)
- Advanced argument mapping (nested objects, arrays)
- Tool metadata from handler annotations
- Streaming responses for long-running operations
- Rate limiting and authentication
Phase 3 (Future)
- MCP resources (file/data access)
- MCP prompts (templated interactions)
- Tool composition (multi-step workflows)
- OpenAPI schema auto-import
Contributing
Contributions welcome! Please read CONTRIBUTING.md first.
Key areas for contribution:
- Additional transport implementations (HTTP, WebSocket)
- More comprehensive schema validation
- Performance optimizations
- Documentation improvements
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT license (LICENSE-MIT)
at your option.
Resources
- Documentation: https://docs.rs/allframe-mcp
- AllFrame Core: https://docs.rs/allframe-core
- MCP Specification: https://modelcontextprotocol.io
- Examples: ./examples/
- Issues: https://github.com/all-source-os/all-frame/issues
Acknowledgments
Built on top of:
- AllFrame - Protocol-agnostic Rust web framework
- Model Context Protocol - By Anthropic
- Tokio - Async runtime for Rust
Made with ❤️ by the AllFrame team