MCP server by lll82012
🦀 RustAgent MCP Enterprise
Production-grade AI super-agent platform built entirely in Rust.
RustAgent MCP Enterprise integrates multi-agent orchestration, RAG (Retrieval-Augmented Generation), and the MCP (Model Context Protocol) into a single, high-performance platform. It enables enterprises to build AI applications with private knowledge bases and standardized tool integration — all without a single line of Python.
✨ Features
- 🚀 Pure Rust — Zero Python/Java dependencies, maximum performance and memory safety
- 🧠 Multi-Agent Orchestration — Planner → Retriever → Executor → Summarizer pipeline
- 📚 Enterprise RAG — Hybrid search (vector + keyword), semantic chunking, citation tracking
- 🔌 MCP Protocol — JSON-RPC 2.0 based tool integration, discoverable and extensible
- 🔒 JWT Authentication — Secure API access with Argon2 password hashing
- 📡 SSE Streaming — Real-time response streaming for chat
- ⚖️ Rate Limiting — Built-in request throttling
- 📊 Observability — Structured logging with tracing, health checks
- 🐳 Docker Ready — One-command deployment with Docker Compose
- 🗄️ PostgreSQL + Qdrant — Reliable persistence and vector search
🏗️ Architecture
┌─────────────┐ ┌──────────────────────────────────┐
│ Client │────▶│ Web Server (Axum) │
└─────────────┘ └──────────────┬───────────────────┘
│
┌──────────────┬───────────┼───────────┬──────────────┐
│ │ │ │ │
┌────▼────┐ ┌─────▼────┐ ┌───▼────┐ ┌───▼─────┐ ┌─────▼────┐
│ Agent │ │ RAG │ │ MCP │ │ LLM │ │ Common │
│ Core │ │ Service │ │Protocol│ │ Client │ │ (shared)│
└────┬────┘ └─────┬────┘ └───┬────┘ └───┬─────┘ └──────────┘
│ │ │ │
│ ┌────▼────┐ │ ┌────▼────┐
│ │ Qdrant │ │ │ OpenAI │
│ │ (Vector)│ │ │ (LLM) │
│ └─────────┘ │ └─────────┘
│ │
└──────────┬───────────────┘
│
┌────▼────┐
│PostgreSQL│
└─────────┘
🚀 Quick Start
Prerequisites
- Rust 1.80+
- Docker & Docker Compose (for full deployment)
- OpenAI API Key (or compatible endpoint)
Local Development (without Docker)
# 1. Clone the repository
git clone https://github.com/yourusername/rustagent-mcp-enterprise.git
cd rustagent-mcp-enterprise
# 2. Set up environment
cp .env.example .env
# Edit .env with your API key
# 3. Start required services (PostgreSQL + Qdrant)
docker-compose up -d postgres qdrant
# 4. Build and run
export RUSTAGENT__LLM__API_KEY="sk-your-key-here"
cargo run --release
# The server starts at http://localhost:8080
Docker Deployment (Recommended)
# 1. Clone and configure
git clone https://github.com/yourusername/rustagent-mcp-enterprise.git
cd rustagent-mcp-enterprise
# 2. Set your API key
export LLM_API_KEY="sk-your-openai-api-key"
export JWT_SECRET="$(openssl rand -hex 32)"
# 3. Start everything with Docker Compose
docker-compose up -d
# 4. Verify
curl http://localhost:8080/api/health
📡 API Reference
Authentication
# Login
curl -X POST http://localhost:8080/api/auth/login \
-H "Content-Type: application/json" \
-d '{"username": "admin", "password": "admin"}'
# Response: { "token": "eyJ...", "token_type": "Bearer", ... }
Chat
# Non-streaming chat
curl -X POST http://localhost:8080/api/chat \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"message": "Tell me about Rust", "enable_rag": false}'
# Streaming chat (SSE)
curl -X POST http://localhost:8080/api/chat/stream \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"message": "Write a function", "stream": true}'
Knowledge Base (RAG)
# Upload a document
curl -X POST http://localhost:8080/api/knowledge/documents \
-H "Authorization: Bearer $TOKEN" \
-F "file=@document.pdf"
# Search the knowledge base
curl -X POST http://localhost:8080/api/knowledge/search \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"query": "important policy", "top_k": 3}'
MCP Tools
# List available tools
curl http://localhost:8080/api/tools \
-H "Authorization: Bearer $TOKEN"
# Execute a tool (e.g., echo)
curl -X POST http://localhost:8080/api/tools/echo \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"message": "Hello from MCP!"}'
# MCP JSON-RPC endpoint
curl -X POST http://localhost:8080/api/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"tools/list","id":"1"}'
Health Check
curl http://localhost:8080/api/health
# Response: { "status": "healthy", "version": "0.1.0", ... }
📁 Project Structure
rustagent-mcp-enterprise/
├── crates/
│ ├── common/ # Shared types, errors, configuration
│ ├── llm-client/ # OpenAI-compatible LLM client
│ ├── mcp-protocol/ # MCP JSON-RPC 2.0 implementation
│ ├── rag-service/ # RAG: chunking, embedding, retrieval
│ ├── agent-core/ # Multi-agent orchestration engine
│ └── web-server/ # Axum REST API server
├── config/ # Environment configuration files
├── docker/ # Docker build files
├── migrations/ # Database migration scripts
├── src/ # Main binary entry point
├── tests/ # Integration tests
├── docker-compose.yml # Multi-service orchestration
├── Cargo.toml # Workspace manifest
└── README.md
🔧 Configuration
Configuration is loaded in this order (latter overrides former):
config/default.toml— Base defaultsconfig/{RUN_MODE}.toml— Environment-specific- Environment variables prefixed with
RUSTAGENT__
Example environment variable overrides:
export RUSTAGENT__SERVER__PORT=9090
export RUSTAGENT__LLM__MODEL="gpt-4o-mini"
export RUSTAGENT__RAG__TOP_K=10
🧪 Running Tests
# Run all tests
cargo test --workspace
# Run specific crate tests
cargo test -p agent-core
cargo test -p rag-service
# Run with logging
RUST_LOG=debug cargo test -- --nocapture
📦 Building for Production
# Optimized release build
cargo build --release
# The binary will be at:
./target/release/rustagent-mcp-enterprise
🛠️ Tech Stack
| Component | Technology | |-----------|-----------| | Runtime | Tokio 1.40+ | | Web Framework | Axum 0.7+ | | LLM Client | async-openai 0.21+ | | Vector DB | Qdrant | | Database | PostgreSQL 16 + SQLx | | Auth | JWT + Argon2 | | Logging | tracing | | Config | config-rs | | Deployment | Docker + Docker Compose |
📄 License
MIT License — see LICENSE for details.
🤝 Contributing
Contributions are welcome! Please open an issue or submit a pull request.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Built with 🦀 in Rust — because AI deserves type safety too.