使用说明
MCP服务器-OpenAPI和Redmine工具
模型上下文协议(MCP)服务器,为OpenAPI/Swagger文档搜索和Redmine问题管理提供工具。
🚀 快速开始
本地开发
# Install dependencies
pnpm install
# Build
pnpm build
# Run
pnpm start
服务器在上运行 http://localhost:3100
测试运行状况端点
curl http://localhost:3100/health
🛠️ 特性
运输类型
- ✅ 超文本传输协议 通过快递+
StreamableHTTPServerTransport(/mcp) - ✅ 标准 通过
StdioServerTransport(MCP_TRANSPORT=stdio) - ✅ 无会话 HTTP请求处理
提供的工具
1.OpenAPI搜索(openapi_searchEndpoints)
在OpenAPI/Swagger文档中搜索API端点。
配置: 通过 OPENAPI_JSON
例子:
curl -X POST http://localhost:3100/mcp \
-H "Content-Type: application/json" \
-H "OPENAPI_JSON: https://petstore3.swagger.io/api/v3/openapi.json" \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}'
2.Redmine问题获取器(redmine_getIssue)
获取带有附件和自定义字段的Redmine问题。
配置: 传递这些密钥:
REDMINE_URL:您的Redmine实例URLREDMINE_API:您的Redmine API密钥REDMINE_PROJECT:项目ID到范围问题REDMINE_IMAGE_CACHE_DIR(可选):缓存描述图像以供重用的本地目录
📡 API终点
健康检查
GET /health
返回服务器状态、正常运行时间、内存使用情况。
MCP协议
POST /mcp # JSON-RPC messages (initialize, tools/list, tools/call, etc.)
GET /mcp # Optional SSE stream (client-dependent)
此服务器是 无会话。客户端不需要存储或发送 Mcp-Session-Id.
🏗️ 建筑
会话管理
此服务器是无会话的,不存储每个客户端的状态。
多用户支持
支持多个并发用户。配置是通过每个请求的HTTP标头传递的。
🌐 部署
选择您的平台:
- 铁路 -每月5美元,部署最简单
- 科耶布 -永远免费,好DX
- Oracle云 -永久免费,资源最大化,手动设置
看 部署.md 获取详细指南。
🔧 配置
环境变量
PORT=3100 # Server port (default: 3100)
NODE_ENV=production # Environment
MCP_TRANSPORT=http # "http" (default) or "stdio"
OPENAPI_JSON=http://localhost:8000/openapi.json
REDMINE_URL=https://redmine.example.com
REDMINE_API=<your-api-key>
REDMINE_PROJECT=<project-id>
REDMINE_IMAGE_CACHE_DIR=/tmp/remake-mcp/redmine-images # Optional Redmine image cache directory
每会话配置(通过HTTP标头)
REDMINE_API: <your-api-key>
REDMINE_URL: https://redmine.example.com
REDMINE_PROJECT: <project-id>
REDMINE_IMAGE_CACHE_DIR: /tmp/remake-mcp/redmine-images
OPENAPI_JSON: https://api.example.com/openapi.json
📦 依赖项
@modelcontextprotocol/sdk-MCP协议实现express-HTTP服务器cors-CORS中间件zod-架构验证
🐳 码头工人
# Build
docker build -t mcp-server .
# Run
docker run -p 3100:3100 mcp-server
# Test
curl http://localhost:3100/health
🧪 测试
# 1. Start server
pnpm start
# 2. Initialize session with OpenAPI config
curl -X POST http://localhost:3100/mcp \
-H "Content-Type: application/json" \
-H "OPENAPI_JSON: https://petstore3.swagger.io/api/v3/openapi.json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "initialize",
"params": {
"protocolVersion": "2024-11-05",
"capabilities": {},
"clientInfo": {"name": "test-client", "version": "1.0.0"}
}
}' -i
# 3. List available tools
curl -X POST http://localhost:3100/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/list"
}'
# 4. Call OpenAPI search tool
curl -X POST http://localhost:3100/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 3,
"method": "tools/call",
"params": {
"name": "openapi_searchEndpoints",
"arguments": {"path": "/pet"}
}
}'
📝 许可证
麻省理工学院
🤝 贡献
问题和PR欢迎!
