使用说明
MCP代理
具有RAG、多Agent编排和MCP集成的生产级AI Agent系统。
快速开始
1.设置
# Create virtual environment
python -m venv venv
venv\Scripts\activate # Windows
# source venv/bin/activate # Linux/Mac
# Install dependencies
pip install -r requirements.txt
# Create .env file
cp .env.example .env
# Edit .env and add your API keys
2.跑步
# Start the API server
python -m uvicorn src.api.main:app --host 0.0.0.0 --port 8000 --reload
# Or use Docker
docker-compose up -d
3.测试
# Health check
curl http://localhost:8000/health
# API docs
# Open: http://localhost:8000/docs
特性
- ✅ RAG系统 -ChromaDB的持久矢量存储
- ✅ 多Agent -专业代理(研究、编码、数据分析)
- ✅ MCP集成 -连接到MCP服务器以获取工具
- ✅ 快速API -可生产的REST API
- ✅ 数据库 -PostgreSQL/SQLite支持
- ✅ 缓存 -Redis性能
- ✅ 命令行界面 -丰富的命令行界面
API终点
GET /health-健康检查POST /api/v1/chat-与AI代理聊天GET /api/v1/sessions-列出会话
配置
选项1:使用Docker服务(推荐)
-
启动PostgreSQL和Redis:
start_services.bat # Or: docker-compose -f docker-compose.services.yml up -d -
创建
.env文件:# LLM Provider (Required) OPENAI_API_KEY=your-key-here # Database - Docker PostgreSQL DATABASE_URL=postgresql://mcpagent:mcpagent_password@localhost:5432/mcpagent # Redis - Docker Redis REDIS_URL=redis://localhost:6379/0 ENABLE_CACHE=true
选项2:仅SQLite(无Docker)
# LLM Provider
OPENAI_API_KEY=your-key-here
# Database - SQLite
DATABASE_URL=sqlite:///./data/mcpagent.db
# Redis - Disabled
ENABLE_CACHE=false
MCP集成
在中配置MCP服务器 config/mcp_servers.json:
[
{
"name": "math",
"url": "http://localhost:8001/api/mcp/math/mcp",
"enabled": true
}
]
项目结构
MCPAGENT/
├── src/
│ ├── api/ # FastAPI application
│ ├── core/ # Core logic (agents, RAG, MCP)
│ ├── infrastructure/ # Database, cache, LLM
│ ├── config/ # Configuration
│ └── utils/ # Utilities
├── config/ # Configuration files
├── requirements.txt # Dependencies
└── docker-compose.yml # Docker setup
许可证
麻省理工学院