关于 smithery-ai-cookbook-ts-smithery-cli
这是一个使用官方 MCP TypeScript SDK 与 @smithery/cli 构建的简单 MCP 服务示例。它面向希望在 Smithery 上托管可流式 HTTP 服务的开发者,同时保留 STDIO 支持以兼容旧环境。
主要功能
- 01基于 @smithery/cli 编译服务并启动交互式 playground
- 02处理通过 Smithery 传入的会话配置
- 03通过 TRANSPORT 环境变量切换 STDIO 与 HTTP 传输
- 04包含 smithery.yaml 部署配置
适用场景
- 01学习如何在 Smithery 上部署 TypeScript MCP 服务
- 02在本地以 HTTP 模式开发并用 playground 测试工具
- 03以 STDIO 模式运行服务以兼容现有客户端
MCP 相关
该项目是一个 MCP 服务,通过 src/index.ts 暴露 MCP 工具,并处理来自 Smithery 的会话配置。
配置
远程服务无需本地安装。选择你使用的客户端,复制配置或使用一键安装。
服务地址
https://server.smithery.ai/@smithery-ai/cookbook-ts-smithery-cli/mcp一键复制安装命令
Claude CodeTerminal
claude mcp add --transport http ai-smithery-smithery-ai-cookbook-ts-smithery-cli https://server.smithery.ai/@smithery-ai/cookbook-ts-smithery-cli/mcpCursor.cursor/mcp.json
{"mcpServers":{"ai-smithery-smithery-ai-cookbook-ts-smithery-cli":{"type":"http","url":"https://server.smithery.ai/@smithery-ai/cookbook-ts-smithery-cli/mcp"}}}在 Cursor 中打开VS Code.vscode/mcp.json
{"servers":{"ai-smithery-smithery-ai-cookbook-ts-smithery-cli":{"type":"http","url":"https://server.smithery.ai/@smithery-ai/cookbook-ts-smithery-cli/mcp"}}}在 VS Code 中打开Claude Desktopclaude_desktop_config.json
{"mcpServers":{"ai-smithery-smithery-ai-cookbook-ts-smithery-cli":{"type":"http","url":"https://server.smithery.ai/@smithery-ai/cookbook-ts-smithery-cli/mcp"}}}Windsurf~/.codeium/windsurf/mcp_config.json
{"mcpServers":{"ai-smithery-smithery-ai-cookbook-ts-smithery-cli":{"serverUrl":"https://server.smithery.ai/@smithery-ai/cookbook-ts-smithery-cli/mcp"}}}命令在终端中运行;JSON 粘贴到对应客户端的 MCP 配置后重启。需要授权的服务会在首次连接时提示登录。
全部服务地址
Streamable HTTP
https://server.smithery.ai/@smithery-ai/cookbook-ts-smithery-cli/mcp需要授权工具
详细介绍
使用 Smithery CLI 的 TypeScript MCP 服务
一个使用官方 MCP TypeScript SDK 和 smithery/cli 构建的简单 TypeScript MCP 服务。本示例展示了如何使用 smithery/cli 在 Smithery 上托管可流式传输的 HTTP 服务,同时支持 STDIO,以保持向后兼容。
查看完整指南:https://smithery.ai/docs/migrations/typescript-with-smithery-cli
功能:
- Smithery CLI:使用
@smithery/cli编译服务并启动交互式 Playground - Smithery 会话配置:处理通过 Smithery 传入的用户会话配置
- HTTP 传输:可通过 TRANSPORT 环境变量使用 STDIO 和 HTTP 传输
先决条件
- Node.js 22 或更高版本
- npm 包管理器
项目结构
src/index.ts- 包含 MCP 工具和会话配置的主服务实现package.json- Node.js 依赖项和脚本smithery.yaml- Smithery 部署配置
快速开始
-
安装依赖项:
npm install -
运行开发服务:
HTTP 模式(自动启动 Smithery Playground,以便进行交互式测试):
npm run dev
可选 - STDIO 模式: 如果你更希望以 STDIO 模式运行,可以使用:
API_KEY=your-api-key npm run start:stdio -
部署你自己的版本: 要部署你自己的 MCP 服务:
- 在 https://smithery.ai/new 连接你的代码仓库
评论
支持 Markdown
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。