MCP到克劳德技能转换器
使用TypeScript接口自动将模型上下文协议(MCP)服务器转换为Claude代码技能。
概述
此工具连接到任何MCP服务器,反思其可用工具,并生成完整的Claude Code技能包,包括:
- TypeScript接口 适用于所有工具输入(从JSON模式自动生成)
- 技能.md 带有工具描述和参数的文档
- 即用型技能包 可以安装在Claude Code中
特性
- 🔍 自动发现:连接到MCP服务器并发现所有可用工具
- 📝 TypeScript生成:将JSON模式转换为TypeScript接口
- 📦 完整套装:创建可安装的技能包
- 🔄 分页支持:处理具有大型工具列表的服务器
- 🛠️ 通用兼容性:适用于任何MCP服务器(Node.js、Python等)
安装
npm install用法
构建项目
npm run build转换MCP服务器
node dist/scripts/convert.js "" 例子
转换Everything服务器:
node dist/scripts/convert.js "npx -y @modelcontextprotocol/server-everything" ./everything-skill转换本地服务器:
node dist/scripts/convert.js "node ./my-server/index.js" ./my-skill转换Python服务器:
node dist/scripts/convert.js "uvx mcp-server-time" ./time-skill用作Claude代码技能
这个项目本身就是Claude Code技能!
安装作为一种技能
- 克隆或下载此存储库
- 安装依赖项:
npm install - 通过引用技能在Claude Code中使用
使用克劳德代码中的技能
User: Convert the everything MCP server to a skill
Claude: I'll convert the MCP server to a Claude Code skill...
[Runs the conversion automatically]
✓ Generated skill at ./everything-skill/看 技能.md 了解详细的技能使用说明。
运作原理
- 连接:通过stdio传输建立与MCP服务器的连接
- 发现:发送
tools/listJSON-RPC请求枚举所有工具 - 解析:提取工具元数据(名称、描述、输入模式)
- 生成:使用将JSON模式转换为TypeScript接口
json-schema-to-typescript - 包裹:创建包含skill.md、类型和文档的完整技能目录
生成的输出结构
/
├── SKILL.md # Main skill documentation
├── README.md # Installation and usage instructions
└── scripts/
└── types.ts # TypeScript interfaces for all tools生成界面示例
来自MCP工具:
{
"name": "get_weather",
"description": "Get weather for a location",
"inputSchema": {
"type": "object",
"properties": {
"location": { "type": "string", "description": "City name" },
"units": { "type": "string", "enum": ["celsius", "fahrenheit"] }
},
"required": ["location"]
}
}生成的TypeScript:
export interface GetWeatherInput {
location: string;
units?: "celsius" | "fahrenheit";
}需求
- Node.js 18+(用于ES模块和MCP SDK)
- MCP服务器:
- 实现模型上下文协议规范 - 支持 tools/list 方法 - 使用JSON模式进行输入定义 - 可以通过stdio传输启动
支持的MCP服务器
此转换器适用于用任何语言编写的MCP服务器:
- ✅ Node.js/TypeScript服务器
- ✅ Python服务器(通过
uvx或直接调用) - ✅ Go服务器
- ✅ 任何支持MCP SDK的语言
发展
项目结构
mcp-to-claude-skill/
├── scripts/
│ ├── convert.ts # Main CLI entry point
│ ├── mcp-client.ts # MCP server connection logic
│ ├── schema-parser.ts # JSON Schema → TypeScript converter
│ └── skill-generator.ts # SKILL.md generation
├── SKILL.md # Skill definition for Claude Code
├── package.json
├── tsconfig.json
└── README.md建筑
npm run build这将TypeScript编译为JavaScript dist/ 目录。
清洁
npm run clean故障排除
“找不到模块”错误
确保你已经跑过了 npm run build 在执行转换器之前。
连接超时
如果服务器启动时间过长:
- 验证服务器命令是否正确
- 检查是否安装了所需的依赖项
- 尝试直接运行server命令进行测试
未找到工具
如果 tools/list 返回0个工具:
- 验证服务器是否实现了工具协议
- 使用MCP检查器调试服务器
- 检查服务器日志是否有错误
贡献
欢迎投稿!需要改进的地方:
- \[\]支持输出模式(返回类型)
- \[\]生成包装函数(如Anthropic的示例)
- \[\]支持MCP资源和提示
- \[\]带有提示的交互模式
- \[\]支持HTTP传输
参考文献
许可证
麻省理工学院
