Token导航 LogoToken导航TokenDH.com
RAG MCP agentAPI logo
开发工具stdio官方级别未说明来源级核验

RAG MCP agentAPI

MCP Server

一个集成RAG(检索增强生成)和MCP(多工具协作平台)工具的系统,提供文档检索、速率限制和多工具协作功能,适用于开发运维和自动化测试场景。

工具数

3

提示词数

0

GitHub Stars

0

资源数

0
检索增强生成Python开发工具

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

N3xou

提供方

N3xou

最后核验

2026/5/17 20:22

运行时

Docker

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

docker run -d -p 6379:6379 --name devops-redis redis:7-alpine

详细介绍

设置和运行说明-实验7

快速参考

开始一切

docker run -d -p 6379:6379 --name devops-redis redis:7-alpine
python mcp_server.py  # Terminal 1
python agent_api.py   # Terminal 2

测试一切

curl http://localhost:8000/health
curl -X POST "http://localhost:8000/rag/ingest?directory=data/docs"
python test_mcp_tools.py
k6 run k6/load_test.js

停止一切

# Press Ctrl+C in both terminals
docker stop devops-redis

先决条件

pip install fastapi uvicorn chromadb pydantic groq python-dotenv langgraph langchain-core redis requests

附加要求:

  • Docker(适用于Redis)
  • k6(用于负载测试)

______________________________________________________________________

步骤0:启动Redis

docker run -d -p 6379:6379 --name devops-redis redis:7-alpine

验证Redis:

docker exec -it devops-redis redis-cli ping
# Expected: PONG

______________________________________________________________________

步骤1:配置环境

创建 .env 文件:

GROQ_API_KEY=gsk_your_key_here
REDIS_URL=redis://localhost:6379
BASIC_RPM=10
PRO_RPM=60
VIP_RPM=300

______________________________________________________________________

步骤2:启动MCP服务器(终端1)

python mcp_server.py

预期产量:

✓ Database initialized
✓ Sample server data seeded
✓ MCP Server started

______________________________________________________________________

步骤3:启动代理API(终端2)

python agent_api.py

预期产量:

✓ Connected to Redis at redis://localhost:6379
✓ Groq LLM configured
✓ LangGraph workflow initialized
✓ MCP client connected to server
INFO:     Uvicorn running on http://0.0.0.0:8000

______________________________________________________________________

第4步:摄取文件

curl -X POST "http://localhost:8000/rag/ingest?directory=data/docs"

预期产量:

{
  "status": "success",
  "documents_ingested": 45,
  "message": "Ingested 45 chunks from data/docs"
}

______________________________________________________________________

步骤5:测试系统

健康检查

curl http://localhost:8000/health

预期: 所有值 true

测试查询(RAG)

curl -X POST "http://localhost:8000/agent/query" `
  -H "Content-Type: application/json" `
  -H "X-Client-ID: basic-test" `
  -d '{\"message\": \"What is the deployment procedure?\"}'

预期: 带有引用和速率限制标头的HTTP 200

测试速率限制

# Send 15 requests (over 10 RPM limit)
for ($i=1; $i -le 15; $i++) {
  Write-Host "Request $i"
  curl -X POST "http://localhost:8000/agent/query" `
    -H "Content-Type: application/json" `
    -H "X-Client-ID: basic-ratelimit-test" `
    -d '{\"message\": \"Test\"}'
  Start-Sleep -Milliseconds 500
}

预期: 前~10个获取HTTP 200,其余获取HTTP 429

测试MCP工具

# Create ticket
curl -X POST "http://localhost:8000/agent/query" `
  -H "X-Client-ID: vip-test" `
  -H "Content-Type: application/json" `
  -d '{\"message\": \"Create a critical ticket for database outage\"}'

# Get ticket
curl -X POST "http://localhost:8000/agent/query" `
  -H "X-Client-ID: vip-test" `
  -H "Content-Type: application/json" `
  -d '{\"message\": \"Get ticket 1\"}'

