
mcporter
MCPorter是一个基于TypeScript的运行时环境、命令行界面和代码生成工具包,专门为模型上下文协议(MCP)设计。通过零配置发现功能,您可以轻松发现、调用任何MCP服务器,并将其转化为独立的命令行界面或类型化API。
概述
mcporter (MCPorter 🧳) 是一个用于 模型上下文协议 (MCP) 的开源 TypeScript 运行时、CLI 和代码生成工具包。它让开发者和 AI 智能体能够发现已配置的 MCP 服务器、直接调用工具、在 TypeScript 中组合自动化流程,并从任何 MCP 端点生成单一用途的 CLI。
该项目为支持 Anthropic 的“使用 MCP 进行代码执行”指南而构建,通过让 AI 智能体通过轻量级的 CLI 二进制文件调用工具,而不是加载庞大的 JSON 模式,从而消除了样板代码并减少了上下文窗口膨胀。
最新版本:0.8.2 (2026年3月)。采用 MIT 许可证。
特性
- 零配置发现: 自动从
~/.mcporter/mcporter.json、项目配置以及与 Claude、Cursor、Codex、VS Code、Windsurf 和 OpenCode 的集成中发现 MCP 服务器。 - CLI 优先工具调用: 使用自然语法 (
mcporter call linear.create_comment ...) 或函数调用风格运行工具 —— 无需了解模式。 - 一键 CLI 生成:
mcporter generate-cli从任何 MCP 服务器创建独立的、自包含的 CLI (Bun/Node),便于共享和智能体使用。 - 类型化 TypeScript API:
mcporter emit-ts生成带有强类型、默认值和验证的.d.ts接口或完整的客户端包装器。 - 可组合运行时:
createRuntime()+createServerProxy()提供连接池、OAuth 缓存、日志跟踪以及对 HTTP/SSE/stdio 传输的支持。 - 临时与守护进程模式: 即时连接到任何 MCP 端点;通过守护进程命令保持有状态服务器(例如 chrome-devtools)的热状态。
- AI 智能体友好: 减少上下文膨胀 —— 智能体调用一个小型 CLI 二进制文件,而不是嵌入完整的 MCP 模式。
- 健壮的工具集: 自动更正、丰富的输出格式化 (
text(),json())、配置管理和调试助手。
使用场景
- AI 智能体工具集成: 让 Claude/Cursor 通过生成的 CLI 调用复杂的 MCP 服务器,而不会导致上下文窗口爆炸。
- 快速自动化脚本编写: 构建组合多个 MCP 工具并具备完整类型安全性的 TypeScript 工作流。
- 工具共享: 为团队或公共使用生成并分发单一用途的 CLI(例如
linear-comment)。 - 开发与调试: 在原型设计期间即时检查任何 MCP 服务器模式或临时调用工具。
- 减少 MCP 膨胀: 用轻量级的 CLI 调用替代编辑器/智能体中的沉重模式加载。
安装与快速开始
即时运行(无需安装)
npx mcporter list
npx mcporter list linear --schema
全局安装
npm install -g mcporter
# 或使用 Homebrew
brew tap steipete/tap && brew install steipete/tap/mcporter
调用示例
# 冒号语法
mcporter call linear.create_comment issueId:ENG-123 body:'Looks good!'
# 函数调用语法
mcporter call 'linear.create_comment(issueId: "ENG-123", body: "Looks good!")'
生成 CLI
mcporter generate-cli --command https://mcp.context7.com/mcp
### TypeScript 使用示例
```ts
import { createRuntime } from "mcporter";
const runtime = await createRuntime();
const result = await runtime.callTool("context7", "resolve-library-id", {
args: { libraryName: "react" }
});
console.log(result.text());
await runtime.close();
完整文档、CLI 参考及示例均在 代码仓库 中。
为何选择 mcporter?
MCP 通过工具为 AI 代理赋予了超能力,但管理模式和连接配置却颇为繁琐。mcporter 让 MCP 变得高效易用——一次发现,即时调用,为代理生成 CLI,并编写简洁的类型化代码。它是终极的 MCP 瑞士军刀。
相关链接
- GitHub: steipete/mcporter
- 官网: mcporter.dev
- CLI 参考与文档: github.com/steipete/mcporter/tree/main/docs
作为任何基于 MCP 的 AI 工作流的完美伴侣。
Tags
Related Entries
Keep exploring similar tools and resources in this category.

LobeHub
Tools & ExtensionsLobeHub is a modern AI agent platform and marketplace for discovering, building, and collaborating with intelligent agent teammates. It features native Model Context Protocol (MCP) integration and the world's largest curated MCP Servers Marketplace with tens of thousands of ready-to-use integrations.
Related Reads
Background, tutorials, and protocol context connected to this entry.



