remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
Integrations
Enables configuration through environment variables loaded from .env files, supporting easy management of API keys and other configuration settings needed by the MCP server.
Serves as the runtime environment for the MCP server, with support for Node.js 18 or higher, enabling server-side JavaScript execution and API integrations.
Provides full TypeScript support with proper typing throughout the codebase, enabling type safety for tool definitions, service implementations, and handler functions.
通用 MCP 服务器模板
模块化、可扩展的模型上下文协议 (MCP) 服务器模板,旨在轻松定制和扩展。
特征
- 模块化架构:通过定义明确的结构明确地分离关注点
- 小型、专注的文件:更好的可维护性,更容易被人工智能吸收
- 轻松扩展点:添加新工具和服务的简单模式
- 全面的错误处理:整个代码库的强大错误管理
- 类型安全:完全支持 TypeScript 并正确输入
项目结构
入门
先决条件
- Node.js 18 或更高版本
- npm 或 yarn
安装
- 克隆此存储库:Copy
- 安装依赖项:Copy
- 根据
.env.example
创建.env
文件:Copy - 使用您的 API 密钥和配置编辑
.env
文件。
构建和运行
- 构建项目:Copy
- 运行服务器:Copy
扩展模板
添加新服务
- 在
src/services/
中创建一个新的服务文件:Copy - 在
src/types/
中添加任何必要的类型。
添加新工具
- 在新文件中定义您的工具或扩展
src/tools/
中现有的工具:Copy - 为您的工具实现处理程序:Copy
- 在
src/index.ts
中注册您的工具和处理程序。
配置
该模板使用src/config.ts
中的集中配置系统。可以通过以下方式提供配置:
- 环境变量
- 命令行参数(使用
--env KEY=VALUE
) - 代码中的默认值
错误处理
该模板包括全面的错误处理:
- 具有速率限制支持的服务级错误处理
- 使用适当的错误消息进行工具级错误处理
- MCP 协议错误处理
执照
麻省理工学院
This server cannot be installed
一个与 AI 配合使用的框架,可轻松为任何服务创建服务器。只需将 API 文档放入其中,并请求创建 MCP。