@executor-js/mcporter

中文文档
0.11.4发布于 2026/06/10MITTypeScriptES Module近 30 天下载 1.1万

TypeScript 运行时间和CLI用于连接到已配置的上下文协议模型服务器.

中文使用文档
文档目录28 节
  1. 密钥能力
  2. 0.11.0中有什么新鲜事
  3. 快速启动
  4. 调用语法选项
  5. 列出您的 MCP 服务器
  6. 背景7: 获取文件( 不需要认证)
  7. 线性:搜索文档(要求) LINEAR_API_KEY (中文(简体) )
  8. Chrome DevTools: 抓取当前标签
  9. 尝试不编辑配置的 MCP
  10. 让 MCP 服务器与守护进程同步
  11. 朋友工具调用
  12. 安装
  13. 随即运行 npx
  14. 添加到您的工程中
  15. 用 npm 在全球安装
  16. 土生土长(梯/塔普)
  17. 密码的一发电话
  18. 用运行时间编译自动化
  19. 在代码中编写工具
  20. 生成独立的 CLI
  21. 生成类型客户端
  22. 配置参考
  23. 管理配置 mcporter config
  24. 工具过滤
  25. 测试和测试
  26. 相关
  27. 调试挂起服务器快速
  28. 许可证

MCPorter QQ - 从类型脚本中调用 MCP 或者作为 CLI

MCPorter header banner

npm version CI Status Platforms MIT License

TypeScript 运行时间, CLI, 和代码生成工具箱用于模型背景协议.

MCPorter 帮助您切入 Anthropic 中突出显示的“代码执行”工作流程 用 MCP 执行代码 引导 : 发现您系统中已经配置的 MCP 服务器, 直接调用它们, 在 TypeScript 中编译更丰富的自动化, 在您需要共享工具时编译薄荷单目的 CLI 。 所有这些都用在盒子里-- 没有锅炉板,没有计划.

密钥能力

  • 零相克发现. createRuntime() 合并您的家配置( n)~/.mcporter/mcporter.json[c],或 $XDG_CONFIG_HOME/mcporter/mcporter.json[c] 当设定)首先,然后 config/mcporter.json,加上光标/光标/Codex/Windsurf/OpenCode/VS 代码导入, 扩展 ${ENV} 占位符,和集合连接,这样您就可以重复使用多个调用.
  • 单指令CLI一代. mcporter generate-cli 将任何 MCP 服务器定义变成一个随时运行的 CLI, 并带有可选的捆绑/汇编和元数据, 以便于再生 .
  • 已打入工具客户端 . mcporter emit-ts 发射 .d.ts 接口或随时运行的客户端包装器,因此代理/测试可以使用强大的TypeScript类型调用MCP服务器,而无需手写管道.
  • 友好相容API. createServerProxy() 将工具暴露为工程学骆驼Case方法,自动应用 JSON-schema 默认,验证所需的参数,手背a CallResult 与 .text(), (中文(简体) ), .markdown(), (中文(简体) ), .json(), (中文(简体) ), .images(),以及 .content() 帮手.
  • 记录/重放固定装置. mcporter record 捕捉MCP JSON-RPC交通作为NDJSON,并且 mcporter replay 用于离线调试和已编辑的重排的相同响应.
  • OAuth和stdio ergonomics. 中国植物物种信息数据库. 所建的OAuth缓存,日志尾随,和stdio 包装器让你与HTTP,SSE,以及从同一个界面出动的stdio 传输工作.
  • 相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相相接相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相. 点出CLI 任意 MCP端点(HTTP或stdio)不触摸配置,如果需要,则在后期再坚持. 需要浏览器登录的托管MCP( Supabase, Vercel等) 是自动检测的 - 只需运行 mcporter auth <url> 而CLI则在苍蝇上向OAuth推广定义. 见 文档/adhoc.md。 。 。 .

0.11.0中有什么新鲜事

  • 桥模式. mcporter serve 曝光守护进程管理的保存式服务器为可读的 MCP 桥 server__tool 名称.
  • 无头乌头. --no-browser保险箱种子,缓存的托肯新鲜,和 auth: "refreshable_bearer" 包括非交互式部署.
  • HTTP 兼容性 . httpFetch: "node-http1" 保留拒绝节点内置的提供者 fetch 工作时.
  • 写作更安全. Cifig, OAuth 保险库, JSON 输出, 和缓存元数据写入是序列化的/ 原子化的, 所以并行代理停止相踩.
  • 释出信心. 0.11.0 在npm和Homebrew上发布,现场/发布的安装烟雾为绿色.

快速启动

