模型上下文协议服务器

Kirha Smithery Gateway是一个可配置的MCP(模型上下文协议)服务器,用于Kirha工具规划,支持动态工具注册和会话管理。

  • by kirha-ai
  • TypeScript
  • 本地部署
  • 更新于
在 GitHub 查看 kirha-ai/kirha-smithery-gateway

使用说明

Kirha Smithery门户

A configurable MCP (Model Context Protocol) server for Kirha tool planning ready to use with Smithery ## Features
  • JSON配置:轻松配置工具、垂直产品和API端点
  • 动态工具注册:工具根据配置进行注册
  • 基于会话的API密钥:每个会话都有自己的API密钥,用于安全执行工具
  • 调试模式:用于开发的可选调试日志记录
  • 模块化架构:使用单独文件中的工具将关注点彻底分离

配置

环境配置(smithery.yaml)

runtime: "container"
startCommand:
  type: "http"
  configSchema:
    type: "object"
    properties:
      apiKey:
        type: "string"
        description: "Your API key"
      debug:
        type: "boolean"
        description: "Enable debug logging"
        default: false
      configPath:
        type: "string"
        description: "Path to custom configuration file"
    required: ["apiKey"]

JSON配置(config.JSON)

{
  "mcp": {
    "name": "kirha-crypto",
    "version": "1.0.0"
  },
  "tool": {
    "name": "execute-crypto-tool-planning",
    "title": "Crypto Tool Planning",
    "description": "Execute crypto-related tool planning",
    "enabled": true
  },
  "vertical": "crypto",
  "api": {
    "executeToolPlanningUrl": "https://api.kirha.ai/chat/v1/tool-planning/execute",
    "summarization": {
      "enable": true,
      "model": "kirha-flash"
    }
  }
}

创建叉子

要为不同的垂直方向创建叉:

  1. 复制 config.example.json 向 config.json
  2. 更新配置:
    • 改变 mcp.name 到你的垂直名称
    • 更新 vertical 到您的垂直ID
    • 修改 tool 使用您的特定工具创建对象
    • 更新 tool.name, tool.title,以及 tool.description

项目结构

src/
├── index.ts              # Main server entry point
├── types.ts              # Type definitions
└── tools/
    └── toolPlanning.ts   # Tool planning implementation

发展

# Install dependencies
npm install

# Run in development mode
npm run dev

# Build for production
npm run build

# Start built server
npm start

添加新工具

  1. 在中创建新文件 src/tools/ (例如。, newTool.ts)
  2. 按照以下步骤执行刀具注册功能 ToolRegistrationFunction 类型
  3. 将工具添加到 availableTools 在中映射 src/index.ts
  4. 更新您的 config.json 包括新工具

会话管理

  • 每个客户端连接都从Smithery获得自己的API密钥
  • 配置在连接时绑定
  • 工具可以访问特定于会话的配置
  • API密钥安全地传递给工具执行函数

调试模式

通过设置启用调试模式 debug: true 在会话配置中:

GET /mcp?apiKey=your-key&debug=true

这将记录:

  • 配置加载
  • 工具注册
  • 工具执行
  • 错误详细信息