Main
把 MCP 调用当 API:把工具调用封装成类型化函数,让 agent/app 逻辑保持清晰。
原型阶段先用 CLI;接口稳定后再改为库方式集成,减少脚本漂移。
把传输层抽离:统一 MCP provider 的连接方式,降低环境切换成本。
用类型与示例固化工具契约:减少 agent 对参数的臆测与误填。
README (excerpt)
MCPorter 🧳 - Call MCPs from TypeScript or as CLI
TypeScript runtime, CLI, and code-generation toolkit for the Model Context Protocol.
MCPorter helps you lean into the "code execution" workflows highlighted in Anthropic's Code Execution with MCP guidance: discover the MCP servers already configured on your system, call them directly, compose richer automations in TypeScript, and mint single-purpose CLIs when you need to share a tool. All of that works out of the box -- no boilerplate, no schema spelunking.
Key Capabilities
- Zero-config discovery.
createRuntime()merges your home config (~/.mcporter/mcporter.json[c], or$XDG_CONFIG_HOME/mcporter/mcporter.json[c]when set) first, thenconfig/mcporter.json, plus Cursor/Claude/Codex/Windsurf/OpenCode/VS Code imports, expands${ENV}placeholders, and pools connections so you can reuse transports across multiple calls. - One-command CLI generation.
mcporter generate-cliturns any MCP server definition into a ready-to-run CLI, with optional bundling/compilation and metadata for easy regeneration. - Typed tool clients.
mcporter emit-tsemits.d.tsinterfaces or ready-to-run client wrappers so agents/tests can call MCP servers with strong TypeScript types without hand-writing plumbing. - Friendly composable API.
createServerProxy()exposes tools as ergonomic camelCase methods, automatically applies JSON-schema defaults, validates required arguments, and hands back aCallResultwith.text(),.markdown(),.json(),.images(), and.content()helpers.
Source-backed notes
- README 给出安装方式:
pnpm add mcporter、npm install -g mcporter,以及 Homebrew tap。 - GitHub topics 包含
mcp与cli(已通过 GitHub API 复核)。 - 仓库为 MIT 许可且近期更新(已通过 GitHub API 复核)。
FAQ
- 有 CLI 吗?:有:README 提供
npm install -g mcporter,并可用mcporter --help查看用法。 - 必须用 TypeScript 吗?:不必须:CLI 只要有 Node.js 就能用;但库的最佳体验在 TypeScript。
- 许可证是什么?:MIT(已通过 GitHub 许可证元数据复核)。