MCPorter 自动发现您已经在 Cursor, Claude Code/Desktop, Codex 或本地覆盖中配置的 MCP 服务器 。 你可以马上试试 npx- 无需安装。 需要完整命令引用( 旗帜、 模式、 返回类型) 吗 ? 检查出来 文献/文献参考。 。 。 .

调用语法选项

# Colon-delimited flags (shell-friendly)
npx mcporter call linear.create_comment issueId:ENG-123 body:'Looks good!'

# Function-call style (matches signatures from `mcporter list`)
npx mcporter call 'linear.create_comment(issueId: "ENG-123", body: "Looks good!")'

# Literal positional values that start with `--`
npx mcporter call server.tool -- --raw-value

列出您的 MCP 服务器

npx mcporter list
npx mcporter list context7 --schema
npx mcporter list https://mcp.linear.app/mcp --all-parameters
npx mcporter list shadcn.io/api/mcp.getComponents           # URL + tool suffix auto-resolves
npx mcporter list --stdio "bun run ./local-server.ts" --env TOKEN=xyz
  • 添加 --json 发布机器可读摘要,并附有每个服务器的状况(自动/离线/http/error计数),对于单服务器运行,则提供完整的工具计划有效载荷.
  • 添加 --status 简洁的单服务器状态检查,没有工具文件, --exit-code 当检查过的服务器不健康时失败,或 --quiet 为了无声的健康之门.
  • 添加 --verbose ,以文本和 JSON 列表输出来显示所有注册服务器名称(主名第一)的配置源.

