LiteLLM MCP连接器
LiteLLM代理与模型上下文协议(MCP)连接器的全面集成,用于 Jira, 概念, GitLab,以及 Slack.
🌟 特性
- LiteLLM人工智能网关:与100多个LLM API的统一接口,具有成本跟踪、速率限制和负载平衡功能
- MCP集成:对模型上下文协议服务器的本机支持
- OAuth 2.0身份验证:所有连接器的安全身份验证
- 4个生产就绪连接器:
- Jira:问题跟踪、项目管理和工作流自动化 - 概念:知识库访问和文件管理 - GitLab:存储库操作、CI/CD和问题管理 - Slack:团队沟通和信息传递
🏗️ 建筑
┌─────────────────────────────────────────────────────────────┐
│ LiteLLM Proxy (Port 4000) │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Rate Limiting│ │ Auth/API Keys│ │Load Balancing│ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
└───────────────┬─────────────────────────────────────────────┘
│
┌───────┴────────┬────────┬────────┬────────┐
│ │ │ │ │
┌───────▼──────┐ ┌───────▼──┐ ┌──▼────┐ ┌─▼──────┐ │
│ Jira MCP │ │Notion MCP│ │GitLab │ │ Slack │ │
│ Server │ │Server │ │MCP │ │MCP │ │
│ (Port 8001) │ │(Port8002)│ │Server │ │Server │ │
│ │ │ │ │(8003) │ │(8004) │ │
└──────┬───────┘ └────┬─────┘ └───┬───┘ └───┬────┘ │
│ │ │ │ │
│ │ │ │ │
┌───▼──────┐ ┌───▼──────┐ ┌──▼─────┐ ┌─▼──────▼┐
│ Jira │ │ Notion │ │ GitLab │ │ Slack │
│ Cloud │ │ API │ │ API │ │ API │
└──────────┘ └──────────┘ └────────┘ └────────┘📋 先决条件
- Python 3.11+
- Docker和Docker Compose(可选,用于容器化部署)
- 您要使用的每个服务的OAuth凭据
🚀 快速开始
1.克隆和设置
git clone https://github.com/vsemashko/litellm-mcp-connectors.git
cd litellm-mcp-connectors
# Copy environment template
cp .env.example .env
# Edit .env with your credentials
nano .env2.安装依赖项
# Using pip
pip install -r requirements.txt
# Or using the package
pip install -e .3.配置OAuth凭据
编辑 .env 包含每个服务的OAuth凭据的文件:
- Jira:在以下位置创建OAuth应用程序https://developer.atlassian.com/console/myapps/
- 概念:在以下位置创建集成https://www.notion.so/my-integrations
- GitLab:在以下位置创建OAuth应用程序https://gitlab.com/-/profile/applications
- Slack:创建应用程序https://api.slack.com/apps
4.使用Docker Compose运行
cd docker
docker-compose up -d5.手动运行(开发)
# Terminal 1: Start Jira MCP Server
uvicorn connectors.jira.server:app --host 0.0.0.0 --port 8001
# Terminal 2: Start Notion MCP Server
uvicorn connectors.notion.server:app --host 0.0.0.0 --port 8002
# Terminal 3: Start GitLab MCP Server
uvicorn connectors.gitlab.server:app --host 0.0.0.0 --port 8003
# Terminal 4: Start Slack MCP Server
uvicorn connectors.slack.server:app --host 0.0.0.0 --port 8004
# Terminal 5: Start LiteLLM Proxy
litellm --config config/litellm_config.yaml --port 4000📚 用法
通过LiteLLM代理发出请求
所有服务运行后,您可以向LiteLLM代理发出请求:
curl -X POST http://localhost:4000/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $LITELLM_MASTER_KEY" \
-d '{
"model": "gpt-4",
"messages": [{"role": "user", "content": "Search Jira for bugs in project PROJ"}],
"tools": ["jira.search_issues"]
}'直接访问MCP服务器
您还可以直接与MCP服务器交互:
Jira示例
# List available tools
curl -X POST http://localhost:8001/mcp \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $LITELLM_MASTER_KEY" \
-d '{"method": "tools/list"}'
# Search issues
curl -X POST http://localhost:8001/mcp \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $LITELLM_MASTER_KEY" \
-d '{
"method": "tools/call",
"params": {
"name": "search_issues",
"arguments": {
"jql": "project = PROJ AND status = Open"
}
}
}'概念示例
# Search pages
curl -X POST http://localhost:8002/mcp \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $LITELLM_MASTER_KEY" \
-d '{
"method": "tools/call",
"params": {
"name": "search_pages",
"arguments": {
"query": "meeting notes"
}
}
}'GitLab示例
# List projects
curl -X POST http://localhost:8003/mcp \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $LITELLM_MASTER_KEY" \
-d '{
"method": "tools/call",
"params": {
"name": "list_projects",
"arguments": {
"search": "backend"
}
}
}'Slack示例
# Send message
curl -X POST http://localhost:8004/mcp \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $LITELLM_MASTER_KEY" \
-d '{
"method": "tools/call",
"params": {
"name": "send_message",
"arguments": {
"channel": "general",
"text": "Hello from MCP!"
}
}
}'🔧 配置
LiteLLM代理配置
编辑 config/litellm_config.yaml 致:
- 添加/删除LLM模型
- 配置速率限制
- 设置虚拟密钥
- 配置MCP服务器端点
MCP服务器配置
编辑 config/mcp_servers.json 致:
- 定义可用的工具和资源
- 配置OAuth作用域
- 设置服务器元数据
🧪 测试
# Run all tests
pytest
# Run with coverage
pytest --cov=connectors --cov=shared
# Run specific connector tests
pytest tests/test_jira.py📊 监控
所有服务都公开健康检查端点:
- LiteLLM代理:http://localhost:4000/health
- Jira MCP:http://localhost:8001/health
- MCP概念:http://localhost:8002/health
- GitLab MCP:http://localhost:8003/health
- 松弛MCP:http://localhost:8004/health
🔐 安全
- 所有连接器的OAuth 2.0客户端凭据流
- API请求的承载令牌身份验证
- 每个API键的可配置速率限制
- 具有预算跟踪功能的虚拟密钥管理
- 支持基于团队的访问控制
📁 项目结构
litellm-mcp-connectors/
├── config/
│ ├── litellm_config.yaml # LiteLLM proxy configuration
│ └── mcp_servers.json # MCP server definitions
├── connectors/
│ ├── jira/ # Jira MCP server
│ ├── notion/ # Notion MCP server
│ ├── gitlab/ # GitLab MCP server
│ └── slack/ # Slack MCP server
├── shared/
│ ├── auth/ # OAuth & authentication
│ └── utils/ # Common utilities
├── tests/ # Test suite
├── docker/
│ ├── docker-compose.yml # Docker orchestration
│ └── Dockerfile.connector # Connector image
├── requirements.txt # Python dependencies
├── pyproject.toml # Project metadata
└── README.md # This file🤝 贡献
欢迎投稿!拜托:
- 分叉存储库
- 创建要素分支
- 进行更改
- 添加测试
- 提交拉取请求
📝 许可证
MIT许可证-有关详细信息,请参阅许可证文件
🐛 故障排除
常见问题
OAuth身份验证失败
- 在中验证OAuth凭据
.env - 检查令牌URL是否正确
- 确保授予所需的范围
MCP服务器连接错误
- 验证所有服务器是否正在运行
- 检查端口可用性
- 检查防火墙设置
速率限制
- 调整限制
litellm_config.yaml - 检查虚拟密钥配额
📖 其他资源
🙋 支持
对于问题和疑问:
- 在GitHub上打开一个问题
- 检查现有文档
- 查看故障排除指南
______________________________________________________________________
内置于❤️ 使用LiteLLM和模型上下文协议
