# mcporter

MCPorter 是 Model Context Protocol (MCP) 的 TypeScript 運行環境、CLI 工具與程式碼生成工具套件。透過零配置發現功能，探索、呼叫任何 MCP 伺服器，將其轉化為獨立 CLI 或類型化 API。

Canonical URL: https://a2a-mcp.org/entry/mcporter-zh-TW

Language: zh-TW

Category: Tools & Extensions

Updated: 2026-04-06

## 概述

**mcporter** (MCPorter 🧳) 是一個開源的 **TypeScript 運行時環境、CLI 工具和程式碼生成套件**，專為 [Model Context Protocol (MCP)](https://github.com/modelcontextprotocol/specification) 而設計。它讓開發者和 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 呼叫取代繁重的架構載入。

## 安裝與快速入門

### 立即執行 (無需安裝)
```bash
npx mcporter list
npx mcporter list linear --schema
```

### 全域安裝
```bash
npm install -g mcporter
# 或使用 Homebrew
brew tap steipete/tap && brew install steipete/tap/mcporter
```

### 範例呼叫
```bash
# 冒號語法
mcporter call linear.create_comment issueId:ENG-123 body:'Looks good!'

# 函式呼叫語法
mcporter call 'linear.create_comment(issueId: "ENG-123", body: "Looks good!")'
```

# 生成 CLI
```bash
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 參考資料和範例都在[儲存庫](https://github.com/steipete/mcporter)中。

## 為什麼選擇 mcporter？

MCP 透過工具賦予 AI 代理超能力，但管理架構和連接過程繁瑣。mcporter 讓 MCP 變得更**順手** — 一次探索、即刻呼叫、為代理生成 CLI，並撰寫乾淨的類型化程式碼。它是終極的 MCP 瑞士軍刀。

## 相關連結

- GitHub：[steipete/mcporter](https://github.com/steipete/mcporter)
- 網站：[mcporter.dev](https://mcporter.dev)
- CLI 參考資料與文件：[github.com/steipete/mcporter/tree/main/docs](https://github.com/steipete/mcporter/tree/main/docs)

完美搭配任何 MCP 驅動的 AI 工作流程。

## Tags

- MCP協議
- TypeScript
- 命令行介面
- MCP客戶端
- AI代理
- 工具呼叫
- 程式碼生成
- 運行環境
- Claude
- Cursor
- Context7

## Sources

- [Project website](https://github.com/steipete/mcporter)
