mcporter README

The project's README from github.com/openclaw/mcporter. As one markdown file: README.md.

MCPorter 🧳 — Carry MCP tools into scripts, CLIs, and agents

CI npm Node License Docs

MCPorter header banner

MCPorter is a TypeScript runtime and command-line tool for discovering and calling Model Context Protocol servers. It is for developers and coding agents that need the same MCP tools from a terminal, a script, or a generated standalone CLI.

Install

Try the CLI without installing it:

npx mcporter --version

Install it for repeated command-line use:

brew install steipete/tap/mcporter
# or
npm install -g mcporter

Node 24 or newer is required for npm installs. For the TypeScript runtime, add mcporter to your project with your package manager. Signed macOS binaries and the other supported install paths are covered in the install guide.

Quick start

Inspect a public MCP server, then call one of its tools:

npx mcporter list https://mcp.context7.com/mcp --brief
npx mcporter call https://mcp.context7.com/mcp.resolve-library-id \
  query="React hooks docs" libraryName=react

The first command prints the server's TypeScript-style tool signatures. The second returns matching Context7 library IDs without requiring local configuration or credentials. See the five-minute quickstart for resources, generated CLIs, and typed clients.

Core workflows

Goal Command or API Details
Discover servers and tools mcporter list CLI reference
Call tools and read resources mcporter call, mcporter resource Call syntax
Connect to a one-off URL or stdio command --http-url, --stdio Ad-hoc servers
Complete or seed OAuth mcporter auth, mcporter vault Configuration
Generate a focused CLI mcporter generate-cli CLI generator
Generate TypeScript types or clients mcporter emit-ts Typed clients
Capture a reproducible MCP session mcporter record, mcporter replay Record and replay

Human-readable output goes to stdout by default. Use JSON output when another program or agent needs a stable result, and consult mcporter <command> --help for the flags supported by that command.

Configuration and discovery

MCPorter reads project and user config, then imports MCP servers from Cursor, Claude Code and Desktop, Codex, Windsurf, OpenCode, and VS Code. A minimal config/mcporter.json looks like this:

{
  "mcpServers": {
    "context7": {
      "url": "https://mcp.context7.com/mcp"
    }
  }
}

Config files accept JSONC, environment placeholders (${VAR}, ${VAR:-fallback}, or whole-value $env:VAR), HTTP and stdio definitions, OAuth settings, tool filters, and lifecycle policy. The configuration guide defines precedence and the full schema; the import reference lists every discovered client format. The ${env:VAR} form used by some MCP clients is not supported; mcporter rejects it with the accepted alternatives instead of sending it literally.

Chrome DevTools definitions using --autoConnect can control Chrome through a paired OpenClaw extension relay. MCPorter discovers OpenClaw's active extension relay endpoint, while preserving an explicit MCPORTER_CHROME_DEVTOOLS_RELAY_URL override and the legacy 127.0.0.1:18799 fallback. It uses Browser Relay Authentication v2 over one retained loopback socket, keeps the host key out of the network and child process, and gives chrome-devtools-mcp a credential-free loopback URL plus ephemeral authorization through an OS-protected preload handoff. Old relay authentication is never retried. Routing defaults to prefer, which may fall back only to Chrome's original auto-connect path; require fails closed and off keeps original auto-connect.

TypeScript runtime

Use createRuntime() when a process needs explicit server definitions, connection reuse, or several calls:

import { createRuntime } from 'mcporter';

const runtime = await createRuntime({
  servers: [{ name: 'context7', command: { kind: 'http', url: new URL('https://mcp.context7.com/mcp') } }],
});
try {
  console.log((await runtime.listTools('context7')).map((tool) => tool.name));
} finally {
  await runtime.close();
}

callOnce() handles a single configured call and cleanup. createServerProxy() maps MCP tool names to callable camelCase properties and wraps results with text, Markdown, JSON, image, and raw-content helpers. See the runtime overview and tool-calling guide.

Protocols and long-lived servers

MCPorter connects to stdio, Streamable HTTP, and legacy SSE servers. It negotiates the current 2026-07-28 protocol or a legacy revision per server, while legacy connections advertise client elicitation capabilities. Interactive CLI calls can answer form and URL requests; headless and daemon-managed calls decline them with an actionable hint.

The repository's modern and legacy fixture servers cover both generations; CI exercises representative fixture paths end-to-end over stdio and Streamable HTTP. See protocols and interactive requests for negotiation controls and the keep-alive daemon for pooled servers, the MCP bridge, and Chrome DevTools integration.

Development

pnpm install --frozen-lockfile
pnpm check
pnpm test
pnpm docs:site

The project uses the Node and pnpm versions declared in package.json. Live hosted-server tests are opt-in; see live tests and manual testing.

License

MIT — see LICENSE.

mcporter (openclaw/mcporter)

Searching Database…

这是什么?MCPorter 是一个 TypeScript 运行时和命令行工具,用于发现并调用 Model Context Protocol(MCP)服务器,让开发者和编程智能体可以在终端、脚本中使用同一套 MCP 工具,也可以生成独立的命令行程序。
这是库还是命令行工具?两者都是:你可以把它作为 TypeScript 运行时导入代码中(使用 createRuntime、callOnce、createServerProxy),也可以直接运行 mcporter 命令行(list、call、generate-cli)。它甚至能生成一个只针对某个 MCP 服务器的独立命令行工具。
怎样让它跑起来?可以不安装,直接用 npx 试用;也可以用 npm 全局安装,以便反复使用命令行;或者把 mcporter 包添加到项目中,以使用 TypeScript 运行时。
需要特定的 Node 版本吗?使用 npm 安装需要 Node 24 或更高版本;另外也提供经过签名的 macOS 二进制文件,作为替代的安装方式。
配置时有什么需要注意的坑吗?某些 MCP 客户端使用的 '${env:VAR}' 占位符语法不受支持。mcporter 会拒绝这种写法,并给出可用的替代写法,而不是原样发送。
MCPorter 可以从哪些编程工具导入 MCP 服务器配置?它会自动导入 Cursor、Claude Code 和 Desktop、Codex、Windsurf、OpenCode 以及 VS Code 的配置。
它能为单个 MCP 服务器生成独立的命令行工具吗?可以。运行 'mcporter generate-cli' 即可为单个服务器生成专用命令行工具;'emit-ts' 则可以生成 TypeScript 类型或带类型的客户端。
它支持哪些 MCP 传输协议?它可以通过 stdio、Streamable HTTP 和旧版 SSE 连接,并会为每个服务器协商使用当前的 2026-07-28 协议,或更早的修订版本。
Chrome DevTools 中继功能是做什么用的?它通过本地回环套接字,把 chrome-devtools-mcp 经由已配对的 OpenClaw 浏览器扩展进行转发,并提供一个不含凭据、带有临时授权的 URL,而不是暴露主机密钥。
Creator
openclaw
Size
53.6 MB
Stars
5.1K
Age
11mo
Commits · 90 Days