适用于Leantime项目管理系统的强大Model Context Protocol (MCP)代理桥。使用TypeScript和官方MCP SDK构建,此工具提供了一个可靠的MCP客户端与Leantime服务器之间的桥梁。
@modelcontextprotocol/sdk进行强大的协议处理npm install -g leantime-mcp
git clone https://github.com/leantime/leantime-mcp.git
cd leantime-mcp
npm install
npm run build
npm install -g .
添加到您的claude_desktop_config.json:
{
"mcpServers": {
"leantime": {
"command": "leantime-mcp",
"args": [
"https://yourworkspace.leantime.io/mcp",
"--token",
"YOUR_TOKEN_HERE"
]
}
}
}
{
"mcpServers": {
"leantime": {
"command": "leantime-mcp",
"args": [
"https://yourworkspace.leantime.io/mcp",
"--token",
"YOUR_TOKEN_HERE",
"--insecure"
]
}
}
}
{
"mcpServers": {
"leantime": {
"command": "node",
"args": [
"/path/to/leantime-mcp/dist/index.js",
"https://your-leantime.com/mcp",
"--token",
"YOUR_TOKEN_HERE"
]
}
}
}
{
"mcpServers": {
"leantime": {
"command": "leantime-mcp",
"args": [
"https://yourworkspace.leantime.io/mcp",
"--token",
"YOUR_TOKEN_HERE",
"--auth-method",
"Bearer",
"--max-retries",
"5",
"--retry-delay",
"2000"
]
}
}
}
对于Claude Code,添加到您的claude_config.json或使用命令行:
{
"mcp": {
"servers": {
"leantime": {
"command": "leantime-mcp",
"args": [
"https://yourworkspace.leantime.io/mcp",
"--token",
"YOUR_TOKEN_HERE"
]
}
}
}
}
claude --mcp-server leantime="leantime-mcp https://your-leantime.com/mcp --token YOUR_TOKEN_HERE"
对于Cursor IDE,添加到您的工作区设置或全局设置:
.vscode/settings.json){
"mcp.servers": {
"leantime": {
"command": "leantime-mcp",
"args": [
"https://yourworkspace.leantime.io/mcp",
"--token",
"YOUR_TOKEN_HERE"
]
}
}
}
打开Cursor设置 → 扩展 → MCP 并添加:
{
"leantime": {
"command": "leantime-mcp",
"args": [
"https://yourworkspace.leantime.io/mcp",
"--token",
"YOUR_TOKEN_HERE"
]
}
}
对于支持MCP的ChatGPT或OpenAI API集成:
# 使用OpenAI和MCP的Python示例
import openai
from mcp_client import MCPClient
# 初始化MCP客户端
mcp_client = MCPClient(
command="leantime-mcp",
args=[
"https://yourworkspace.leantime.io/mcp",
"--token",
"YOUR_TOKEN_HERE"
]
)
# 与OpenAI一起使用
client = openai.OpenAI(api_key="your-openai-key")
response = client.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": "Show me my Leantime projects"}],
tools=mcp_client.get_tools()
)
# 对于自定义GPT动作
openapi: 3.0.0
info:
title: Leantime MCP Proxy
version: 2.0.0
servers:
- url: https://yourworkspace.leantime.io/mcp
paths:
/tools/list:
post:
summary: 列出可用工具
requestBody:
content:
application/json:
schema:
type: object
properties:
jsonrpc:
type: string
default: "2.0"
method:
type: string
default: "tools/list"
id:
type: integer
security:
- bearerAuth: []
components:
securitySchemes:
bearerAuth:
type: http
scheme: bearer
bearerFormat: JWT
对于任何MCP兼容客户端:
{
"name": "leantime",
"command": "leantime-mcp",
"args": [
"https://yourworkspace.leantime.io/mcp",
"--token",
"YOUR_TOKEN_HERE"
],
"env": {
"NODE_ENV": "production"
}
}
# docker-compose.yml
version: '3.8'
services:
leantime-mcp:
image: node:18-alpine
command: npx leantime-mcp https://yourworkspace.leantime.io/mcp --token YOUR_TOKEN_HERE
environment:
- NODE_ENV=production
volumes:
- ./config:/config
stdin_open: true
tty: true
# 使用调试日志进行本地测试
leantime-mcp https://localhost:8080/mcp \
--token "dev-token-123" \
--insecure \
--no-cache \
--max-retries 1 \
2>debug.log
# 中等可靠性的预发布环境
leantime-mcp https://staging.leantime.com/mcp \
--token "staging-token-456" \
--max-retries 3 \
--retry-delay 1000
# 高可靠性的生产环境
leantime-mcp https://leantime.company.com/mcp \
--token "prod-token-789" \
--auth-method Bearer \
--max-retries 5 \
--retry-delay 2000
leantime-mcp <url> --token <token> [选项]
<url> - Leantime MCP端点URL(必需)--token <token> - 认证令牌(必需)--auth-method <method> - 认证方法(可选,默认:Bearer)--insecure - 跳过SSL证书验证(可选)--protocol-version <version> - MCP协议版本(可选)--max-retries <num> - 最大重试次数(可选,默认:3)--retry-delay <ms> - 基础重试延迟(毫秒)(可选,默认:1000)--no-cache - 禁用响应缓存(可选)| 方法 | 头格式 | 示例 |
|---|---|---|
Bearer(默认) | Authorization: Bearer <token> | --auth-method Bearer |
X-API-Key | X-API-Key: <token> | --auth-method X-API-Key |
leantime-mcp https://leantime.example.com/mcp --token abc123
leantime-mcp https://leantime.example.com/mcp --token abc123 --auth-method x-api-key
leantime-mcp https://localhost/mcp --token abc123 --insecure
leantime-mcp https://leantime.example.com/mcp --token abc123 --protocol-version 2025-03-26
leantime-mcp https://leantime.example.com/mcp --token abc123 --max-retries 5 --retry-delay 2000
leantime-mcp https://leantime.example.com/mcp --token abc123 --no-cache
tools/list、resources/list和prompts/list响应被缓存--no-cache禁用开发/测试@modelcontextprotocol/sdk而不是自定义实现# 克隆仓库
git clone https://github.com/leantime/leantime-mcp.git
cd leantime-mcp
# 安装依赖
npm install
# 构建TypeScript
npm run build
# 本地测试
echo '{"jsonrpc":"2.0","id":1,"method":"ping"}' | node dist/index.js https://your-leantime.com/mcp --token your-token
# 监控更改并重新构建
npm run dev
--insecure标志代理包括全面的错误处理:
所有错误消息都记录到stderr,以避免干扰MCP通信上的stdout。
已在v2.0中修复:代理现在会在初始握手后自动捕获并在所有请求中包含MCP会话ID。
已在v2.0中修复:代理现在将Leantime的PHP错误响应转换为Claude Desktop可以理解的正确JSON-RPC错误格式。
--max-retries 5--insecure进行自签名证书的开发这是正常行为 - 代理等待从Claude Desktop通过stdin接收JSON-RPC消息。如果您正在手动测试,请发送一个JSON-RPC消息:
echo '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' | leantime-mcp https://your-leantime.com/mcp --token YOUR_TOKEN
npm install -g ."command": "node",
"args": ["/absolute/path/to/leantime-mcp/dist/index.js", ...]
启用详细日志以排查连接问题:
# 代理将日志输出到stderr,因此您可以看到调试信息,同时MCP通信继续
leantime-mcp https://your-leantime.com/mcp --token YOUR_TOKEN 2>debug.log
Claude Desktop日志:检查~/Library/Logs/Claude/mcp-server-leantime.log(macOS)以获取详细的MCP通信日志。
代理日志:所有代理日志都输出到stderr,包括:
代理提供了详细的日志用于调试:
[LeantimeMCP] 初始化Leantime MCP代理...
[LeantimeMCP] 服务器:https://leantime.example.com/mcp
[LeantimeMCP] 认证方法:Bearer
[LeantimeMCP] SSL验证:启用
[LeantimeMCP] 协议版本:2025-03-26
[LeantimeMCP] 准备处理MCP请求...
MIT许可 - 详见LICENSE文件
git checkout -b feature/amazing-feature)npm run build && npm test)对于问题和疑问: