mcp-scripts

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

MCP Script Rules

MCP 脚本规则

When working with files in
scripts/
:
scripts/
目录下处理文件时:

DO

应当遵循

  • Use CLI arguments for all parameters (argparse)
  • Include USAGE docstring at top of file
  • Use
    call_mcp_tool("server__tool", params)
    pattern
  • Handle errors gracefully with informative messages
  • Print results to stdout for Claude to process
  • 为所有参数使用CLI参数(argparse)
  • 在文件顶部包含USAGE文档字符串
  • 使用
    call_mcp_tool("server__tool", params)
    格式
  • 优雅地处理错误并给出信息丰富的提示
  • 将结果打印到stdout以便Claude处理

DON'T

禁止事项

  • Hardcode parameters in the script
  • Edit scripts to change parameters (use CLI args instead)
  • Import from servers/ directly (use runtime.mcp_client)
  • 在脚本中硬编码参数
  • 通过编辑脚本修改参数(改用CLI参数)
  • 直接从servers/导入(使用runtime.mcp_client)

Tool Naming

工具命名

Tool IDs use double underscore:
serverName__toolName
Examples:
  • morph__warpgrep_codebase_search
  • ast-grep__ast_grep
  • perplexity__perplexity_ask
工具ID使用双下划线:
serverName__toolName
示例:
  • morph__warpgrep_codebase_search
  • ast-grep__ast_grep
  • perplexity__perplexity_ask

Testing

测试

Test with:
uv run python -m runtime.harness scripts/<script>.py --help
使用以下命令测试:
uv run python -m runtime.harness scripts/<script>.py --help