释放 MCP 服务器
与 Unleash Feature Toggle 系统集成的模型上下文协议 (MCP) 服务器实现。
概述
该项目使用模型上下文协议 (MCP) 在 LLM 应用程序和 Unleash 功能标记系统之间搭建了桥梁。它允许 AI 应用程序:
- 从 Unleash 检查功能标志状态
- 向 LLM 公开功能标志信息
- 创建功能标志
- 更新功能标志
- 列出所有项目
目录
要求
- Node.js(v18 或更高版本)
- TypeScript(v5.0 或更高版本)
- 访问 Unleash 服务器实例
安装
# Install dependencies
npm i
建筑学
Unleash MCP 服务器充当 LLM 应用程序和 Unleash 功能标志系统之间的桥梁:
+----------------+ +-------------------+ +----------------+
| | | | | |
| LLM App | <--> | Unleash MCP | <--> | Unleash API |
| (MCP Client) | | Server | | Server |
| | | | | |
+----------------+ +-------------------+ +----------------+
发展
项目结构
unleash-mcp-server/
├── src/
│ ├── index.ts # Main entry point
│ ├── server.ts # Server implementation
│ ├── config.ts # Configuration handling
│ ├── transport/ # MCP transport implementations
│ │ ├── http.ts # HTTP/SSE transport
│ │ └── stdio.ts # STDIO transport
│ ├── unleash/ # Unleash API client implementations
│ │ ├── unleash-client.ts # Main Unleash client
│ │ ├── get-feature-flag.ts
│ │ └── get-all-projects.ts
│ ├── resources/ # MCP resource implementations
│ │ ├── flags.ts # Feature flag resources
│ │ └── projects.ts # Project resources
│ ├── tools/ # MCP tool implementations
│ │ ├── get-flag.ts # Get feature flag tool
│ │ └── get-projects.ts # Get projects tool
│ └── prompts/ # MCP prompt implementations
│ ├── flag-check.ts # Check single flag
│ └── batch-flag-check.ts # Check multiple flags
├── tests/ # Tests
└── package.json # Project configuration
编码标准
- 命名约定:
- 文件:使用 kebab-case.ts (例如
feature-flag.ts
) - 类:使用 PascalCase(例如,
UnleashClient
) - 函数/方法:使用驼峰式命名法(例如
getFlagStatus
) - 接口/类型:使用 PascalCase(例如,
FeatureFlagConfig
)
- 进口:
- 导入本地文件时始终包含 .js 扩展名
- 遵循导入顺序:Node.js 内置函数 → 外部依赖项 → 本地导入
- 使用命名导出而不是默认导出
- 文档:
- 对公共函数、类和接口使用 JSDoc 注释
- 使用内联注释记录复杂逻辑
建筑
# Compile TypeScript
npm run build
# Run the server
npm start
测试
检查
# MCP stdio inspect
npm run build
npx @modelcontextprotocol/inspector node dist/index.js
# MCP sse inspect
npm start
npx @modelcontextprotocol/inspector
如何使用
对于 Claude 或 Cursor 配置:
{
"mcpServers": {
"unleash": {
"command": "npx",
"args": [
"-y",
"unleash-mcp"
],
"env": {
"UNLEASH_URL": "YOUR_UNLEASH_END_POINT",
"UNLEASH_API_TOKEN": "YOUR_UNLEASH_API_TOKEN",
"MCP_TRANSPORT": "stdio",
"MCP_HTTP_PORT": 3001
}
}
}
}
贡献
欢迎贡献代码!欢迎提交 Pull 请求。
支持该项目
如果您发现这个项目有帮助,请考虑给我买杯咖啡!
扫描上方二维码或点击此处支持该项目的发展。
执照
该项目根据 MIT 许可证获得许可 - 有关详细信息,请参阅 LICENSE 文件。