# 🦀 RustChain Community MCP Server Guide
## Overview
The RustChain Community MCP (Model Context Protocol) Server provides high-performance AI agent workflow execution with enterprise-grade security and compliance. Built in Rust for memory safety and blazing performance, it delivers 10-100x speed improvements over Python alternatives while maintaining full MCP compatibility.
## 🎯 Quick Start
### 1. Install RustChain
```bash
# Install from Cargo
cargo install rustchain-community
# Or build from source
git clone https://github.com/Michael-A-Kuykendall/rustchain-community.git
cd rustchain-community
cargo build --release --features="cli,llm,tools,rag"
```
### 2. Start the MCP Server
```bash
# Start integrated MCP server (default port 8080)
rustchain server start --mcp-port 8080
# Start with custom configuration
rustchain server start --config rustchain.toml --mcp-port 3000
# Development mode with hot reload
rustchain server dev --mcp-enabled
```
### 3. Verify Server Health
```bash
# Health check endpoint
curl http://localhost:8080/health
# Expected response:
{
"status": "healthy",
"server": "RustChain Community MCP",
"version": "0.1.0",
"endpoints": ["/mcp", "/health", "/missions", "/tools"],
"features": ["agent", "chain", "llm", "rag", "compliance"]
}
```
### 4. Test MCP Communication
```bash
# Basic ping test (JSON-RPC 2.0)
curl -X POST http://localhost:8080/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"ping","id":1}'
# Expected response:
{
"jsonrpc": "2.0",
"result": {
"status": "pong",
"server": "RustChain Community MCP",
"version": "0.1.0",
"performance": {
"avg_response_time_ms": 0.8,
"memory_usage_mb": 2.3
}
},
"id": 1
}
```
## 🔧 Server Configuration
### Basic Configuration (rustchain.toml)
```toml
[server]
host = "0.0.0.0"
port = 8080
mcp_enabled = true
max_connections = 1000
[security]
enable_audit = true
compliance_mode = "enterprise"
policy_enforcement = true
[performance]
worker_threads = 8
max_memory_mb = 512
request_timeout_ms = 30000
[features]
llm_providers = ["openai", "anthropic", "ollama"]
vector_stores = ["qdrant", "pinecone"]
tool_sandboxing = true
```
### MCP-Specific Settings
```toml
[mcp]
port = 8080
max_request_size_mb = 10
enable_streaming = true
cors_enabled = true
rate_limit_requests_per_minute = 1000
[mcp.methods]
# Core MCP methods
ping = true
tools_list = true
tools_call = true
resources_list = true
resources_read = true
# RustChain-specific methods
mission_execute = true
agent_chat = true
chain_run = true
transpile = true
```
## 🛡️ Enterprise Security Features
### Memory-Safe Architecture
RustChain's Rust foundation provides:
- **Zero Buffer Overflows**: Compile-time memory safety
- **No Use-After-Free**: Ownership model prevents dangling pointers
- **Thread Safety**: Fearless concurrency without data races
- **Resource Management**: Automatic cleanup prevents memory leaks
### Policy Enforcement
```bash
# Create security policy
cat > security-policy.yaml << EOF
version: "1.0"
name: "enterprise_security_policy"
rules:
- action: "file_access"
allow_paths: ["/workspace", "/tmp"]
deny_patterns: ["*.env", "*.key", "*/secrets/*"]
- action: "network_access"
allow_domains: ["api.openai.com", "*.anthropic.com"]
deny_protocols: ["ftp", "telnet"]
- action: "command_execution"
allow_commands: ["git", "npm", "cargo"]
sandbox_mode: true
EOF
# Apply policy
rustchain policy apply security-policy.yaml
```
### Audit Trail System
```bash
# Enable comprehensive auditing
rustchain audit configure \
--format json \
--output /var/log/rustchain/audit.log \
--include-requests \
--include-responses \
--compliance-mode sox
# Query audit logs
rustchain audit query \
--from "2024-01-01" \
--to "2024-01-31" \
--user-id "enterprise-user" \
--output audit-report.json
```
## 🤖 MCP Method Reference
### Core MCP Methods
| `ping` | Health check and performance metrics | None | Server status, performance data |
| `tools/list` | List available RustChain tools | None | Tool registry with metadata |
| `tools/call` | Execute tool with parameters | `name`, `arguments` | Tool execution results |
| `resources/list` | List available resources | None | Resource inventory |
| `resources/read` | Read resource content | `uri` | Resource data |
### RustChain-Specific Methods
| `mission/execute` | Run YAML mission workflows | `mission_yaml`, `variables` | Execution results, outputs |
| `agent/chat` | Multi-agent conversation | `message`, `agent_config` | Agent response, reasoning |
| `chain/run` | Execute workflow chains | `chain_config`, `inputs` | Chain outputs, metrics |
| `transpile` | Convert between formats | `source_format`, `target_format`, `content` | Transpiled content |
| `compliance/validate` | Check regulatory compliance | `mission`, `standards` | Validation report |
### Tool Execution Example
```bash
curl -X POST http://localhost:8080/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "file_create",
"arguments": {
"path": "/workspace/hello.txt",
"content": "Hello from RustChain MCP!",
"permissions": "644"
}
},
"id": 1
}'
# Response:
{
"jsonrpc": "2.0",
"result": {
"success": true,
"file_path": "/workspace/hello.txt",
"bytes_written": 26,
"execution_time_ms": 0.3
},
"id": 1
}
```
### Mission Execution Example
```bash
curl -X POST http://localhost:8080/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "mission/execute",
"params": {
"mission_yaml": "version: '\''1.0'\''\nname: hello_world\nsteps:\n - id: greeting\n step_type: command\n parameters:\n command: echo '\''Hello MCP!'\''",
"variables": {}
},
"id": 1
}'
# Response:
{
"jsonrpc": "2.0",
"result": {
"mission_id": "hello_world",
"status": "completed",
"execution_time_ms": 12,
"steps_completed": 1,
"outputs": {
"greeting": "Hello MCP!\n"
}
},
"id": 1
}
```
## 🚀 Performance Monitoring
### Real-Time Metrics
```bash
# Get performance metrics
curl http://localhost:8080/metrics
# Response includes:
{
"server_uptime_seconds": 3600,
"requests_total": 15420,
"requests_per_second": 4.28,
"avg_response_time_ms": 0.8,
"memory_usage": {
"total_mb": 2.3,
"heap_mb": 1.1,
"stack_mb": 0.2
},
"missions_executed": 1200,
"tools_called": 8400,
"active_connections": 45
}
```
### Benchmark Comparison
```bash
# Run performance benchmark
rustchain benchmark run \
--duration 60s \
--concurrent-requests 100 \
--include-competitors
# Sample results:
RustChain MCP | 12,450 | 0.8ms | 2.3 | 0.0%
LangChain (Python) | 245 | 15.2ms | 48.7 | 2.1%
AutoGen (Python) | 180 | 22.1ms | 65.3 | 3.4%
CrewAI (Python) | 156 | 28.4ms | 72.1 | 4.2%
```
## 🔄 Integration Examples
### Claude Desktop Configuration
```json
{
"mcpServers": {
"rustchain-community": {
"command": "rustchain",
"args": ["server", "mcp", "--port", "8080"],
"env": {
"RUST_LOG": "info",
"RUSTCHAIN_CONFIG": "~/.config/rustchain/config.toml"
}
}
}
}
```
### VS Code Extension Integration
```json
{
"rustchain.mcp": {
"enabled": true,
"serverUrl": "http://localhost:8080",
"autoStart": true,
"features": {
"missionExecution": true,
"agentChat": true,
"transpilation": true,
"compliance": true
}
}
}
```
### Custom Client (Node.js)
```javascript
import WebSocket from 'ws';
class RustChainMCPClient {
constructor(url = 'ws://localhost:8080/mcp-ws') {
this.ws = new WebSocket(url);
this.requestId = 0;
}
async executeMission(missionYaml, variables = {}) {
const request = {
jsonrpc: '2.0',
method: 'mission/execute',
params: { mission_yaml: missionYaml, variables },
id: ++this.requestId
};
return this.sendRequest(request);
}
async callTool(name, arguments) {
const request = {
jsonrpc: '2.0',
method: 'tools/call',
params: { name, arguments },
id: ++this.requestId
};
return this.sendRequest(request);
}
sendRequest(request) {
return new Promise((resolve, reject) => {
const timeout = setTimeout(() => {
reject(new Error('Request timeout'));
}, 30000);
const handler = (data) => {
const response = JSON.parse(data);
if (response.id === request.id) {
clearTimeout(timeout);
this.ws.off('message', handler);
if (response.error) {
reject(new Error(response.error.message));
} else {
resolve(response.result);
}
}
};
this.ws.on('message', handler);
this.ws.send(JSON.stringify(request));
});
}
}
// Usage example
const client = new RustChainMCPClient();
const result = await client.executeMission(`
version: '1.0'
name: data_analysis
steps:
- id: fetch_data
step_type: http
parameters:
url: https://api.example.com/data
method: GET
- id: analyze
step_type: agent
parameters:
objective: "Analyze the fetched data"
model: "gpt-4"
depends_on: [fetch_data]
`);
console.log('Mission result:', result);
```
## 🔍 Troubleshooting
### Server Won't Start
```bash
# Check if port is in use
netstat -tulpn | grep 8080
# Check configuration
rustchain config validate
# Start with verbose logging
RUST_LOG=debug rustchain server start
```
### Performance Issues
```bash
# Check system resources
rustchain diagnostics system
# Monitor memory usage
rustchain diagnostics memory --watch
# Profile performance
rustchain benchmark profile --duration 30s
```
### Connection Issues
```bash
# Test local connectivity
curl -f http://localhost:8080/health
# Check firewall settings
sudo ufw status
# Verify MCP endpoint
curl -X POST http://localhost:8080/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"ping","id":1}' \
-v
```
## 📊 Advanced Features
### Multi-Model Support
```bash
# Configure multiple LLM providers
rustchain config llm add openai --api-key $OPENAI_API_KEY
rustchain config llm add anthropic --api-key $ANTHROPIC_API_KEY
rustchain config llm add ollama --base-url http://localhost:11434
# Use specific model in mission
cat > multi-model-mission.yaml << EOF
version: '1.0'
name: multi_model_analysis
steps:
- id: gpt_analysis
step_type: llm
parameters:
provider: openai
model: gpt-4
prompt: "Analyze this data: {{data}}"
- id: claude_review
step_type: llm
parameters:
provider: anthropic
model: claude-3-sonnet
prompt: "Review this analysis: {{gpt_analysis.output}}"
EOF
```
### Vector Database Integration
```bash
# Setup vector store
rustchain rag configure \
--provider qdrant \
--url http://localhost:6333 \
--collection rustchain-docs
# Add documents to vector store
curl -X POST http://localhost:8080/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "rag_add",
"arguments": {
"collection": "rustchain-docs",
"documents": [
{
"id": "readme",
"content": "RustChain Community documentation...",
"metadata": {"type": "documentation", "version": "0.1.0"}
}
]
}
},
"id": 1
}'
```
### Enterprise Compliance
```bash
# Generate compliance report
rustchain compliance report \
--standards sox,gdpr,hipaa \
--output compliance-report.pdf \
--include-recommendations
# Validate mission against policies
curl -X POST http://localhost:8080/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "compliance/validate",
"params": {
"mission": "mission-config.yaml",
"standards": ["sox", "gdpr"],
"strict_mode": true
},
"id": 1
}'
```
## 🌟 Community and Support
### Documentation Resources
- **[GitHub Repository](https://github.com/Michael-A-Kuykendall/rustchain-community)** - Source code and issues
- **[Wiki Documentation](https://github.com/Michael-A-Kuykendall/rustchain-community/wiki)** - Comprehensive guides
- **[API Reference](https://docs.rs/rustchain-community)** - Rust API documentation
- **[Examples](https://github.com/Michael-A-Kuykendall/rustchain-community/tree/main/examples)** - Code samples and tutorials
### Community Channels
- **GitHub Discussions** - Technical questions and feature requests
- **Discord Server** - Real-time community support
- **Matrix Channel** - Decentralized communication
### Contributing
- **Code Contributions** - Follow the [Contributing Guide](CONTRIBUTING.md)
- **Documentation** - Help improve guides and examples
- **Bug Reports** - Use GitHub Issues with detailed information
- **Feature Requests** - Discuss in GitHub Discussions first
---
**🦀 Built with Rust for Performance, Security, and Reliability**
**📚 Related Documentation:**
- [Installation Guide](installation.md) - Setup and configuration
- [Quick Start Guide](quickstart.md) - Getting started tutorial
- [API Reference](api-reference.md) - Complete API documentation
- [Architecture Overview](../README.md) - System design and internals