openclaw/mcporter
Call MCPs via TypeScript, masquerading as simple TypeScript API. Or package them as cli.
MCPorter – A TypeScript runtime & CLI for Model Context Protocol (MCP)
What it is – MCPorter is a small open‑source library (published on npm) that lets developers and AI‑coding agents discover, call, and work with Model Context Protocol servers from the command line, scripts, or generated TypeScript clients.
Why it matters – MCP is a protocol that lets language‑model‑backed tools expose typed “functions” (e.g., resolve‑library‑id, search‑docs) that can be invoked programmatically. MCPorter provides the glue between those servers and ordinary code or shell pipelines, making the protocol usable without writing custom networking code.
Quick start (from the README)
# Try the CLI without installing globally
npx mcporter --version
# List the tools a public MCP server offers (brief view)
npx mcporter list https://mcp.context7.com/mcp --brief
# Call a concrete tool
npx mcporter call https://mcp.context7.com/mcp.resolve-library-id \
query="React hooks docs" libraryName=react
The first command shows the server’s TypeScript‑style signatures; the second returns matching library IDs.
Core capabilities (as listed in the README)
| Goal | CLI / API | What you get |
|---|---|---|
| Discover servers & their tools | mcporter list |
Human‑readable or JSON list of tool signatures |
| Call a tool / fetch a resource | mcporter call, mcporter resource |
Executes the remote tool, returns text, Markdown, JSON, image, etc. |
| Connect ad‑hoc (URL or stdio) | --http-url, --stdio |
No permanent config needed |
| OAuth handling | mcporter auth, mcporter vault |
Stores credentials, optionally encrypted with MCPORTER_VAULT_PASSWORD |
| Generate a focused CLI for a server | mcporter generate-cli |
Stand‑alone executable that only knows that server’s tools |
| Emit TypeScript types / client library | mcporter emit-ts |
Typed SDK you can import in your code |
| Record & replay sessions | mcporter record, mcporter replay |
Capture a full interaction for debugging or reproducibility |
Runtime API (TypeScript)
import { createRuntime } from 'mcporter';
const runtime = await createRuntime({
servers: [{
name: 'context7',
command: { kind: 'http', url: new URL('https://mcp.context7.com/mcp') }
}]
});
// List tool names
console.log((await runtime.listTools('context7')).map(t => t.name));
await runtime.close();
createRuntime()– set up a reusable connection pool, optionally with multiple servers.callOnce()– one‑off call with automatic cleanup.createServerProxy()– creates an object whose camelCase properties map to MCP tools, returning rich helpers for text, Markdown, JSON, images, etc.
Configuration
A minimal config/mcporter.json:
{
"mcpServers": {
"context7": { "url": "https://mcp.context7.com/mcp" }
}
}
- Supports JSONC, environment variable interpolation, HTTP/stdio definitions, OAuth settings, tool filters, and lifecycle policies.
- Can import server definitions from many IDEs and assistants (Cursor, Claude Code, VS Code, etc.).
- Special Chrome DevTools integration via an OpenClaw extension relay (handles loopback authentication, no credential leakage).
Protocol support
- Connects to stdio, Streamable HTTP, and legacy SSE servers.
- Negotiates the latest protocol version (
2026‑07‑28) or falls back to older revisions. - Handles interactive requests (forms, URLs) – CLI can answer them, headless mode can decline with a hint.
- Includes a keep‑alive daemon for pooled connections and Chrome DevTools bridging.
Installation options
| Method | Command |
|---|---|
| One‑off CLI | npx mcporter --version |
| Homebrew (macOS) | brew install steipete/tap/mcporter |
| Global npm | npm install -g mcporter |
| Project dependency | npm install mcporter (or pnpm/yarn) |
Node 24+ is required for the npm package; the repo’s CI also tests on Node 26.
Development & testing
- Uses pnpm, Vitest 5, and runs CI on Linux/macOS/Windows.
- Live‑hosted server tests are optional (see
docs/livetests.md). - Documentation site generated via
pnpm docs:site.
Related projects (from the README)
- CodexBar – macOS menu‑bar UI for Codex token windows.
- Trimmy – utility to flatten multi‑line shell snippets.
- Oracle – bundles prompts/files for multi‑model runs.
- Model Context Protocol specification – the formal spec that MCPorter implements.
TL;DR
MCPorter is a practical bridge for the Model Context Protocol: a CLI for discovery, a TypeScript runtime for programmatic calls, tools to generate typed SDKs or focused CLIs, and support for OAuth, encryption, and session recording. It’s aimed at developers building AI‑augmented tooling or agents that need to call remote “model‑backed functions” in a typed, reproducible way.
Related
- Project
- Project
- Project
- Project