API转MCP工具

一个将API转换为MCP(模型上下文协议)工具的Node.js包,支持多种API类型,易于与MCP生态系统集成。

  • by JayLi52
  • JavaScript
  • 本地部署
  • 5 星标
  • 更新于
在 GitHub 查看 JayLi52/api2mcptools

使用说明

@terryliyongjie/api2mcp工具

中文文档

一个将API转换为MCP(模型上下文协议)工具的Node.js包。

安装

选项1:npx快速入门(推荐)

set CONFIG_JSON_PATH=example.json
npx @terryliyongjie/api2mcptools

选项2:传统安装

# Install locally in your project
npm install @terryliyongjie/mcp-tools

# Or install globally to use as a CLI tool
npm install -g @terryliyongjie/mcp-tools

配置

环境变量

# Required: Path to your configuration JSON file
CONFIG_JSON_PATH=example.json

配置文件示例(example.json):

// Single tool configuration
{
    "name": "tool_name",
    "description": "Tool description",
    "inputSchema": {
        "type": "object",
        "properties": {
            "param1": {
                "type": "string",
                "description": "Parameter description"
            }
        },
        "required": ["param1"]
    },
    "axiosConfig": {
        "url": "https://api.example.com/endpoint",
        "method": "get",
        "params": {
            "key": "your_api_key"
        }
    }
}

// Or multiple tools configuration
[
    {
        "name": "baidu_place_search",
        "description": "使用百度地图API进行地点检索服务",
        "inputSchema": {
            "type": "object",
            "properties": {
                "query": {
                    "type": "string",
                    "description": "检索关键字"
                },
                "region": {
                    "type": "string",
                    "description": "检索行政区划区域"
                }
            },
            "required": ["query", "region"]
        },
        "axiosConfig": {
            "url": "https://api.map.baidu.com/place/v2/search",
            "method": "get",
            "params": {
                "ak": "your_baidu_map_key"
            }
        }
    },
    // More tools...
]

特性

  • 将JSON API转换为MCP工具
  • 易于与MCP生态系统集成
  • 支持各种API类型
  • 命令行界面(CLI)支持

用法

作为CLI工具

全局安装后,您可以直接在终端中使用该命令:

mcp-tools [options]

作为一个模块

// Example code coming soon

发展

# Install dependencies
npm install

# Build the project
npm run build

# Run in development mode
npm run dev

# Watch mode during development
npm run watch

# Run MCP inspector
npm run inspector

许可证

麻省理工学院