MCPorter 🧳
TypeScript runtime & CLI toolkit for the Model Context Protocol · v0.8.1
MCPorter は、Cursor・Claude・Codex・VS Code などで設定済みの MCP(Model Context Protocol)サーバーを、TypeScript コードや CLI からゼロ設定で呼び出すためのランタイムおよびツールキット。サーバー探索・型付きクライアント生成・スタンドアロン CLI 生成・OAuth 管理を一手に担う。
createRuntime() は ~/.mcporter/mcporter.json・プロジェクト設定・Cursor/Claude/Codex/Windsurf/VS Code のインポートをマージし、${ENV} 変数展開・接続プールを透過的に行う。
- macOS · Linux · Windows(Node ≥ 20.11)
- HTTP / SSE / stdio トランスポート統一 API
npx mcporterでインストール不要即時実行- Homebrew tap 経由のバイナリ配布にも対応
| スタイル | 例 | 特徴 |
|---|---|---|
colon-flag |
linear.create_comment issueId:ENG-123 body:'Hi' |
シェルスクリプト向け。key=value / key:value 両対応。 |
function-call |
'linear.create_comment(issueId: "ENG-123", body: "Hi")' |
mcporter list のシグネチャをそのままコピペ可能。 |
HTTP selector |
https://mcp.linear.app/mcp.list_issues |
URL + ツール名を直接指定。config 不要。 |
shorthand |
mcporter linear.list_issues |
動詞を省略。dotted token は call に自動解釈。 |
# 全サーバー一覧
npx mcporter list
# TypeScript 形式のシグネチャ表示
npx mcporter list context7 --schema
# 全パラメータを展開
npx mcporter list linear --all-parameters
# JSON 出力(スクリプト連携)
npx mcporter list --json
# Context7 でドキュメント取得
npx mcporter call context7.resolve-library-id \
libraryName=react
# Linear にコメント投稿
npx mcporter call \
'linear.create_comment(issueId: "LNR-123", body: "Hello")'
# Chrome DevTools スナップショット
npx mcporter call chrome-devtools.take_snapshot
# 未設定サーバーにアドホック接続
npx mcporter call \
--stdio "bun run ./local-server.ts" --name local
linear - Hosted Linear MCP
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): Comment;
// optional (3): notifySubscribers, labelIds, mentionIds
Did you mean …? ヒントを表示する。
| フラグ | 対象コマンド | 説明 |
|---|---|---|
--config <path> | 全般 | config ファイルを明示指定 |
--http-url <url> | list / call / auth | アドホック HTTP MCP サーバー指定 |
--stdio "cmd" | list / call / auth | アドホック stdio サーバー指定 |
--persist <path> | list / call | アドホック定義を config に保存 |
--all-parameters | list | 省略された任意パラメータを全展開 |
--output json|raw | call | JSON / 生テキスト出力 |
--tail-log | call | レスポンスのログファイルを末尾表示 |
--raw-strings | call | 数値的引数を文字列として保持 |
--oauth-timeout <ms> | call / auth | OAuth ブラウザ待機時間を変更 |
最もシンプルな API。サーバー探索・OAuth・トランスポートの開閉を自動処理する。単発スクリプトやエージェントのツールフックに適している。
import { callOnce } from "mcporter";
const result = await callOnce({
server: "firecrawl",
toolName: "crawl",
args: { url: "https://anthropic.com" },
});
console.log(result); // 生 MCP エンベロープ
複数回呼び出す場合やストリーミングが必要な場合は createRuntime() を使う。OAuth トークンのリフレッシュ・トランスポート再利用を内包する。
import { createRuntime } from "mcporter";
const runtime = await createRuntime();
const tools = await runtime.listTools("context7");
const result = await runtime.callTool("context7", "resolve-library-id", {
args: { libraryName: "react" },
});
console.log(result);
await runtime.close(); // トランスポートとセッションを終了
ツール名を camelCase メソッドとして呼び出せる人間向け API。引数マッピング・JSON スキーマデフォルト適用・CallResult でラップが自動で行われる。
import { createRuntime, createServerProxy } from "mcporter";
const runtime = await createRuntime();
const chrome = createServerProxy(runtime, "chrome-devtools");
const linear = createServerProxy(runtime, "linear");
// takeSnapshot → take_snapshot に自動マッピング
const snapshot = await chrome.takeSnapshot();
console.log(snapshot.text());
// CallResult ヘルパー: .text() .json() .images() .markdown() .content() .raw
const docs = await linear.searchDocumentation({ query: "automations" });
console.log(docs.json());
await runtime.close();
任意の MCP サーバー定義をスタンドアロン CLI に変換する。生成物にはリジェネレーション用メタデータが埋め込まれる。
# HTTP MCP を CLI に変換
npx mcporter generate-cli \
--command https://mcp.context7.com/mcp
# → context7.ts / context7.js を出力
# stdio MCP を Bun コンパイル済みバイナリに
npx mcporter generate-cli \
"npx -y chrome-devtools-mcp@latest" \
--compile
# 特定ツールだけ含める
npx mcporter generate-cli linear \
--include-tools list_issues,create_issue
# 既存 CLI を最新 mcporter でリジェネ
npx mcporter generate-cli \
--from dist/context7.js
mcporter list と同じシグネチャ・Doc ブロックから .d.ts インターフェースまたはクライアントラッパーを生成する。
# 型定義のみ(.d.ts)
npx mcporter emit-ts linear \
--out types/linear-tools.d.ts
# クライアントラッパー(.d.ts + .ts)
npx mcporter emit-ts linear \
--mode client --out clients/linear.ts
# 任意パラメータも含む
npx mcporter emit-ts linear \
--mode client --include-optional \
--out clients/linear-full.ts
# JSON サマリ出力(スクリプト連携)
npx mcporter emit-ts linear --json
createRuntime / createServerProxy をラップしたファクトリ関数も一緒に出力される。
{
"$schema": "https://raw.githubusercontent.com/steipete/mcporter/main/mcporter.schema.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"],
"env": { "npm_config_loglevel": "error" }
}
},
"imports": ["cursor", "claude-code", "claude-desktop", "codex", "windsurf", "opencode", "vscode"]
}
${VAR} / ${VAR:-fallback} / $env:VAR の変数展開に対応。インラインコメント(// / /* */)と末尾カンマも許可される JSONC 形式。
| 優先度 | ソース | 備考 |
|---|---|---|
| 1 | --http-url / --stdio / ベア URL | 最高優先。--persist がない限りキャッシュされない。 |
| 2 | config/mcporter.json(または --config 指定) | プロジェクトルートのローカル設定。 |
| 3 | ~/.mcporter/mcporter.json | ホームディレクトリのグローバル設定。プロジェクト設定とマージされる。 |
| 4 | imports リストのエディタ設定 | Cursor / Claude / Codex / Windsurf / VS Code など。読み取り専用スナップショット。 |
| サブコマンド | 説明 |
|---|---|
config list [filter] | ローカルエントリを表示。--source import でインポート元を表示。 |
config get <name> | 単一サーバーの解決済み定義とソースパスを表示。 |
config add <name> [target] | サーバーを config に永続化(URL または stdio コマンド)。 |
config remove <name> | ローカルエントリを削除。インポート由来のエントリはコピー後に削除可能。 |
config import <kind> | cursor / claude-code / codex などの設定を表示・コピー。 |
config login <name|url> | OAuth / auth フローを完了し ~/.mcporter/<name>/ にキャッシュ。 |
config logout <name> | OAuth トークンキャッシュを削除。--all で全消去。 |
config doctor | config ファイルの共通ミスを検証(開発中)。 |
chrome-devtools や mobile-mcp のようなステートフル stdio サーバーは、初回呼び出し時に per-login デーモンが自動起動し、Chrome タブやデバイスセッションを複数の呼び出し間で維持する。
# デーモンの状態確認(接続中サーバー一覧)
mcporter daemon status
# デーモンを明示的に起動
mcporter daemon start
# 起動しつつログをファイルに出力
mcporter daemon start --log --log-file /tmp/daemon.log
# 設定変更後にバウンス
mcporter daemon restart
# デーモン停止
mcporter daemon stop
サーバーエントリに "lifecycle": "keep-alive" を追加するか、MCPORTER_KEEPALIVE=name 環境変数で指定するとデーモン管理対象になる。逆に "lifecycle": "ephemeral" または MCPORTER_DISABLE_KEEPALIVE=name でオプトアウト可能。
--stdio / --http-url)はデーモン管理外。--persist で config に書き込んでから lifecycle を設定する。
MCPORTER_DEBUG_HANG=1— ハングしたトランスポートの詳細ログを出力--log-level debug— 全コマンドで詳細ログを有効化--log-servers <name>— 特定サーバーの呼び出しトレースのみ出力tmux new-session -- pnpm mcporter:list— バックグラウンドで長時間セッションを維持しつつ調査- ハング調査の詳細は
docs/hang-debug.mdとdocs/tmux.mdを参照
- GitHub: steipete/mcporter — ソースコード
- npm: mcporter — パッケージページ
- docs/call-syntax.md — 呼び出し構文の詳細
- docs/adhoc.md — アドホック接続と OAuth の詳細
- docs/emit-ts.md — emit-ts フラグ全リファレンス
- docs/config.md — 設定解決・インポートの詳細