动态API服务器
一个基于MCP协议的模块化动态API服务器,为AI助手提供丰富的工具能力,同时显著减少prompt token消耗。
特点
- 模块化API设计:每个API都是独立模块,易于维护和扩展
- 动态发现与加载:自动扫描和加载API目录中的模块
- 元工具设计:AI仅需知道三个元工具,而不是全部API
- 热更新支持:监控API文件变化,无需重启即可更新
- 类型安全:完整的TypeScript类型定义
- 丰富的文档:每个API都包含详细说明和使用示例
工作原理
本项目解决了传统MCP工具实现中API数量增长导致prompt负担过重的问题。通过元工具设计模式,将所有具体API实现从prompt中剥离,仅保留三个核心元工具:
- listAllApis:列出所有可用API,可按分类筛选
- getApiDetails:获取特定API的详细信息和使用方法
- executeApi:执行指定的API,接收API ID和参数
AI可以先探索可用API,获取详情,然后再执行,而不需要预先了解所有API的细节。
目录结构
构建和运行
添加新API
创建新API非常简单,只需要在src/apis
目录下的适当子目录中创建新文件:
保存文件后,服务器会自动发现并加载新API,无需重启。
维护和扩展
- 添加新分类:在
src/core/registry.ts
中的ApiCategories
对象添加新分类 - 修改API行为:直接编辑相应的API模块文件
- 修改加载行为:调整
src/core/loader.ts
中的配置或行为
许可证
MIT
This server cannot be installed
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
A modular dynamic API server based on the MCP protocol that provides rich tool capabilities for AI assistants while significantly reducing prompt token consumption.
Related MCP Servers
- -securityFlicense-qualityA simple aggregator server that allows batching multiple MCP tool calls into a single request, reducing token usage and network overhead for AI agents.Last updated -14JavaScript
- -security-license-qualityAn MCP server that allows AI assistants to utilize human capabilities by sending requests to humans and receiving their responses through a Streamlit UI.Last updated -23PythonMIT License
- AsecurityFlicenseAqualityAn MCP server that allows AI assistants to interact with the ServiceTitan API, requiring client credentials for authentication.Last updated -454TypeScript
- -securityAlicense-qualityA tool that creates MCP (Model Context Protocol) servers from OpenAPI/Swagger specifications, enabling AI assistants to interact with your APIs.Last updated -479TypeScriptMIT License