你现在可以指点了 mcporter list 在临时服务器上: 直接提供 URL 或使用新的 --http-url/--stdio 旗帜(加) --env, (中文(简体) ), --cwd, (中文(简体) ), --name,或 --persist)来描述任何MCP端点。 在您坚持此定义之前, 您仍需要重现相同的 URL/ stdio 标记 mcporter call– 打印的 sattle 只有在您将其合并成一个配置后才会成为可重复使用 --persist 或者说 mcporter config add (使用时 --scope home|project 选择写目标。 后续行动 mcporter auth https://… (或同名旗下设定)无需编辑配置即可完成OAuth. 详细情况见 文档/adhoc.md。 。 。 .

单服务器列表现在读取为 TypeScript 头文件, 这样您就可以直接复制/复制签名到 mcporter call数字 :

linear - Hosted Linear MCP; exposes issue search, create, and workflow tooling.
  23 tools · 1654ms · HTTP https://mcp.linear.app/mcp

  /**
   * Create a comment on a specific Linear issue
   * @param issueId The issue ID
   * @param body The content of the comment as Markdown
   * @param parentId? A parent comment ID to reply to
   */
  function create_comment(issueId: string, body: string, parentId?: string);
  // optional (3): notifySubscribers, labelIds, mentionIds

  /**
   * List documents in the user's Linear workspace
   * @param query? An optional search query
   * @param projectId? Filter by project ID
   */
  function list_documents(query?: string, projectId?: string);
  // optional (11): limit, before, after, orderBy, initiativeId, ...

当你跑步时 npx mcporter list vercel数字 :

vercel - Vercel MCP (requires OAuth).

  /**
   * Search the Vercel documentation.
   * Use this tool to answer any questions about Vercel’s platform, features, and best practices,
   * including:
   * - Core Concepts: Projects, Deployments, Git Integration, Preview Deployments, Environments
   * - Frontend & Frameworks: Next.js, SvelteKit, Nuxt, Astro, Remix, frameworks configuration and
   *   optimization
   * - APIs: REST API, Vercel SDK, Build Output API
   * - Compute: Fluid Compute, Functions, Routing Middleware, Cron Jobs, OG Image Generation, Sandbox,
   *   Data Cache
   * - AI: Vercel AI SDK, AI Gateway, MCP, v0
   * - Performance & Delivery: Edge Network, Caching, CDN, Image Optimization, Headers, Redirects,
   *   Rewrites
   * - Pricing: Plans, Spend Management, Billing
   * - Security: Audit Logs, Firewall, Bot Management, BotID, OIDC, RBAC, Secure Compute, 2FA
   * - Storage: Blog, Edge Config
   *
   * @param topic Topic to focus the documentation search on (e.g., 'routing', 'data-fetching').
   * @param tokens? Maximum number of tokens to include in the result. Default is 2500.
   */
  function search_vercel_documentation(topic: string, tokens?: number);

  /**
   * Deploy the current project to Vercel
   */
  function deploy_to_vercel();

需要的参数总是显示;可选参数保持不变,除非(a) 其中只有一两个参数与要求的字段相邻不足4个或(b) 您通过 --all-parameters。每当 MCPorter 隐藏参数时,它会打印 Optional parameters hidden; run with --all-parameters to view all fields. 所以,你知道如何揭示 完整的签名。 返回类型从工具计划推断 title,倒回去去省略后缀 完全而不是猜测.

背景7: 获取文件( 不需要认证)

npx mcporter call context7.resolve-library-id query="React hooks docs" libraryName=react
npx mcporter call context7.query-docs libraryId=/reactjs/react.dev query="useEffect cleanup"

线性:搜索文档(要求) LINEAR_API_KEY(中文(简体) )

LINEAR_API_KEY=sk_linear_example npx mcporter call linear.search_documentation query="automations"

Chrome DevTools: 抓取当前标签

npx mcporter call chrome-devtools.take_snapshot
npx mcporter call 'linear.create_comment(issueId: "LNR-123", body: "Hello world")'
npx mcporter call https://mcp.linear.app/mcp.list_issues assignee=me
npx mcporter call shadcn.io/api/mcp.getComponent component=vortex   # protocol optional; defaults to https
npx mcporter call linear.listIssues --tool listIssues   # auto-corrects to list_issues
npx mcporter linear.list_issues                         # shorthand: infers `call`
VERCEL_ACCESS_TOKEN=sk_vercel_example npx mcporter call "npx -y vercel-domains-mcp" domain=answeroverflow.com  # quoted stdio cmd + single-tool inference

工具调用理解了类似JavaScript的调用语法,自动校正了近误用工具名,并释放出更丰富的内线用提示. 见 文件/调用语法.md 语法和 文献/呼叫-huristic.md 自动更正规则.

帮助旗:

  • --config <path> -- 自定义配置文件(默认为 ./config/mcporter.json) (中文(简体) ).
  • --root <path> -- stdio 命令的工作目录.
  • --log-level <debug|info|warn|error> - 调整动词(尊重) MCPORTER_LOG_LEVEL) (中文(简体) ).
  • --oauth-timeout <ms> -- 缩短/扩展 OAuth 浏览器等; 与 MCPORTER_OAUTH_TIMEOUT_MS 编号 : MCPORTER_OAUTH_TIMEOUT。 。 。 .
  • --tail-log -- 流出工具响应所引用的任何日志文件的最后20行.
  • --output <format> 或者说 --raw -- 控制格式化输出( 默认为漂亮打印的自动检测) .
  • --save-images <dir> 联 合 国 mcporter call) --将MCP图像内容块保存到给定目录中的文件(opt-in;stdout输出形状保持不变).
  • --raw-strings 联 合 国 mcporter call) -- 保持数字外观参数值(用于 key=value, (中文(简体) ), key:value作为字符串.
  • --no-coerce 联 合 国 mcporter call) -- 保留所有 key=value 和作为原始字符串的定位值(bul/null/数字/JSON强制).
  • -- 联 合 国 mcporter call) - 停止旗帜解析, 使所剩的符号保持字面位置值, 即使从它们开始 --。 。 。 .
  • --json 联 合 国 mcporter list) -- 发出JSON摘要/计数而不是正文. 多服务器运行报告每服务器状态,计数,和连接问题;单服务器运行包含完整的工具元数据.
  • --status, (中文(简体) ), --exit-code, (中文(简体) ), --quiet 联 合 国 mcporter list通过现有的列表流程进行简洁的服务器健康检查; --quiet 如果检查有不健康的情况, 则停止输出和出口 1 .
  • --output json/raw 联 合 国 mcporter call) - 当连接失败时, MCPorter 打印出通常的彩色提示并同时发出结构化 { server, tool, issue } 信封 这样脚本就可以在程序上处理 auth/offline/http 错误.
  • --json 联 合 国 mcporter auth) -- 当 OAuth/ Transport 设置失败时, 发出相同的结构化连接信封, 而不是丢出错误 。 与 --no-browser它发出授权启动 JSON 包含 authorizationUrl 财务报告和审定财务报表 redirectUrl。 。 。 .
  • --no-browser 编号 : --browser none 联 合 国 mcporter auth 或者说 mcporter config login-- 压制浏览器的启动并打印无头工作流程的 OAuth 授权 URL; MCPORTER_OAUTH_NO_BROWSER=1 编号 : true 编号 : yes 允许同样的行为.
  • --json 联 合 国 mcporter emit-ts) - 打印一个 JSON 摘要,描述已发射的文件( 模式 + 输出路径) , 而不是文本日志 - 在生成脚本中的文物时手动 .
  • --all-parameters -- 在列出服务器时显示每个 schema 字段( 默认输出显示至少5个参数并附加其他参数摘要) .
  • --http-url <https://…> 编号 : --stdio "command …" -- 描述一个临时的 MCP 服务器内置. STDIO 正在自动继承您的当前 shell 环境; 添加 --env KEY=value 仅在需要同时注入/覆盖变量时 --cwd, (中文(简体) ), --name,或 --persist <config.json>。这些旗帜现在与 mcporter auth 也一样 mcporter auth https://mcp.example.com/mcp 刚刚工作.
  • 对 OAuth 保护的服务器, 如 vercel运行 npx mcporter auth vercel 一次完成登录.

