@yofriadi/pi-mcp
v0.1.3
Published
Standalone MCP extension package for pi installs
Readme
MCP Extension
Install from git URL
pi install git:github.com/yofriadi/pi-extensions@mcp-v<version>To load only this extension from the monorepo package source, use package filtering in settings:
{
"packages": [
{
"source": "git:github.com/yofriadi/pi-extensions@mcp-v<version>",
"extensions": ["packages/mcp/src/index.ts"]
}
]
}Standalone MCP extension package for pi and the Bun fork workflow.
This package provides:
- MCP config discovery and validation
- MCP runtime with stdio and HTTP JSON-RPC transport support
- HTTP session header propagation (
Mcp-Session-Id) and SSE response parsing for streamable MCP endpoints - MCP manager lifecycle orchestration (startup/reload/shutdown)
- MCP command/tool utilities and discovered-tool bridge registration
Install and Load
Upstream pi
# Load extension for one run
pi -e ./packages/coding-agent/examples/extensions/mcp
# Persist extension as an installed package source
pi install ./packages/coding-agent/examples/extensions/mcpBun fork source workflow
# Run coding-agent CLI directly via Bun with extension loaded
bun packages/coding-agent/src/cli.ts -e ./packages/coding-agent/examples/extensions/mcpConfiguration
Native config merge order
The resolver loads files in this order (later entries override earlier by server name):
~/.pi/agent/mcp.json<cwd>/.mcp.json<cwd>/.pi/mcp.json
Supported top-level shapes:
mcpServersobjectserversobjectserversarray ([{ "name": "...", ... }])
Example:
{
"mcpServers": {
"context7": {
"transport": "stdio",
"command": "npx",
"args": ["-y", "@upstash/context7-mcp"],
"timeoutMs": 30000
},
"mcp.grep.app": {
"transport": "http",
"url": "https://mcp.grep.app",
"timeoutMs": 30000
}
}
}Optional external discovery adapters (opt-in)
By default, external Claude/Cursor configs are ignored.
To opt in:
export PI_MCP_DISCOVERY_ADAPTERS=claude,cursorSupported adapter values:
claudecursornone(disables adapter loading)
Adapter-derived servers are loaded before native pi config files, so native pi files can override imported definitions.
Commands
/mcp-statusshow manager/runtime/config/tool-cache health/mcp-tools <server>list MCP tools from one server/mcp-call <server> <method> [jsonParams]issue JSON-RPC call/mcp-reloadreload config and restart MCP runtime
Agent Tools
mcp_list_toolsmcp_call
At startup/reload, discovered MCP tools are bridged into regular agent tools with stable names (for example: mcp_context7_resolve_library_id).
Security Notes
- Only configure MCP servers you trust. MCP tools can execute external processes or requests.
- Review local config files before enabling adapters (
PI_MCP_DISCOVERY_ADAPTERS) because this imports external definitions. - Prefer pinned commands/versions (for example explicit npm package versions) when possible.
- Treat MCP server output as untrusted input in downstream prompts and scripts.
Troubleshooting
No MCP servers appear
- Run
/mcp-status. - Check
Configured serversandDiagnosticsoutput. - Verify file paths and JSON validity for
~/.pi/agent/mcp.json,.mcp.json, or.pi/mcp.json.
Server is configured but not active
- Run
/mcp-statusand inspect the server reason. - For stdio servers, verify command + args locally.
- For HTTP servers, verify endpoint accepts JSON-RPC POST and returns valid responses.
Tool bridge did not register expected tools
- Run
/mcp-statusand inspectDiscovered MCP toolsandBridged MCP tools. - Run
/mcp-tools <server>to confirm servertools/listoutput. - Run
/mcp-reloadafter config/server changes.
Adapter-based discovery not working
- Confirm
PI_MCP_DISCOVERY_ADAPTERSis set in the runtime environment. - Use supported values only:
claude,cursor. - Re-run
/mcp-reloadand inspect/mcp-statusdiagnostics for unknown adapter warnings.
