MP

mitsuhiko/pi-codemode-mcp

Developer tools

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る

40 stars 2 forks 品質 45 トレンド 12

コードを使用してMCPをPiに接続する実験的な方法

概要

MCP を 2 つのツールで拡張する Pi 拡張: - list mcp tools — すべての MCP ツールを列挙します(最初の 20 インラインで、完全なリストをテンプファイルにオーバーフローします) - call mcp — サンドボックスで JavaScript を実行し、スクリプトが MCP サーバーを呼び出します ステータス、有効/無効、再接続、およびauth 設定の /mcp コマンドも追加します。 これは、コンポジションを可能にする方法でMCPでコーディングエージェントインターフェイスを可能にする効率のメリットがあるかどうかを確認する実験でした。 このブログ記事をご覧ください。 実際の結果は、MCPが今日どのように機能するかで、そのような効率の向上は有用ではないということです。 一方、内部でコードを使用するMCPサーバーは非常に便利です。 たとえば、JavaScript 環境を使用して Google サービスを呼び出す MCP サーバーの例を参照してください。 同じスキルと同様に、実際に実行する。 合併注文にロード(以前のレイター) 1. ~/.pi/agent/mcp.json 2. ~/.pi/agent/.mcp.json 3. /.pi/mcp.json の 4. /.mcp.jsonの --mcp-config /path/to/file.json でオーバーライドできます.

概要(AI 翻訳)

MCP を 2 つのツールで拡張する Pi 拡張:

  • [list_mcp_tools — すべてのMCPツールを列挙する(最初の20インラインを表示し、全リストをテンプファイルにオーバーフローする)
  • [call_mcp — サンドボックスで JavaScript を実行し、スクリプトが MCP サーバーを呼び出します

また、ステータス、有効/無効、再接続、auth 設定の [/mcp] コマンドも追加します。

なぜ?

これは、コーディングエージェントインターフェイスを許可する効率のメリットがあるかどうかを確認する実験でした MCP はコンポジションを許す方法にあります。 このブログ記事をご覧ください。

実際の結果は、MCPが今日どのように機能するかで、そのような効率の向上は有用ではないということです。 その他について 内部でコードを使用するMCPサーバーは、非常に役立ちます。 お問い合わせ たとえば、MCP サーバー JavaScript環境を使用してGoogleサービスを呼び出します。 その1つは実際に同様に同様に実行する スキルは行います。

設定ファイル

合併注文にロード(以前のレイター)

  1. [~/.pi/agent/mcp.json
  2. [~/.pi/agent/.mcp.json
  3. [ /.pi/mcp.json
  4. [ /.mcp.json

--mcp-config /path/to/file.jsonでオーバーライドできます。

[[T8]

パラメーター:

  • [query: ケースインセンティブテキストマッチ、または[[/pattern/flags]を介してregex

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。

README

以下は原文 README の抜粋です。原文を見る。

pi-codemode-mcp

Pi extension that exposes MCP through two tools:

  • list_mcp_tools — enumerates all MCP tools (shows first 20 inline, overflows full list to a temp file)
  • call_mcp — runs JavaScript in a sandbox and lets the script call MCP servers

It also adds a /mcp command for status, enable/disable, reconnect, and auth setup.

Why?

This was an experiment to see if there is an efficiency benefit of allowing a coding agent interface with MCP in a way that allows composition. See this blog post.

The actual findings are that with how MCP works today, such efficiency gains are not useful. On the other hand an MCP server that uses code internally can be very helpful. See for instance an example MCP server that uses a JavaScript environment to call Google services. That one actually performs as well as a similar skill does.

Configuration files

Loaded in merge order (later overrides earlier):

  1. ~/.pi/agent/mcp.json
  2. ~/.pi/agent/.mcp.json
  3. /.pi/mcp.json
  4. /.mcp.json

You can override with --mcp-config /path/to/file.json.

list_mcp_tools

Parameters:

  • query (optional): case-insensitive text match, or regex via /pattern/flags

The tool always shows the first 20 matches inline. If more matches exist, it writes the full list to a temp .tsv file so the agent can grep/rg it.

Each listed MCP tool includes a compact schema signature, with required fields marked by * and optional fields in brackets.

Only currently enabled MCP tools are listed.

/mcp command

Use /mcp to manage MCP from interactive mode:

  • /mcp — opens an interactive select menu (status, reconnect, auth, and per-server tool toggles)
  • /mcp status — show server connection/auth state + enabled/disabled counts
  • /mcp enable — enable a specific MCP tool (or all tools for server)
  • /mcp disable — disable a specific MCP tool (or all tools for server)
  • /mcp reconnect [server] — reconnect one/all servers and refresh metadata
  • /mcp auth — trigger auth setup flow

Tool enable/disable policies are persisted in:

  • ~/.pi/agent/mcp-tool-policies.json

Auth behavior

  • OAuth flow (standard MCP auth)
    • /mcp auth starts an OAuth browser login flow with localhost callback (for URL-based servers).
    • received tokens are stored in: ~/.pi/agent/mcp-oauth//tokens.json
    • then the server is reconnected.
    • if a server’s auth metadata does not support dynamic client registration, /mcp auth falls back to bearer setup for the current session (for GitHub Copilot MCP, it will try gh auth token automatically).
  • Bearer servers (auth: "bearer" or bearer token config)
    • if bearerTokenEnv is configured, /mcp auth lets you paste a token into that env var for the current pi process.
GitHub で README 全文を見る

インストール

This server does not publish a one-line install command.

Open the repository installation guide MCP 初心者?mcpskill.org のガイドから始めましょう →