MCP框架
用于构建模型上下文协议 (MCP) 服务器的 TypeScript 框架。
与原版的差异
该分支(@ronangrant/mcp-framework)包括以下改进:
- 用仅控制台的日志记录替换基于文件的日志记录,以获得更好的兼容性和可靠性
- 消除了对文件系统日志的依赖,消除了 ENOENT 错误
- 简化日志记录实现,同时保持相同的接口
- 所有日志现在通过 console.error() 输出到 stderr
安装
用法
创建一个新的 MCP 服务器:
特征
- 用于创建 MCP 服务器的易于使用的 API
- 内置对工具、提示和资源的支持
- 带有控制台输出的简化日志系统
- 全面支持 TypeScript
- 灵活的交通选择
执照
麻省理工学院
MCP-Framework 是一个使用 TypeScript 优雅地构建模型上下文协议 (MCP) 服务器的框架。
MCP-Framework 为您提供开箱即用的架构,并支持基于目录的自动工具、资源和提示符发现功能。使用我们强大的 MCP 抽象,您可以优雅地定义工具、资源或提示符。我们的命令行界面让您轻松上手 MCP 服务器。
特征
- 🛠️ 自动发现和加载工具、资源和提示
- 多种传输支持(stdio、SSE)
- 具有完全类型安全性的 TypeScript 优先开发
- 基于官方 MCP SDK 构建
- 易于使用的工具、提示和资源基类
- SSE 端点的开箱即用身份验证
点击此处阅读完整文档
使�� mcp-framework 创建存储库
使用 CLI(推荐)
CLI 使用
该框架提供了强大的 CLI 来管理您的 MCP 服务器项目:
项目创建
添加工具
添加提示
添加资源
开发工作流程
- 创建你的项目:
- 根据需要添加工具:
- 建造:
- 添加到 MCP 客户端(请参阅下面的 Claude Desktop 示例)
与 Claude Desktop 一起使用
本地开发
将此配置添加到您的 Claude Desktop 配置文件:
MacOS :`~/Library/Application Support/Claude/claude_desktop_config.json` Windows :`%APPDATA%/Claude/claude_desktop_config.json`
发布后
将此配置添加到您的 Claude Desktop 配置文件:
MacOS :`~/Library/Application Support/Claude/claude_desktop_config.json` Windows :`%APPDATA%/Claude/claude_desktop_config.json`
构建和测试
- 更改你的工具
- 运行 `npm run build` 进行编译
- 服务器将在启动时自动加载您的工具
快速入门
创建工具
设置服务器
传输配置
stdio 传输(默认)
如果没有提供传输配置,则默认使用 stdio 传输:
上交所运输
要使用服务器发送事件 (SSE) 传输:
CORS 配置
SSE 传输支持灵活的 CORS 配置。默认情况下,它使用适合开发的宽松设置。对于生产环境,您应该根据自己的安全需求配置 CORS:
验证
MCP 框架为 SSE 端点提供了可选的身份验证方式。您可以选择 JWT 或 API Key 身份验证,也可以实现自定义的身份验证提供程序。
JWT 身份验证
客户端必须在授权标头中包含有效的 JWT 令牌:
API 密钥认证
客户端必须在 X-API-Key 标头中包含有效的 API 密钥:
自定义身份验证
您可以通过实现AuthProvider
接口来实现自己的身份验证提供程序:
执照
麻省理工学院
This server cannot be installed
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
用于构建模型上下文协议 (MCP) 服务器的 TypeScript 框架,可自动发现和加载工具、资源和提示。
Related MCP Servers
- AsecurityAlicenseAqualityA production-ready template for creating Model Context Protocol servers with TypeScript, providing tools for efficient testing, development, and deployment.Last updated -1112JavaScriptMIT License
- AsecurityFlicenseAqualityA TypeScript-based template for developing Model Context Protocol servers with features like dependency injection and service-based architecture, facilitating the creation and integration of custom data processing tools.Last updated -12TypeScript
- AsecurityFlicenseAqualityA template for creating Model Context Protocol (MCP) servers in TypeScript, offering features like container-based dependency injection, a service-based architecture, and integration with the LLM CLI for architectural design feedback through natural language.Last updated -15TypeScript
- AsecurityAlicenseAqualityA TypeScript-based template for building Model Context Protocol servers, featuring fast testing, automated version management, and a clean structure for MCP tool implementations.Last updated -112TypeScriptMIT License