提示:你可以完全跳过动词..mcporter firecrawl 自动运行 mcporter list firecrawl和点缀像 mcporter linear.list_issues 发送到呼叫命令(包含typo修正).

超时默认为 30 s; 覆盖到 MCPORTER_LIST_TIMEOUT 或者说 MCPORTER_CALL_TIMEOUT 当你期待慢起步。 OAuth 浏览器握手获得单独的5分钟宽限期;通过 --oauth-timeout <ms> (或出口) MCPORTER_OAUTH_TIMEOUT_MS当你需要CLI 更快的保释 当你诊断 顽固的认证流.

尝试不编辑配置的 MCP

# Point at an HTTPS MCP server directly
npx mcporter list --http-url https://mcp.linear.app/mcp --name linear

# Run a local stdio MCP server via Bun
npx mcporter call --stdio "bun run ./local-server.ts" --name local-tools
  • 添加 --persist config/mcporter.local.json 以保存对未来运行的推断定义.
  • 使用 --allow-http 如果你真的需要打一个清晰的结尾.
  • 见 文档/adhoc.md 以便进行深潜.

让 MCP 服务器与守护进程同步

  • chrome-devtools, (中文(简体) ), mobile-mcp,而其他状态的 stdio 服务器在您第一次称它们为每个日志守护进程时,会自动启动一个每个日志守护进程,所以 Chrome 标签和设备会话在代理之间保持活性.
  • 使用 mcporter daemon status 检查守护进程是否在运行(以及哪些服务器已连接).
  • 随时停止 mcporter daemon stop,加热前 mcporter daemon start,或者通过 mcporter daemon restart 在调整配置/env后.
  • 所有其他服务器保持平面; 添加 "lifecycle": "keep-alive" 到服务器条目(或设置) MCPORTER_KEEPALIVE=name当你想要守护进程管理它时。 您也可以设置 "lifecycle": "ephemeral" (或 MCPORTER_DISABLE_KEEPALIVE=name选择退出.
  • 守护进程只管理来自您的配置/ 导入的命名服务器 。 通过下列方式引用的 STDIO/HTTP目标 --stdio …, (中文(简体) ), --http-url …,或内置函数调用语法今天仍为每个进程 config/mcporter.json (或使用) --persist如果你需要他们参与共享守护进程.
  • mcporter serve --stdio 将每个守护进程管理的保存-活性服务器曝光为Claude Code或Codex等客户端的MCP stdio桥. 登记一次,然后调用命名空格工具 chrome-devtools__list_pages; 添加 --servers a,b 限制桥梁或 --http <port> 在本地主机 /mcpHTTP 模式也暴露了 /mcp/<server> 用于选择一个带有其原始的、无前缀的工具名称的保存式服务器.
  • 找麻烦? 运行 mcporter daemon start --log (或 --log-file /tmp/daemon.log将 stdout/stderr 插入文件,并添加 --log-servers chrome-devtools 您只需为特定的 MCP 调用痕迹 。 服务器配置也可以设置 "logging": { "daemon": { "enabled": true } } 强制详细记录 进入.

朋友工具调用

  • 函数调用语法. 而不是杂耍 --flag value,可以将工具称为 mcporter call 'linear.create_issue(title: "Bug", team: "ENG")'。解析器支持嵌入对象/阵列,允许您在想要依赖计划命令时省略标签(例如:. mcporter 'context7.resolve-library-id("React hooks docs", "react")'),并清晰地显示计划验证错误. 深度潜入 文件/调用语法.md。 。 。 .
  • 旗手还行. 更喜欢CLI式的论据? 坚持 mcporter linear.create_issue title=value team=value, (中文(简体) ), title=value, (中文(简体) ), title:value,或甚至 title: value——CLI现在将所有三种形式正常化.
  • 未知的长旗会很快失效 . mcporter call server.tool --source import 现在错误而不是静静地转动 --source 输入位置工具参数。 使用 source=import, (中文(简体) ), --args '{"source":"import"}',或插入 -- 在开始的文字位置值之前 --。 。 。 .
  • 骗局. 见 文件/工具调用 对每个支持的调用样式(自动插入动词、旗帜、函数调用和临时URL)进行快速比较.
  • 自动修正. 如果您打入工具名, MCPorter 会检查服务器的工具目录, 当编辑距离很小时重复, 否则打印一个 Did you mean …? 指点 热度(以及如何调谐)被俘获 文献/呼叫-huristic.md。 。 。 .
  • 更丰富的单服务器输出. mcporter list <server> 现在打印 TypeScript 风格的签名,内置注释,还原形状的提示,以及反映新调用语法的命令示例. 可选参数默认保存- 添加 --all-parameters 或者说 --schema 每当你需要 JSON 完整的计划。 想要更严格的扫描吗? mcporter list <server> --brief (或 --signatures仅保留紧凑的签名和可选摘要.

安装

随即运行 npx

npx mcporter list

添加到您的工程中

pnpm add mcporter

用 npm 在全球安装

npm install -g mcporter

土生土长(梯/塔普)

brew tap steipete/tap
brew install steipete/tap/mcporter

该水龙头出版与npm。 如果你遇到问题 安装了更古老的水龙头,运行 brew update 重新来过之前.

密码的一发电话

import { callOnce } from 'mcporter';

const result = await callOnce({
  server: 'firecrawl',
  toolName: 'crawl',
  args: { url: 'https://anthropic.com' },
});

console.log(result); // raw MCP envelope

callOnce 自动发现所选服务器(包括 Cursor/Claude/Codex/Windsurf/OpenCode/VS代码导入),处理OAuth提示,完成后关闭传输. 它对于手动运行或将MCPorter直接接入代理工具钩是理想的.

用运行时间编译自动化

import { createRuntime } from 'mcporter';

const runtime = await createRuntime();

const tools = await runtime.listTools('context7');
const result = await runtime.callTool('context7', 'resolve-library-id', {
  args: { query: 'React hooks docs', libraryName: 'react' },
});

console.log(result); // prints JSON/text automatically because the CLI pretty-prints by default
await runtime.close(); // shuts down transports and OAuth sessions

到达 createRuntime() 当您需要连接集、 重复呼叫, 或高级选项, 如明确超时和日志流 。 运行时间再利用 运输,刷新 OAuth 的标志, 并且只有在你打电话时,所有的东西都泪下 runtime.close()。 。 。 .

在代码中编写工具

运行时API是为代理和脚本而建,而不只是终端上的人类.

import { createRuntime, createServerProxy } from 'mcporter';

const runtime = await createRuntime();
const chrome = createServerProxy(runtime, 'chrome-devtools');
const linear = createServerProxy(runtime, 'linear');

const snapshot = await chrome.takeSnapshot();
console.log(snapshot.text());

const docs = await linear.searchDocumentation({
  query: 'automations',
  page: 0,
});
console.log(docs.json());

友好的人工智能被烤入代理和结果助手:

  • 从骆驼Case到kebab-case工具名的属性名称映射(takeSnapshot - > (中文) take_snapshot) (中文(简体) ).
  • 位置参数映射到 chema 所需的字段, 选项对象尊重 JSON- schema 默认值 .
  • 成果以 CallResult,所以你可以选择 .text(), (中文(简体) ), .markdown(), (中文(简体) ), .json(), (中文(简体) ), .images(), (中文(简体) ), .content(),或访问 .raw 当你需要完整的信封.

放下来 runtime.callTool() 当您需要明确控制参数、元数据或流出选项时.

打电话 mcporter list <server> 任何时候都需要TypeScript风格的签名,可选参数提示,以及符合 CLI 函数调用语法的样本引用. 添加 --brief 或者说 --signatures 仅需要紧凑签名.

生成独立的 CLI

将任何服务器定义转换为可共享的 CLI 文物 :

npx mcporter generate-cli \
  --command https://mcp.context7.com/mcp

# Outputs:
#   context7.ts        (TypeScript template with embedded schemas)
#   context7.js        (bundled CLI via Rolldown or Bun, depending on runtime)

通过这个奇怪的把戏,将铬脱氧核糖核酸MCP转换成CLI:

npx mcporter generate-cli --command "npx -y chrome-devtools-mcp@latest"

提示: 您可以放下 --command 当内置命令是第一个位置参数(例如, npx mcporter generate-cli "npx -y chrome-devtools-mcp@latest") (中文(简体) ).

  • --name 覆盖推断的 CLI 名称.
  • 添加 --description "..." 如果您想要在生成的帮助输出中有一个自定义摘要( 否则 mcporter 会在生成时向 MCP 服务器询问自己的描述/标题) .
  • 生成的 CLI 继承了相同的色彩感知帮助布局 mcporter 本身: 引用无参数的二进制, 显示嵌入式工具列表 + 快速启动, 每个 --help 页面使用粗体标题 + 当 stdout 是 TTY 时暗化描述.
  • 添加 --bundle [path] 将捆绑与模板并排出( 瞄准节点时滚动, 当运行时间决定给 Bun; 覆盖到 --bundler rolldown|bun) (中文(简体) ).
  • --output <path> 将模板写到特定的地方.
  • --runtime bun|node 选择生成代码的运行时间( Bun for --compile) (中文(简体) ).
  • 添加 --compile 释放 Bun 编译 二进制; MCPorter 省略时清理中间捆绑 --bundle。 。 。 .
  • 使用 --include-tools a,b,c 或者说 --exclude-tools a,b,c 为一组工具生成一个CLI(相互排斥).
  • 使用 --from <artifact> (可选择) --dry-run利用嵌入式元数据重新生成现有的CLI.
  • 如果服务器已经停留在您的配置/ 导入中, 请选择一个位置短手 : npx mcporter generate-cli linear --bundle dist/linear.js。 。 。 .
  • --server编号 :--command 接受 HTTP URL,可选 .tool 后缀,甚至无计划的主机(sshadcn.io/api/mcp.getComponents) (中文(简体) ).

每个文物都嵌入再生元数据(生成器版本,解析服务器定义,引用旗帜). 使用 :

npx mcporter inspect-cli dist/context7.js     # human-readable summary
npx mcporter generate-cli --from dist/context7.js  # replay with latest mcporter

代理通常每个 MCP 服务器或工作流程应获得一个小技能,而不是 一种通用的"所有Mcporter"技能. 见 医生/代理技能 用于图案和可复制模板.

生成类型客户端

使用 mcporter emit-ts 需要强烈的输入工具而不发送完整的 CLI 。 它重用与 mcporter list,因此生成的头像与CLI显示的内容保持同步.

# Types-only interface (Promise signatures)
npx mcporter emit-ts linear --out types/linear-tools.d.ts

# Client wrapper (creates a reusable proxy factory alongside the .d.ts)
npx mcporter emit-ts linear --mode client --out clients/linear.ts
  • --mode types (违约)产生 .d.ts 界面,您可以在任何地方导入.
  • --mode client 发射 .d.ts 财务报告和审定财务报表 (单位:千美元) .ts 包装的助手 createRuntime 编号 : createServerProxy 给你的.
  • 添加 --include-optional 当您想要拼出每个可选字段时( 缩写) mcporter list --all-parameters) (中文(简体) ).
  • 添加 --json 以发送结构化摘要(模式加输出路径),而不是脚本时的纯文本日志 emit-ts。 。 。 .
  • 这个 <server> 参数还理解 HTTP URL 和选择器 .tool 后缀或缺少协议——暗指主CLI.

见 文件/电子邮件 用于全旗引用加内含已释放文件的快照.

配置参考

管理此文件为 mcporter config list|get|add|remove|import 当你宁愿避免手写JSON时 文件/配置 完全通过. 配置文件解析为 JSONC, 所以内置 // 财务报告和审定财务报表 /* ... */ 注释加后缀 mcporter.json 财务报告和审定财务报表 mcporter.jsonc。 。 。 .

管理配置 mcporter config

运行 mcporter config … 当您想要交互查看项目MCP时, 通过您的软件包管理器( pnpm, npm, npx等) :

  • config list 显示 只有本地条目 默认,并在 TTYs 上打印出其他所有配置文件( Cursor, Claude, Windsurf, VS 代码等) 的摘要,其中包含计数和样本名称. 添加 --source import 直接检查这些进口条目或 --json 用于脚本.
  • config get/remove/logout 重用模糊匹配逻辑 mcporter list编号 :call,所以打字喜欢 sshadcn 自动更正为 shadcn (带有暗通知)和模棱两可的名称呈现出“你的意思是......?”.
  • config import <kind> --copy 将编辑器管理条目拖入 config/mcporter.json,让你在不接触上游文件的情况下自定义或删除它们.
  • 每个子命令的荣誉 --config <path> 编号 : --root <dir>,使多个工程配置或特定工作空间的覆盖很容易被拼接.

config/mcporter.json 镜克/克洛德的形状:

{
  "mcpServers": {
    "context7": {
      "description": "Context7 docs MCP",
      "baseUrl": "https://mcp.context7.com/mcp",
      "headers": {
        "Authorization": "$env:CONTEXT7_API_KEY",
      },
    },
    "chrome-devtools": {
      "command": "npx",
      "args": ["-y", "chrome-devtools-mcp@latest", "--autoConnect"],
      "env": { "npm_config_loglevel": "error" },
    },
  },
  "imports": ["cursor", "claude-code", "claude-desktop", "codex", "windsurf", "opencode", "vscode"],
}

MCPorter为你处理的是什么:

  • ${VAR}, (中文(简体) ), ${VAR:-fallback},以及 $env:VAR 配置字符串的插入。 隐秘 headers, (中文(简体) ), env不记名的占位者在运行时要保持懒惰和决心.
  • 共享金库中的自动 OAuth 令牌缓存( O)~/.mcporter/credentials.json,或 $XDG_DATA_HOME/mcporter/credentials.json 设定时),除非您超越 tokenCacheDir。 。 。 .
  • Stdio命令继承了定义它们的文件的目录(导入或本地配置).
  • 导入优先级与数组顺序相匹配; 省略 imports 要使用默认值 ["cursor", "claude-code", "claude-desktop", "codex", "windsurf", "opencode", "vscode"]。 。 。 .
  • chrome-devtools-mcp --autoConnect 在上游自动连接可挂起繁忙的Chrome配置文件时, 接收一个小的相容补丁; 设置 MCPORTER_DISABLE_CHROME_DEVTOOLS_COMPAT=1 选择退出.

OAuth 保护服务器

如果一个 HTTP MCP 需要浏览器登录( OAuth), 请坚持使用 --auth oauth (或设置) "auth": "oauth" 在 JSON 中,然后运行 mcporter auth 一次:

npx mcporter config add notion https://mcp.notion.com/mcp --auth oauth
npx mcporter auth notion

在无头主机上使用 npx mcporter auth notion --no-browser 以打印授权 URL,而不是启动平台浏览器。 将打印的 URL 视为敏感的操作输出 。 留着 mcporter auth 在浏览器重定向到打印前, 进程为活性 redirectUrl;在抓取stdout后退出或清理命令的处理管理器,可以在OAuth完成前杀死回回调的收听器. 运行一个持久终端会话中的命令, tmux,或受监督的背景过程,例如: nohup,如果您在另一台机器上打开 URL,请确保只通过回路通道或配置的通道可以到达回路端口 oauthRedirectUrl。 。 。 .

不支持动态客户端注册的供应商可以使用预先注册的应用程序:

{
  "mcpServers": {
    "hubspot": {
      "baseUrl": "https://mcp.hubspot.com/mcp",
      "auth": "oauth",
      "oauthClientId": "your-client-id",
      "oauthClientSecretEnv": "HUBSPOT_CLIENT_SECRET",
      "oauthTokenEndpointAuthMethod": "client_secret_post",
      "oauthRedirectUrl": "http://127.0.0.1:3434/callback",
    },
  },
}

在环境变量或私人机器本地配置中保留客户秘密, 并登记准确 oauthRedirectUrl 与供养.

可刷新无记名标志( 非交互式 OAuth)

对于没有浏览器提示而需要自动刷新的预播OAuth令牌的服务器,请使用 auth: "refreshable_bearer"接收 HTTP 服务器 Authorization: Bearer <token> 页眉; STIO 服务器需要 refresh.accessTokenEnv 作为环境变量注入符号:

{
  "mcpServers": {
    "example": {
      "command": "uvx",
      "args": ["example-mcp-server"],
      "auth": "refreshable_bearer",
      "refresh": {
        "tokenEndpoint": "https://api.example.com/oauth/token",
        "clientIdEnv": "EXAMPLE_CLIENT_ID",
        "clientSecretEnv": "EXAMPLE_CLIENT_SECRET",
        "clientAuthMethod": "client_secret_basic",
        "refreshSkewSeconds": 300,
        "accessTokenEnv": "EXAMPLE_ACCESS_TOKEN",
      },
    },
  },
}

mcporter 使用从金库中提取的刷新令牌在令牌过期前刷新(默认提前5分钟). 对于启动后无法重新装入证书的 stdio 保留状态服务器,使用 "lifecycle": "ephemeral" 或者在符号过期前重新启动守护进程.

已经拥有 OAuth 符号的无头部署可以种子金库,而无需 复制 mcporter 的内部金库密钥 :

npx mcporter vault set hubspot --tokens-file ./tokens.json
npx mcporter vault set hubspot --stdin < tokens.json
npx mcporter vault clear hubspot

JSON的载荷是 { "tokens": { ... }, "clientInfo": { ... } }· ; tokens 需要,并且 clientInfo 是可选的.

提供 configPath 或者说 rootDir 转到 CLI/ 运行时的调用.

配置解析命令和系统级配置

mcporter每跑一次读取完全一个主配置. 查询命令是:

  1. 你走过的路 --config (或方案) configPath) (中文(简体) ).
  2. 这个 MCPORTER_CONFIG 环境变量(将其设置在外壳中以应用到任何地方).
  3. <root>/config/mcporter.json 当前工程中.
  4. $XDG_CONFIG_HOME/mcporter/mcporter.json[c] 何时 XDG_CONFIG_HOME 设定, 返回到 ~/.mcporter/mcporter.json[c] 当 XDG mcporter 配置不存在时,项目文件缺失.

