Mcpblade
MCPBlade is a powerful aggregation and management service for Model Control Protocol (MCP) servers. It provides intelligent tool discovery, semantic search, and smart routing capabilities to seamlessly work with multiple MCP servers.
Installation
npx mcpbladeAsk AI about Mcpblade
Powered by Claude Β· Grounded in docs
I know everything about Mcpblade. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Reviews
Documentation
MCPBlade
MCPBlade is a powerful aggregation and management service for Model Control Protocol (MCP) servers. It provides intelligent tool discovery, semantic search, and smart routing capabilities to seamlessly work with multiple MCP servers.
Features
- Tool Aggregation: Combines tools from multiple MCP servers into a unified interface
- Semantic Search: Vector-based search to find tools using natural language queries
- Smart Routing: Automatically routes tool calls to the correct backend server
- Health Monitoring: Continuous health checks and heartbeat monitoring for all connected servers
- Persistent & Temporary Servers: Support for both persistent configuration-based and temporary runtime servers
- Multiple Transport Types: Support for stdio, SSE, and streamable HTTP transports for backend connections
- NATS Integration: Distributed service communication via NATS messaging with microservices support
- HTTP API: RESTful API and MCP-compatible streaming endpoints
- Middleware Architecture: Logging, proxy, and other middleware support
Architecture
MCPBlade consists of several key components:
- Core Service (
service.go): Main business logic and MCP server management - Vector Search (
vector/): Tool indexing and semantic search capabilities - Transport Layer:
transport/nats/: NATS-based communicationtransport/http/: HTTP API endpoints
- Persistence (
persistence/chromem/): Vector database implementation - MCP Integration (
mcp/): MCP protocol endpoint handlers - Proxy Layer (
proxy.go): Service proxy middleware for distributed deployments
Installation
go install github.com/flarexio/mcpblade/cmd/mcpblade@latest
go install github.com/flarexio/mcpblade/cmd/mcpblade_mcp_server@latest
Configuration
Create a configuration file config.yaml (see config.example.yaml for reference):
mcpServers:
time:
transport: stdio
command: uvx
args: [ "mcp-server-time", "--local-timezone=Asia/Taipei" ]
cacheRefreshTTL: 5m
vector:
enabled: true
persistent: true
collection: tools
Supported Transport Types
- stdio: Standard input/output communication with subprocess
- sse: Server-Sent Events over HTTP
- streamable-http: HTTP streaming protocol
Usage
Running the Core Service
# Run with default configuration path (~/.flarex/mcpblade)
mcpblade
# Run with custom configuration path
mcpblade --path /path/to/config
# Enable HTTP API
mcpblade --http --http-addr :8080
# Connect to custom NATS server
mcpblade --nats nats://localhost:4222
Running as MCP Server
# Connect to shared MCPBlade instance
mcpblade_mcp_server --edge-id your-edge-id
# Run dedicated server with specific MCP backend
mcpblade_mcp_server --edge-id your-edge-id --server-id my-server --cmd "uvx mcp-server-time"
# Connect to custom NATS server
mcpblade_mcp_server --edge-id your-edge-id --nats nats://localhost:4222
API Reference
Core Service Interface
The Service interface provides these methods:
- RegisterMCPServer: Add a new MCP server to the registry
- UnregisterMCPServer: Remove an MCP server from the registry
- ListTools: Get all available tools from registered servers
- SearchTools: Search for tools using semantic queries
- Forward: Route MCP requests to appropriate backend servers
- Close: Gracefully shutdown the service
HTTP API Endpoints
When HTTP transport is enabled:
# RESTful API
POST /api/mcp/register # Register MCP server
DELETE /api/mcp/unregister/:id # Unregister MCP server
GET /api/mcp/tools # List all tools
GET /api/mcp/tools/search # Search tools
POST /api/mcp/forward # Forward tool calls
# MCP Protocol
POST /mcp/ # MCP JSON-RPC endpoint
Example Tool Search
// Semantic search for tools
tools, err := service.SearchTools(ctx, "what's the current time?", 5)
if err != nil {
return err
}
for _, tool := range tools {
fmt.Printf("Tool: %s - %s\n", tool.Name, tool.Description)
}
Example Tool Call
req := mcp.CallToolRequest{
Request: mcp.Request{Method: "tools/call"},
Params: mcp.CallToolParams{
Name: "get_current_time",
Arguments: map[string]any{
"timezone": "Asia/Taipei",
},
},
}
result, err := service.Forward(ctx, req)
if err != nil {
return err
}
// Handle result
if !result.IsError {
for _, content := range result.Content {
fmt.Printf("Result: %v\n", content)
}
}
Transport Architecture
[MCP Clients]
β (stdio/nats/http)
[MCPBlade Proxy/Service]
β (stdio/sse/streamable-http)
[Backend MCP Servers]
Flow Description
-
Inbound: Clients connect to MCPBlade via:
- stdio: Native MCP protocol (via
mcpblade_mcp_server) - nats: Distributed messaging (via
transport/nats/) - http: RESTful API and MCP streaming (via
transport/http/)
- stdio: Native MCP protocol (via
-
Processing: MCPBlade aggregates, searches, and routes requests using:
- Tool caching and deduplication
- Vector-based semantic search
- Health monitoring and heartbeat tracking
-
Outbound: MCPBlade connects to backend servers as an MCP client via:
- stdio: Subprocess communication
- sse: Server-Sent Events
- streamable-http: HTTP streaming
Vector Search
Tools are automatically indexed in a vector database for intelligent search:
// Search finds tools using semantic similarity
tools, err := service.SearchTools(ctx, "time and date functions", 10)
// Tools are indexed with metadata including:
// - Server ID
// - Tool name and description
// - Input schema
// - Full tool JSON for reconstruction
The vector implementation uses ChromeDB with support for:
- In-memory collections for development
- Persistent storage for production
- Automatic embedding generation
- Similarity search with configurable result limits
Health Monitoring
The service continuously monitors the health of all registered MCP servers:
- Periodic Health Checks: Configurable TTL-based monitoring
- Heartbeat Tracking: Atomic timestamp tracking for each server
- Automatic Recovery: Failed servers can be automatically restarted
- Cache Refresh: Tool cache is refreshed based on health status
- Graceful Degradation: Failed servers are excluded from routing
Middleware System
MCPBlade uses a middleware architecture for cross-cutting concerns:
Logging Middleware
svc = mcpblade.LoggingMiddleware(logger)(svc)
Provides structured logging with Zap for all service operations.
Proxy Middleware
svc = mcpblade.ProxyMiddleware(endpoints)(svc)
Enables distributed deployments by proxying calls through NATS endpoints.
Development
Running Tests
# Run all tests
go test ./...
# Run with race detection
go test -race ./...
# Run specific test suite
go test ./service_test.go
Project Structure
βββ cmd/
β βββ mcpblade/ # Main service executable
β βββ mcpblade_mcp_server/ # MCP server implementation
βββ transport/
β βββ nats/ # NATS transport layer
β β βββ transport.go # NATS handlers
β β βββ factory.go # NATS client endpoints
β β βββ topic.go # NATS topic routing
β βββ http/ # HTTP transport layer
β βββ transport.go # HTTP handlers
β βββ mcp.go # MCP streaming endpoints
β βββ router.go # Route configuration
βββ persistence/chromem/ # ChromeDB vector database
βββ vector/ # Vector database interfaces
βββ mcp/ # MCP protocol handlers
β βββ endpoint.go # MCP endpoint implementations
β βββ endpoint_test.go # MCP protocol tests
βββ service.go # Core service implementation
βββ service_test.go # Service integration tests
βββ model.go # Data models and types
βββ model_test.go # Model serialization tests
βββ endpoint.go # Go-kit endpoints
βββ proxy.go # Proxy middleware
βββ logging.go # Logging middleware
βββ config.example.yaml # Example configuration
Dependencies
- mcp-go: MCP protocol implementation
- chromem-go: Vector database
- nats.go: NATS messaging with microservices
- go-kit: Microservice toolkit for endpoints
- gin: HTTP web framework
- zap: Structured logging
- cli/v3: Command-line interface
License
MIT License - see LICENSE.md for details.
This project is part of the FlareX ecosystem.
Contributing
Contributions are welcome! Please ensure:
- All tests pass:
go test ./... - Code follows Go conventions
- New features include tests
- Documentation is updated
- Commit messages are descriptive
For major changes, please open an issue first to discuss the proposed changes.
