pi-mcp-adapter 4.0.0 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/CHANGELOG.md +69 -1
  2. package/README.md +78 -1026
  3. package/cli.js +210 -0
  4. package/commands.ts +37 -4
  5. package/config.ts +300 -32
  6. package/direct-tool-surface.ts +6 -5
  7. package/direct-tools.ts +40 -27
  8. package/dist/config.d.ts +9 -4
  9. package/dist/config.js +313 -30
  10. package/dist/config.js.map +1 -1
  11. package/dist/elicitation-handler.d.ts +4 -0
  12. package/dist/elicitation-handler.js +14 -1
  13. package/dist/elicitation-handler.js.map +1 -1
  14. package/dist/mcp-auth.js +3 -1
  15. package/dist/mcp-auth.js.map +1 -1
  16. package/dist/mcp-trace.d.ts +2 -0
  17. package/dist/mcp-trace.js +6 -0
  18. package/dist/mcp-trace.js.map +1 -1
  19. package/dist/metadata-cache.d.ts +3 -1
  20. package/dist/metadata-cache.js +32 -4
  21. package/dist/metadata-cache.js.map +1 -1
  22. package/dist/project-server-trust.d.ts +17 -0
  23. package/dist/project-server-trust.js +209 -0
  24. package/dist/project-server-trust.js.map +1 -0
  25. package/dist/server-manager.d.ts +9 -0
  26. package/dist/server-manager.js +108 -14
  27. package/dist/server-manager.js.map +1 -1
  28. package/dist/session-recovery.js +4 -3
  29. package/dist/session-recovery.js.map +1 -1
  30. package/dist/types.d.ts +20 -1
  31. package/dist/types.js.map +1 -1
  32. package/dist/utils.d.ts +5 -1
  33. package/dist/utils.js +16 -0
  34. package/dist/utils.js.map +1 -1
  35. package/{OAUTH.md → docs/auth.md} +62 -9
  36. package/docs/configuration.md +221 -0
  37. package/docs/extension-api.md +248 -0
  38. package/docs/pi-builtin-comparison.md +113 -0
  39. package/docs/prompts-and-ui.md +86 -0
  40. package/docs/protocol-extensions.md +47 -0
  41. package/docs/scripting.md +131 -0
  42. package/docs/servers.md +143 -0
  43. package/docs/tools.md +259 -0
  44. package/elicitation-handler.ts +13 -1
  45. package/index.ts +220 -27
  46. package/init.ts +77 -41
  47. package/mcp-auth.ts +3 -1
  48. package/mcp-panel.ts +52 -4
  49. package/mcp-setup-panel.ts +9 -6
  50. package/mcp-trace.ts +8 -0
  51. package/metadata-cache.ts +25 -4
  52. package/onboarding-state.ts +20 -0
  53. package/package.json +10 -13
  54. package/pi-builtin-mcp.ts +32 -0
  55. package/pi-signin-import.ts +147 -0
  56. package/project-server-trust.ts +8 -4
  57. package/prompts.ts +11 -3
  58. package/proxy-modes.ts +44 -33
  59. package/runtime-protocol.ts +501 -0
  60. package/search-ranking.ts +12 -3
  61. package/server-manager.ts +121 -13
  62. package/session-recovery.ts +4 -3
  63. package/types.ts +12 -1
  64. package/ui-server.ts +34 -32
  65. package/utils.ts +16 -1
