{"_id":"@dreki-gg/pi-mcp","name":"@dreki-gg/pi-mcp","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@dreki-gg/pi-mcp","version":"0.1.0","description":"MCP client extension for pi","keywords":["pi-package","mcp","model-context-protocol"],"license":"MIT","repository":{"type":"git","url":"git+https://github.com/jalbarrang/pi-mcp.git"},"homepage":"https://github.com/jalbarrang/pi-mcp#readme","bugs":{"url":"https://github.com/jalbarrang/pi-mcp/issues"},"engines":{"node":">=22.19.0"},"publishConfig":{"access":"public"},"type":"module","scripts":{"typecheck":"tsc --noEmit","lint":"oxlint extensions bin","format":"oxfmt --write extensions bin","format:check":"oxfmt --check extensions bin","test":"eslint extensions --max-warnings 0 && tsc --noEmit && vitest run","pack:check":"pnpm pack --dry-run","prepublishOnly":"pnpm test && pnpm pack --dry-run","prepare":"husky || true"},"pi":{"extensions":["./extensions/mcp"]},"dependencies":{"@modelcontextprotocol/sdk":"^1.0.0"},"devDependencies":{"@earendil-works/pi-coding-agent":"^0.80.7","@earendil-works/pi-tui":"^0.80.7","@types/node":"24","@typescript-eslint/parser":"^8.64.0","eslint":"^10.7.0","husky":"^9.1.7","lint-staged":"^17.0.8","oxfmt":"^0.43.0","oxlint":"^1.58.0","typebox":"^1.0.0","typescript":"^6.0.0","vitest":"^4.0.18","@earendil-works/pi-ai":"^0.80.7","zod":"^4.0.0"},"peerDependencies":{"@earendil-works/pi-coding-agent":"*","@earendil-works/pi-tui":"*","typebox":"*","@earendil-works/pi-ai":"*"},"peerDependenciesMeta":{"@earendil-works/pi-coding-agent":{"optional":true},"@earendil-works/pi-tui":{"optional":true},"typebox":{"optional":true},"@earendil-works/pi-ai":{"optional":true}},"lint-staged":{"*.{ts,js}":["oxfmt --write","eslint --max-warnings 0 --no-warn-ignored"]},"packageManager":"pnpm@11.11.0","gitHead":"8fb1055ac30067f698c9a5a699cee54fdfef55d4","_id":"@dreki-gg/pi-mcp@0.1.0","_nodeVersion":"26.5.0","_npmVersion":"11.17.0","dist":{"integrity":"sha512-Xk9w3WBLfYHVCP7nKqqWemGE2mPDHILzmKhdmTpidT0iLsjyLD2BiKGW9SpfQi8EsyCi1LUsjrK+vewkbZL1+w==","shasum":"e1411d36323f0e550fc53d67c94ad7ee7c1ee64a","tarball":"https://registry.npmjs.org/@dreki-gg/pi-mcp/-/pi-mcp-0.1.0.tgz","fileCount":43,"unpackedSize":63889,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCkkuMaV7awuMUdag2EDjwZv+jM7b9xRWWiuO4PWI5wLwIgK+A5aFYvapdhOlhWQ1l6ErikLKkJsyzgvqofqcuhrEE="}]},"_npmUser":{"name":"jalbarrang","email":"jalbarrandev@gmail.com"},"directories":{},"maintainers":[{"name":"jalbarrang","email":"jalbarrandev@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/pi-mcp_0.1.0_1784163196258_0.2580351503471012"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-16T00:53:16.148Z","0.1.0":"2026-07-16T00:53:16.414Z","modified":"2026-07-16T00:53:16.654Z"},"maintainers":[{"name":"jalbarrang","email":"jalbarrandev@gmail.com"}],"description":"MCP client extension for pi","homepage":"https://github.com/jalbarrang/pi-mcp#readme","keywords":["pi-package","mcp","model-context-protocol"],"repository":{"type":"git","url":"git+https://github.com/jalbarrang/pi-mcp.git"},"bugs":{"url":"https://github.com/jalbarrang/pi-mcp/issues"},"license":"MIT","readme":"# @dreki-gg/pi-mcp\n\nUse MCP servers in [pi](https://github.com/badlogic/pi-mono) as either native tools or an on-demand gateway. The extension reads standard MCP configuration and keeps configuration, connections, tool projection, and pi integration in separate DDD layers.\n\n## Install\n\nRequires pi 0.80.7 or later and Node.js 22.19.0 or later.\n\n```sh\npi install npm:@dreki-gg/pi-mcp\n```\n\n## Choose an exposure model\n\nDirect servers are the default. They connect at session start and each discovered MCP tool is registered as a native pi tool, such as `github_search`. Choose direct exposure for small, frequently used tool sets.\n\nSet `\"lazy\": true` for a large or occasional server. It does not start at session launch. pi instead exposes one `mcp` gateway tool, which connects the server only when asked. Choose lazy exposure to keep large catalogs out of the prompt.\n\n```json\n{\n  \"mcpServers\": {\n    \"github\": { \"command\": \"npx\", \"args\": [\"-y\", \"@modelcontextprotocol/server-github\"] },\n    \"everything\": { \"command\": \"npx\", \"args\": [\"-y\", \"@modelcontextprotocol/server-everything\"], \"lazy\": true }\n  }\n}\n```\n\n## Gateway transcript\n\nThe gateway takes a JSON string for `args`, preserving tool arguments across model providers.\n\n```text\nmcp({\"action\":\"list\"})\n# everything: idle\nmcp({\"action\":\"list\",\"server\":\"everything\"})\n# everything_echo: Echo a message\nmcp({\"action\":\"describe\",\"server\":\"everything\",\"tool\":\"everything_echo\"})\n# everything_echo: Echo a message\n# Parameters:\n# - message (required): string\nmcp({\"action\":\"call\",\"server\":\"everything\",\"tool\":\"everything_echo\",\"args\":\"{\\\"message\\\":\\\"hi\\\"}\"})\n# hi\n```\n\nUse `describe` before the first call to a gateway tool.\n\n## Commands\n\n| Command | Purpose |\n| --- | --- |\n| `/mcp` or `/mcp status` | Show server transport, exposure, state, and tool count. |\n| `/mcp connect <server>` | Connect or warm a server. For OAuth servers, starts authorization and then registers its tools. |\n| `/mcp disconnect <server>` | Close a live connection. Existing direct pi tools remain registered and fail fast if called. |\n| `/mcp tools <server>` | List bridged tool names. |\n| `/mcp reload` | Re-read configuration and report added, changed, removed, and unchanged entries. |\n| `/mcp auth reset <server>` | Delete stored OAuth credentials and disconnect the server. |\n\nThe footer reports configured servers, bridged tools, and nonzero authentication or failure counts in interactive pi sessions.\n\n## Configuration\n\nConfiguration sources load in this order; later complete server entries replace earlier entries with the same name.\n\n| Order | Source |\n| --- | --- |\n| 1 | `~/.config/mcp/mcp.json` |\n| 2 | `~/.pi/agent/mcp.json` |\n| 3 | `<project>/.mcp.json` |\n| 4 | `<project>/.pi/mcp.json` |\n\nProject files load only after pi trusts the project. `${VAR}` expands from the environment in commands, arguments, environment variables, URLs, and headers. Standard MCP fields are `command`, `args`, `env`, `cwd` for stdio and `type`, `url`, `headers` for HTTP or legacy SSE. Pi fields are `enabled`, `lazy`, `includeTools`, `excludeTools`, `oauth`, and `oauthPort`.\n\n## Security\n\nProject configuration can start processes, so pi trust-gates it. OAuth tokens, client registration, PKCE data, and discovery metadata are stored under `<pi agent dir>/mcp-auth/` with owner-only permissions. `oauth: false` disables OAuth; `oauthPort` selects a fixed localhost callback port. Static project headers also require project trust.\n\n## Layout\n\n- `extensions/mcp/domain/` contains pure domain rules and value projections.\n- `extensions/mcp/application/` coordinates domain behavior through ports.\n- `extensions/mcp/infrastructure/` adapts filesystem, MCP SDK, and pi APIs.\n- `extensions/mcp/index.ts` is the composition root.\n\n## Prior art\n\n[pi-mcp-adapter](https://github.com/nicolo-ribaudo/pi-mcp-adapter) informed the gateway approach. It is proxy-only; pi-mcp adds direct native tool exposure so small, high-frequency MCP catalogs remain ergonomic.\n\n## Development\n\n```sh\npnpm install\npnpm test\npnpm lint\npnpm format:check\n```\n\n`pnpm test` enforces the 100-line limit for each TypeScript file (eslint `max-lines`), typechecks, and runs the Vitest suite. Run `pnpm pack:check` to inspect the exact npm tarball before a release. See [the publishing runbook](https://github.com/jalbarrang/pi-mcp/blob/main/docs/publishing.md) for the initial publish and trusted-publishing setup.\n","readmeFilename":"README.md","_rev":"1-862fded0047a861fd9348cd20d3a29a6"}