R2R MCP 服务器是一款功能强大的工具,可与大语言模型(LLM)进行交互。它借助 MCP 协议集成多种模型,并提供丰富的功能模块,极大提升了与 LLM 交互的效率和体验。
R2R MCP 服务器是一个强大的工具,用于与各种大语言模型(LLM)进行交互。以下是使用该服务器的快速指南:
from r2r_mcp_server import MCPClient
client = MCPClient("http://localhost:8000")
response = client.chat_completion(
messages=[{"role": "user", "content": "你好,我是测试用户。"}]
)
print(response)
pip install mcp r2r loguru pytest pytest-asyncio pytest-cov black isort mypy ruff httpx
mcp init --name "R2R MCP Server" --description "A powerful LLM interaction server"
R2R_API_KEY:R2R 服务的访问密钥。MCP_SERVER_ADDRESS:MCP 服务器地址。LOG_LEVEL:日志级别(DEBUG, INFO, WARNING, ERROR)。import logging
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)
ModelAdapter 接口,针对具体模型进行适配。extensions 目录下添加新的功能插件。cli.py 实现自定义命令。git checkout -b feature/amazing-feature。R2R MCP Server 支持与多种 MCP 兼容模型集成,包括:
| 属性 | 详情 |
|---|---|
| 模型类型 | 支持多种 MCP 兼容模型,如 Claude 等 |
| 训练数据 | 未提及 |
| 包名 | mcp、r2r、loguru、pytest、httpx 等 |
| 版本 | mcp(>=1.0)、r2r(>=0.5)、loguru(>=0.1)、pytest(>=6.0)、httpx(>=0.23) |
| 状态 | 可用 |
| 描述 | MCP 协议实现、R2R 服务接口、日志记录库、测试框架、HTTP 客户端库等 |
r2r-mcp-server/
├── server.py # 主服务程序
├── extensions/ # 功能扩展模块
│ ├── document_parsing.py # 文档解析模块
│ └── code_interpreter.py # 代码解释器模块
├── cli.py # 命令行工具
└── tests/ # 测试用例
└── test_server.py # 服务测试用例
from r2r_mcp_server import MCPClient
client = MCPClient("http://localhost:8000")
response = client.chat_completion(
messages=[{"role": "user", "content": "你好,我是测试用户。"}]
)
print(response)
本项目采用 MIT License。