package/CHANGELOG.md CHANGED
@@ -7,6 +7,74 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [5.1.0] - 2026-10-05
11
+
12
+ ### Highlights
13
+
14
+ - The adapter works with Pi 1.0.0.
15
+ - `/mcp-adapter setup` can add Tavily Search for web search and page extraction, with no account or API key.
16
+ - You can keep a server's MCP App UIs from opening with `"openUi": false` and still use its tools.
17
+ - Other Pi extensions can build on MCP features beyond tool calls, such as the draft MCP Events extension, using the servers and sign-ins you already set up.
18
+ - `pi -p` no longer hangs after replying when an HTTP server signs in with a token command or a Pi `/login` provider.
19
+
20
+ ### Added
21
+
22
+ - `/mcp-adapter setup` can add Tavily Search for web search and page extraction. It uses Tavily's [keyless access](https://docs.tavily.com/documentation/keyless), so there is no account, API key, or sign-in; usage is rate-limited. `tavily_search` and `tavily_extract` are direct tools. Tavily's other tools need an API key and stay behind the proxy. Thanks to [@lakshyaag-tavily](https://github.com/lakshyaag-tavily) for [PR #800](https://github.com/nicobailon/pi-mcp-adapter/pull/800).
23
+ - Server entries accept `"openUi": false` to stop that server's MCP App UIs from opening. Its tools still run and return their results inline. Thanks to [@tekumara](https://github.com/tekumara) for [#803](https://github.com/nicobailon/pi-mcp-adapter/issues/803).
24
+ - Other Pi extensions can add MCP features beyond tool calls, such as the draft MCP Events extension, with `registerMcpProtocol`. An extension declares the requests, streams, and notifications it uses, and the adapter sends them to your configured servers with the same sign-in, project trust, and server approval as tool calls. Extensions never get the raw connection. Registering starts no servers and adds nothing to the model's context. See [protocol extensions](docs/protocol-extensions.md). Thanks to [@mikekelly](https://github.com/mikekelly) for [PR #807](https://github.com/nicobailon/pi-mcp-adapter/pull/807).
25
+
26
+ ### Changed
27
+
28
+ - Works with Pi 1.0.0. Thanks to [@lucascaro](https://github.com/lucascaro) for [PR #801](https://github.com/nicobailon/pi-mcp-adapter/pull/801).
29
+
30
+ ### Fixed
31
+
32
+ - `pi -p` no longer hangs after replying when a kept-alive HTTP server uses a `bearerToken` command or `auth.provider`. Closing the server now ends its open event stream. Thanks to [@nguyentamdat](https://github.com/nguyentamdat) for [PR #802](https://github.com/nicobailon/pi-mcp-adapter/pull/802).
33
+ - Apps that import the adapter directly, instead of loading it through Pi, no longer fail with `Cannot find package '@earendil-works/pi-tui'`. npm now installs `@earendil-works/pi-tui` and `typebox` with the adapter, because it uses them at runtime. Installs through Pi are unchanged. Thanks to [@dannote](https://github.com/dannote) for [#805](https://github.com/nicobailon/pi-mcp-adapter/issues/805).
34
+
35
+ ## [5.0.0] - 2026-10-01
36
+
37
+ ### Highlights
38
+
39
+ - The adapter now works with Pi's own MCP setup: servers added with `pi mcp add`, servers other extensions register, sign-ins made with Pi's built-in MCP, and provider tokens from Pi's `/login` all work here.
40
+ - Far fewer servers stay running. Servers are discovered at startup and then stopped until you use them, so with 100 servers installed and 3 in use, only those 3 run.
41
+ - Servers you rarely use stay searchable. Cached tools no longer expire after a week.
42
+ - `pi-mcp-adapter doctor` checks your servers from a shell or CI.
43
+ - Long tools that report progress no longer time out, and a stray Enter can no longer approve a project server.
44
+
45
+ ### Breaking
46
+
47
+ - On Pi 0.99 and later, the adapter replaces Pi's built-in MCP extension in sessions, except when a host supplies its own config through `createMcpAdapter()`: `/mcp` opens the adapter, and the built-in no longer connects servers. On the first start after you install or update the adapter, it also turns the built-in off in Pi's user settings (`"-builtin:mcp"`, as `pi config` writes), so Pi stops warning that the built-in was not loaded. Turning it back on in `pi config` sticks. Shell `pi mcp` commands still use Pi's own files. See [Pi's built-in MCP](docs/configuration.md#pis-built-in-mcp).
48
+ - `pi-mcp-adapter/config` exports `getPiMcpGlobalConfigPath()` and `getProjectPiMcpConfigPath()` instead of `getLegacyPiMcpGlobalConfigPath()` and `getLegacyProjectPiMcpConfigPath()`.
49
+
50
+ ### Added
51
+
52
+ - On Pi 0.99 and later, the adapter also reads Pi's `~/.pi/agent/mcp.json` and `.pi/mcp.json`, so servers added with `pi mcp add` work here. Each file sits right below the `mcp-adapter.json` in its folder. Pi settings without an exact adapter equivalent are ignored, and entries the adapter can't run, such as SSE servers, are skipped; both are reported at startup, and a loaded server's ignored settings are also listed under it in `/mcp-adapter`. `.pi/mcp.json` servers need project trust and approval, and exclusive mode reads neither file. See [configuration](docs/configuration.md#file-layout).
53
+ - On Pi 0.99 and later, the adapter connects servers that other extensions add with Pi's `pi.registerMcpServer()`, so Pi no longer reports them as unconnected. They are translated like Pi's `mcp.json` entries and are proxy-only: `direct` and `deferred` exposure are ignored and reported. A config entry or an earlier `registerMcpServer()` registration of the same name wins, and the registration is reported as overridden. Registering a name again with a different config replaces the server, and unregistering disconnects it. See [the extension API](docs/extension-api.md#runtime-registration-from-other-extensions).
54
+ - On Pi 0.99 and later, sign-ins made with Pi's built-in MCP can be imported: interactive sessions ask once per OAuth server whose exact URL has a sign-in in Pi's `~/.pi/agent/mcp-auth.json` and none in the adapter, and `ctrl+p` in `/mcp-adapter` imports every eligible server. If the server rotates refresh tokens, the adapter's first refresh can sign Pi's shell `pi mcp` commands out. See [Import a sign-in from Pi's built-in MCP](docs/auth.md#import-a-sign-in-from-pis-built-in-mcp).
55
+ - HTTP servers accept `"auth": { "provider": "<name>" }`, in adapter config and Pi's `mcp.json`, to send the token of a provider you signed in to with Pi's `/login` (Pi 0.99.2 or later). The token is read on every request and sent only to the server's origin, never through a redirect. User-global config only, and `https` except on loopback. Without a token the server needs `/login <provider>`; it never starts MCP OAuth. See [Pi provider tokens](docs/auth.md#pi-provider-tokens).
56
+ - `pi-mcp-adapter doctor [--json]` checks your MCP servers from a shell or CI: each enabled server's state, tool count, and error or hint, exiting 1 when one fails. The report prints before connections close, and a failed shutdown also exits 1. It follows project trust and never starts OAuth. See [Check servers from a shell](docs/configuration.md#check-servers-from-a-shell).
57
+ - Server entries accept a `description`, the same key as Pi's `mcp.json`. `mcp({ server })` shows it, `mcp({ search })` ranks the server's tools by it, and the `/mcp-adapter` panel shows it when you expand the server, falling back to the first line of the server's instructions.
58
+
59
+ ### Changed
60
+
61
+ - Startup no longer leaves every server running until the idle timeout. At each start, the adapter discovers servers whose cached tools are missing, from an older config, or past a server-declared TTL, 10 at a time, saves them together, and stops plain `lazy` servers right away; they start again on first use. Before, only the first session discovered servers, so a server added later stayed unsearchable until it was used. A `lazy` or `lazy-keep-alive` server that fails discovery or needs sign-in is tried once per config: later sessions don't start it until its config changes or it is used. Temporary HTTP outages are retried next session.
62
+ - Cached tool metadata no longer expires after 7 days. Servers you rarely use used to drop out of search a week after the first session. An entry now stays valid until the server's config changes or a TTL the server declared runs out, and it is refreshed the next time the server connects. A prompt command whose cached arguments are out of date no longer rejects the call: it connects, refreshes them, and checks again.
63
+ - A tool call's timeout (`requestTimeoutMs`, or the MCP SDK default of 60 seconds) now restarts whenever the tool reports progress, as in Pi's built-in MCP, so a long tool that keeps reporting progress no longer times out. Tool calls always ask the server for progress, with or without a UI.
64
+ - On Pi 0.99 and later, `directTools: "search"` tools are Pi deferred tools. Pi's `tool_search` finds them, and Pi keeps their activation on the session branch, so it survives a resume. Permission extensions see their MCP annotations, and codemode scripts get their `CallToolResult`. Calls still go through the adapter's approval and output limits. See [search-activated direct tools](docs/tools.md#search-activated-direct-tools).
65
+ - Choosing direct tools is faster when many servers use `includeTools` or `excludeTools`: with 100 servers × 50 tools, about 1 second → 60 ms.
66
+ - The README is now a short overview. The full reference moved into `docs/`: configuration, server options, authentication (formerly `OAUTH.md`), using MCP tools, scripting, prompts and MCP UI, and the extension API.
67
+ - The README compares the adapter with Pi's built-in MCP on what you get by switching: with 100 servers installed and 3 used, Pi 0.99.2 keeps all 100 running (7.0 GB) while the adapter runs only the 3 in use; single tool lookups cost 10–33% fewer tokens than the built-in's default `codemode`; and with a System One key, semantic search put the right tool first in 10 of 11 test requests, where word search did in 5. See the [full comparison](docs/pi-builtin-comparison.md).
68
+
69
+ ### Fixed
70
+
71
+ - Pressing Enter at the project-server approval prompt no longer approves the server. The prompt now starts on "Don't allow", so a first prompt typed while it is open can't approve a server by accident; choose "Allow" to approve it. Thanks to [@meirm](https://github.com/meirm) for #797.
72
+ - Idle shutdown no longer closes a server that is still in use. A tool call waiting for approval, an open MCP UI page, and an accepted browser (URL) request now keep the server running, so the approved call, a UI button, or the retry after the browser step no longer fails because the server was stopped meanwhile.
73
+ - Ending or switching a session no longer prints `MCP: runtime cleanup failed: Cannot access 'scopedMaterializedResourceSessions' before initialization`, and temp files from binary MCP resources are removed again. Thanks to [@wu546526](https://github.com/wu546526) for #781.
74
+ - Connecting to Figma (desktop) while its server is off now says nothing is listening on `127.0.0.1:3845` instead of a bare `fetch failed`.
75
+ - `/mcp-adapter setup` adds Figma (desktop) to the global config instead of writing `.mcp.json` into whatever project you opened setup from.
76
+ - `/mcp-adapter setup` warns when a server you add won't be used, because another config file already defines or disables it, or the current config mode doesn't read the file it was written to.
77
+ - A bearer token or header value that isn't a valid HTTP header value, such as one containing a newline, no longer appears in connection errors. This covers `bearerToken` (including `!command` and `${VAR}` forms), `bearerTokenEnv`, and configured `headers`; the error now names the server and header instead.
10
78
  ## [4.0.0] - 2026-09-30
11
79
 
12
80
  ### Highlights
@@ -99,7 +167,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
167
 
100
168
  ### Added
101
169
 
102
- - New `pi-mcp-adapter/host-managed` entry point for apps that embed Pi and manage their own MCP connections. The app supplies the connections, records each approved call before it is sent, sees the raw result first, and decides when the adapter starts and stops. The adapter never retries a call or reconnects, and never reads config, OAuth, or keyring state. See [Host-managed embedding](README.md#host-managed-embedding). Thanks to [@LeonEthan](https://github.com/LeonEthan) for the design in [issue #716](https://github.com/nicobailon/pi-mcp-adapter/issues/716).
170
+ - New `pi-mcp-adapter/host-managed` entry point for apps that embed Pi and manage their own MCP connections. The app supplies the connections, records each approved call before it is sent, sees the raw result first, and decides when the adapter starts and stops. The adapter never retries a call or reconnects, and never reads config, OAuth, or keyring state. See [Host-managed embedding](docs/extension-api.md#host-managed-embedding). Thanks to [@LeonEthan](https://github.com/LeonEthan) for the design in [issue #716](https://github.com/nicobailon/pi-mcp-adapter/issues/716).
103
171
 
104
172
  ### Changed
105
173