# Append note
curl -X POST "http://localhost:8000/agent/query" `
  -H "X-Client-ID: vip-test" `
  -H "Content-Type: application/json" `
  -d '{\"message\": \"Append note to deploy-2024-01: Success\"}'

______________________________________________________________________

步骤6:运行k6负载测试

安装k6

choco install k6

运行测试

# Basic tier test
k6 run k6/simple_test_basic.js

# Comprehensive test
k6 run k6/load_test.js

# Mixed clients test
k6 run k6/simple_test_mixed.js

预期: 超过限制时,请参阅429条回复

______________________________________________________________________

步骤7:运行自动测试

测试MCP工具

python test_mcp_tools.py

测试RAG精度

python eval_rag.py

______________________________________________________________________

建筑

Client (k6/curl) → Rate Limiter (Redis) → LangGraph Orchestrator
                                                ↓
                                    ┌───────────┴────────────┐
                                    ↓                        ↓
                                RAG System              MCP Tools
                                    ↓                        ↓
                                ChromaDB                SQLite DB

具有速率限制的请求流

1. Client → API: Request with X-Client-ID header
2. Rate Limiter → Redis: Check bucket state (Leaky Bucket)
3. If allowed → Orchestrator: Process request
4. Orchestrator → RAG/MCP: Based on intent
5. Response → Client: With rate limit headers

______________________________________________________________________

技术栈

核心组件

  • API:带限速中间件的Python FastAPI
  • 速率限制器:Redis+漏桶算法
  • 矢量数据库:ChromaDB(嵌入式)
  • LLM:Groq(免费套餐)
  • MCP服务器:Python(stdio传输)
  • 编排器:LangGraph(基于图形的工作流)

测试

  • 负载测试图形 k6
  • 单元测试:Python单元测试
  • 集成测试:自定义测试套件

______________________________________________________________________

项目结构

lab7-devops-agent/
├── agent_api.py              # FastAPI server with rate limiting
├── rate_limiter.py           # Redis + Leaky Bucket implementation
├── devops_orchestrator.py    # LangGraph orchestrator
├── rag_system.py             # RAG with ChromaDB
├── mcp_server.py             # MCP server (3 tools)
├── mcp_client.py             # MCP client
├── test_mcp_tools.py         # Automated tool tests
├── eval_rag.py               # RAG evaluation script
├── docker-compose.yml        # Redis + API services
├── Dockerfile                # API container image
├── requirements.txt          # Python dependencies
├── .env                      # Environment variables
├── k6/
│   ├── load_test.js         # Comprehensive k6 test
│   ├── simple_test_basic.js # Basic tier test
│   ├── simple_test_pro.js   # Pro tier test
│   └── simple_test_mixed.js # Mixed clients test
├── data/
│   └── docs/                # DevOps documentation (10+ files)
│       ├── deployment_procedure.md
│       ├── incident_management.md
│       ├── server_maintenance.md
│       ├── monitoring.md
│       ├── backup_policy.md
│       └── ... (5+ more)
└── tests/
    ├── test_queries.json    # RAG test queries
    └── eval_results.json    # Evaluation results

______________________________________________________________________

费率限制级别

客户端ID模式RPM限制用例
基础basic-*10免费等级,测试
专业版pro-*60付费订阅
贵宾vip-*300企业,负载测试

客户端ID示例:

  • basic-user-123
  • pro-company-456
  • vip-enterprise-789

______________________________________________________________________

MCP工具(3个工具)

  1. 创建_票 -创建事件/问题工单

- 输入:摘要、详细信息、优先级 - 输出:ticket_id,状态

  1. 获取门票 -按ID检索门票详细信息

- 输入:ticket_id - 输出:票详细信息或未找到

  1. 附录_注释 -为实体添加注释

- 输入:entity_id,备注 - 输出:note_id,确认

______________________________________________________________________

Docker编写替代方案

使用Docker Compose而不是手动步骤:

# Start all services
docker-compose up -d

# Check status
docker-compose ps

# View logs
docker-compose logs -f agent-api

# Ingest documents
curl -X POST "http://localhost:8000/rag/ingest?directory=data/docs"

# Stop services
docker-compose down

______________________________________________________________________

故障排除

Redis未连接

docker ps | findstr redis
docker start devops-redis

速率限制不起作用

curl http://localhost:8000/health
# Check "redis_ready": true

MCP服务器没有响应

# Restart MCP server (Terminal 1)
# Press Ctrl+C, then:
python mcp_server.py

重置所有速率限制

docker exec -it devops-redis redis-cli FLUSHALL

端口8000已在使用中

netstat -ano | findstr :8000
taskkill /PID 
 /F

______________________________________________________________________

成功检查表

  • ✅ Redis正在运行: docker ps | findstr redis
  • ✅ 健康检查:全部 true/health
  • ✅ 摄入的文件:40+块
  • ✅ RAG工作:查询返回引用
  • ✅ MCP工具工作:所有3个工具都经过测试
  • ✅ 速率限制:基本层在10个请求后获得429
  • ✅ k6测试:负载测试显示预期的速率限制
  • ✅ 不同级别:专业/VIP有更高的限制

______________________________________________________________________

目录标签

目录标签

检索增强生成Python开发工具本地部署速率限制多工具协作开发运维自动化测试

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

运行时(runtime,运行环境)

Docker

工具数量(toolCount,工具数)

3

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdionone部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP