MCP服务器管理器

Smithery CLI是一个用于安装和管理Model Context Protocol (MCP)服务器的工具,支持多种AI客户端。

  • by waldzellai
  • TypeScript
  • 本地部署
  • 更新于
在 GitHub 查看 waldzellai/smithery-cli

使用说明

Smithery CLI

模型上下文协议(MCP)服务器的Smithery注册表安装程序和管理器,设计为与客户端无关。

需求

  • NodeJS版本18或以上

用法

npx @smithery/cli <command>

可用命令

  • install <package> -安装软件包
    • --client <name> -指定AI客户端
    • --config <json> -以JSON格式提供配置数据(跳过提示)
  • uninstall <package> -卸载软件包
    • --client <name> -指定AI客户端
  • inspect <server-id> -交互式检查服务器
  • run <server-id> -运行服务器
    • --config <json> -为服务器提供配置
  • list clients -列出可用客户端
  • list servers --client <name> -列出特定AI客户端的已安装服务器
  • login -使用API密钥登录(交互式)
  • dev [entryFile] -使用热重载和隧道启动开发服务器
    • --port <port> -运行服务器的端口(默认值:8181)
    • --key <apikey> -提供API密钥
    • --no-open -不要自动打开操场
    • --prompt <prompt> -开始游乐场的初始信息
    • -c, --config <path> -配置文件的路径(默认:自动检测smithery.config.js)
  • build [entryFile] -为生产构建MCP服务器
    • -o, --out <outfile> -输出文件路径(默认:.smithery/index.cjs)
    • --transport <type> -传输类型:shtp或stdio(默认:shtp)
    • -c, --config <path> -配置文件的路径(默认:自动检测smithery.config.js)
  • playground -在浏览器中打开MCP游乐场
    • --port <port> -要公开的端口(默认值:3000)
    • --key <apikey> -提供API密钥
    • 可以在之后传递命令 -- 分隔符
  • --help -显示帮助消息
  • --verbose -显示调试的详细日志

例子

# Install a server (requires --client flag)
npx @smithery/cli install mcp-obsidian --client claude

# Install a server with pre-configured data (skips prompts)
npx @smithery/cli install mcp-obsidian --client claude --config '{"vaultPath":"path/to/vault"}'

# Remove a server
npx @smithery/cli uninstall mcp-obsidian --client claude

# List available clients
npx @smithery/cli list clients

# List installed servers for claude
npx @smithery/cli list servers --client claude

# Inspect a specific server from smithery's registry
npx @smithery/cli inspect mcp-obsidian

# Run a server with configuration
npx @smithery/cli run mcp-obsidian --config '{"key":"value"}'

# Login and set API key
npx @smithery/cli login

# Start development server with hot-reload
npx @smithery/cli dev
npx @smithery/cli dev server.ts --port 3000

# Build server for production
npx @smithery/cli build
npx @smithery/cli build server.ts --out dist/server.cjs --transport stdio

# Open playground in browser
npx @smithery/cli playground
npx @smithery/cli playground --port 3001 -- node dist/server.js

# Show help menu
npx @smithery/cli --help

# Install with verbose logging for debugging
npx @smithery/cli install mcp-obsidian --client claude --verbose

重要提示

  • 使用 login 用于设置Smithery API密钥的命令(某些操作需要)
  • 安装或卸载服务器后,记得重新启动AI客户端
  • 使用 inspect 交互式服务器测试命令
  • 无参数运行以查看帮助菜单
  • 使用 --verbose 故障排除时用于详细日志的标记
  • 这 dev 命令为MCP服务器开发提供热重载
  • 使用 playground 在交互式web界面中测试MCP服务器

发展

本指南将帮助您开始为@smithery/cli进行开发。

入门指南

  1. 克隆存储库:

    git clone https://github.com/smithery-ai/cli
    cd cli
    
  2. 安装依赖项:

    npm install
    
  3. 构建项目:

    npm run build
    

开发命令

# List all servers
npx . list servers

# Inspect a specific server
npx . inspect <server-id>

# Install a server
npx . install <server-name> --client <client-name>

# Run with verbose logging
npx . <command> --verbose

贡献

欢迎投稿!请随时提交拉取请求。