全体 mcporter config … 变异写回命令所选择的文件 。 为了明确管理全系统的配置,请指出国家领导才能:

mcporter config --config ~/.mcporter/mcporter.json add global-server https://api.example.com/mcp

设定 MCPORTER_CONFIG=~/.mcporter/mcporter.json 如果您想让文件成为任何地方的默认文件( handy for npx mcporter … 运行).

mcporter 向 XDG Base Directory env vars 敬重自己的文件 当这些 vars 被明确设定时: XDG_CONFIG_HOME 为家谱, XDG_DATA_HOME 为奥阿斯金库, XDG_CACHE_HOME 用于图案缓存,以及 XDG_STATE_HOME 用于守护进程/运行时状态。 如果匹配的 XDG var 是未设置或相对的, mcporter 将保留遗产 ~/.mcporter 路径。 配置发现为 XDG- first 但仍为探测器 ~/.mcporter/mcporter.json[c] 当不存在 XDG mcporter 配置时, 它使嵌入器在设定用户注册时不隐藏 XDG_CONFIG_HOME 对于另一个工具。 现有的显式覆盖仍然取胜.

工具过滤

服务器定义可以隐藏或屏蔽精确的工具名称,其中之一 allowedTools 或者说 blockedTools数字 :

{
  "mcpServers": {
    "slack-readonly": {
      "baseUrl": "https://example.com/slack/mcp",
      "allowedTools": ["channels_list", "conversations_history"],
    },
    "filesystem-safe": {
      "command": "npx -y @modelcontextprotocol/server-filesystem ~/Downloads",
      "blockedTools": ["write_file", "delete_file", "move_file"],
    },
  },
}

