Mcporter zh

From L-LesterYu/OpenClaw-hot-skills-zh · View interactive version

Mcporter zh is an AI agent skill from the GitHub repository L-LesterYu/OpenClaw-hot-skills-zh. 使用 mcporter CLI 列出、配置、认证和调用 MCP 服务器/工具(HTTP 或 stdio),包括临时服务器、配置编辑和 CLI/类型生成。

How to use this skill

Skill file

MCPorter 技能 🧳

MCPorter 是 TypeScript 运行时、CLI 和代码生成工具包,专为 Model Context Protocol (MCP) 设计。帮助您发现系统中已配置的 MCP 服务器,直接调用它们,在 TypeScript 中组合更丰富的自动化,并在需要共享工具时创建单一用途的 CLI。

核心能力

快速开始

MCPorter 自动发现您已在 Cursor、Claude Code/Desktop、Codex 或本地覆盖中配置的 MCP 服务器。您可以立即使用 npx 尝试——无需安装。

调用语法选项

# 冒号分隔的标志(shell 友好)
npx mcporter call linear.create_comment issueId:ENG-123 body:'看起来不错!'

# 函数调用风格(匹配 `mcporter list` 的签名)
npx mcporter call 'linear.create_comment(issueId: "ENG-123", body: "看起来不错!")'

常用命令

列出 MCP 服务器

# 列出所有已配置的服务器
npx mcporter list

# 列出特定服务器的详细信息(包含 schema)
npx mcporter list context7 --schema

# 列出远程 MCP 服务器的所有工具
npx mcporter list https://mcp.linear.app/mcp --all-parameters

# 列出临时 stdio 服务器
npx mcporter list --stdio "bun run ./local-server.ts" --env TOKEN=xyz

调用工具

# 使用冒号语法调用工具
npx mcporter call linear.create_comment issueId:ENG-123 body:'评论内容'

# 使用函数调用语法
npx mcporter call 'linear.create_comment(issueId: "ENG-123", body: "评论内容")'

# 调用远程服务器
npx mcporter call https://mcp.linear.app/mcp linear.create_comment issueId:ENG-123 body:'评论'

配置管理

# 添加新服务器到配置
npx mcporter config add myserver --http-url https://example.com/mcp

# 编辑配置
npx mcporter config edit

# 查看配置
npx mcporter config show

认证

# 对需要 OAuth 的服务器进行认证
npx mcporter auth https://mcp.linear.app/mcp

# 查看认证状态
npx mcporter auth status

代码生成

# 生成 TypeScript 类型定义
npx mcporter emit-ts linear --output ./types

# 生成 CLI
npx mcporter generate-cli linear --output ./my-linear-cli

使用场景

高级功能

临时服务器

可以连接到任何 MCP 端点而无需修改配置:

# HTTP 服务器
npx mcporter list https://example.com/mcp

# Stdio 服务器
npx mcporter list --stdio "node ./server.js" --env API_KEY=xyz

# 持久化临时服务器
npx mcporter list https://example.com/mcp --persist --name myserver

JSON 输出

大多数命令支持 --json 标志以获得结构化输出:

# JSON 格式列出服务器
npx mcporter list --json

# 使用 jq 过滤
npx mcporter list --json | jq '.[] | select(.name == "linear")'

详细输出

使用 --verbose 查看详细的配置源信息:

npx mcporter list --verbose

安装

虽然可以使用 npx 直接运行,但也可以全局安装:

# 使用 npm
npm install -g mcporter

# 使用 pnpm
pnpm add -g mcporter

# 使用 bun
bun install -g mcporter

配置文件位置

MCPorter 会按以下顺序查找配置文件:

  1. ~/.mcporter/mcporter.json 或 ~/.mcporter/mcporter.jsonc(主目录配置)
  2. config/mcporter.json(项目配置)
  3. 自动导入 Cursor、Claude、Codex、Windsurf、OpenCode、VS Code 的配置

环境变量

支持在配置中使用环境变量占位符:

{
  "servers": {
    "myserver": {
      "url": "https://api.example.com/mcp",
      "headers": {
        "Authorization": "Bearer ${API_KEY}"
      }
    }
  }
}

提示

常见问题

Q: 如何查看某个服务器的所有可用工具?

npx mcporter list <server-name> --schema

Q: 如何调用需要认证的服务器?

npx mcporter auth <server-url>
npx mcporter call <server-name>.<tool-name> <args>

Q: 如何在脚本中使用?

# 使用 --json 获取结构化输出
result=$(npx mcporter call mytool param1:value1 --json)
echo "$result" | jq '.data'

文档

许可证

MIT License

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.