allowedTools 是允许列表: 只有列出的工具出现在 mcporter list 并可以唤作. 一个空阵列会屏蔽每个工具 . blockedTools 是块列表: 列出的工具被隐藏并拒绝 mcporter call。只使用精确的工具名称,并选择每个服务器一个模式.

测试和测试

命令目的
pnpm checkOxfmt格式化加Oxlint/tsgolint门.
pnpm build类型脚本汇编( emits) dist/) (中文(简体) ).
pnpm test通风单元和集成套房(包括可流式HTTP固定装置).

CI通过GitHub Actions运行相同的三重奏.

调试挂起服务器快速

使用 tmux 在您调查遗留的 MCP 传输时, 保持长期 CLI 会话的可见性 :

tmux new-session -- pnpm mcporter:list

让它在背景中运行,然后检查面板(tmux capture-pane -pt <session>),尾接stdio日志,或者命令退出后杀死会话. 说对了 MCPORTER_DEBUG_HANG=1 当你需要动词处理诊断。 更详细的情况: 文件/tmux.md 财务报告和审定财务报表 文档/被调试。 。 。 .

许可证

麻省理工学院 -- -- 见 自由主义。 。 。 .

进一步读作: 文件/工具调用, (中文(简体) ), 文件/调用语法.md, (中文(简体) ), 文档/adhoc.md, (中文(简体) ), 文件/电子邮件, (中文(简体) ), 文件/tmux.md。 。 。 .

版本与发布记录

@executor-js/mcporter 共发布 2 个版本,首次发布于 2026/06/10;过去 12 个月发布了 2 个版本。

版本发布日期距今
0.11.4latest2026/06/105 个月前
0.11.32026/06/105 个月前

关于 @executor-js/mcporter 的常见问题

@executor-js/mcporter 是什么?

TypeScript 运行时间和CLI用于连接到已配置的上下文协议模型服务器.

如何安装 @executor-js/mcporter?

在项目目录运行 npm install @executor-js/mcporter,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 mcporter,可以用 npx mcporter 直接运行。

@executor-js/mcporter 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@executor-js/mcporter 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@executor-js/mcporter 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=24。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@executor-js/mcporter 可以商用吗?

@executor-js/mcporter 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@executor-js/mcporter 的下载量有多少?

根据 npm 官方下载统计,@executor-js/mcporter 在 2026/10/14 – 2026/11/12 这 30 天内被下载 11,220 次,日均约 374 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@executor-js/mcporter 还在维护吗?

最新版本 0.11.4 发布于 2026/06/10(5 个月前);至今共发布 2 个版本,其中过去 12 个月发布了 2 个;首次发布于 2026/06/10。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。