pi-mcp-client 0.1.0 → 0.3.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 (3) hide show
  1. package/README.md +117 -23
  2. package/dist/index.js +736 -214
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -29,34 +29,89 @@ Start a new Pi session and ask it to search Cloudflare's documentation. Use `/mc
29
29
  to inspect the connection. For authenticated services, see [OAuth](#oauth) or
30
30
  [secret commands](#secret-commands).
31
31
 
32
- Pi searches for the tools it needs, then calls those tools directly. Search
33
- loads up to five matching tools by default, or up to 50 with `limit`. Results
34
- use local BM25-based ranking, with tool names weighted more strongly than
35
- descriptions and support for prefix matching. Full schemas become available on
36
- the next model turn, without a separate describe step. Previously loaded tools
37
- remain available as the conversation continues.
32
+ Pi discovers candidates, explicitly activates the tools it needs, then calls
33
+ those tools natively. One `mcp_tools` tool supports both steps:
34
+
35
+ ```js
36
+ // Discover candidates. Never activates, even for an exact-name query.
37
+ mcp_tools({ query: "list teams", server: "linear", limit: 5 })
38
+
39
+ // Activate exact identifiers. Never invokes.
40
+ mcp_tools({ activate: ["linear.list_teams", "linear.get_team"] })
41
+ ```
42
+
43
+ Pass exactly one of `query` or `activate`. The optional `server` and `limit`
44
+ fields are valid only with `query`. Discovery returns up to five candidates by
45
+ default, or up to 50 with `limit`. Each candidate shows its exact activation
46
+ identifier, a short description, required parameter names only, and `[loaded]`
47
+ if already active. Results use local BM25-based ranking, with tool names weighted
48
+ more strongly than descriptions and support for prefix matching.
49
+
50
+ Activation accepts 1–50 exact `server.tool` or `mcp__server__tool` identifiers,
51
+ ignores duplicates, and works without a prior search. Typos never activate fuzzy
52
+ matches: failures list nearby catalog names when available so the assistant can
53
+ retry with an exact identifier. Each identifier reports `loaded`, `already loaded`,
54
+ or `not loaded` with a reason. Partial success keeps the tools that loaded.
55
+
56
+ Full schemas become available on the model turn after activation. First use of a
57
+ capability now takes three turns—discover, activate, call—so a fuzzy search match
58
+ can never become an active tool. Previously loaded tools remain available.
59
+
60
+ `mcp_tools` replaces `mcp_search` without backward compatibility. Update explicit
61
+ Pi tool allowlists to use `mcp_tools` and activate the tools you need again in
62
+ existing sessions. The UI labels discovery calls **mcp discover** and activation
63
+ calls **mcp activate**.
64
+
65
+ ### Result display
66
+
67
+ Discovery rows show `○` for inactive candidates and `●` for already active tools,
68
+ without a status suffix. These reflect the state when discovery runs; earlier
69
+ results don't update retroactively. Activation results use `✔︎` for success and
70
+ `✘︎` for failure. Descriptions stay gray; identifiers remain prominent.
71
+
72
+ Expand a tool result to see JSON objects and arrays formatted with two-space
73
+ indentation and syntax highlighting. Explicit JSON resource MIME types (including
74
+ `application/*+json`) and structured content identify JSON without guessing.
75
+ Other explicit MIME types stay plain text; unlabeled text is checked for JSON.
76
+
77
+ Formatting changes only the display, not the response sent to the assistant.
78
+ Invalid or truncated JSON stays plain text. Results that would exceed formatting
79
+ limits also stay plain text. Resource-link MIME types describe the linked content,
80
+ not the displayed link label.
38
81
 
39
82
  ### Session behavior
40
83
 
41
84
  - Tools accumulate rather than rotating with each prompt.
42
- - Resume and branch navigation restore tools acquired on the selected branch.
85
+ - Resume and branch navigation restore tools activated through `mcp_tools` on
86
+ the selected branch. Discovery results never restore tools.
43
87
  - Compaction retains the acquired tool set. New sessions start fresh.
44
88
  - Pi uses native deferred loading where supported by the model and provider.
45
89
  Other providers receive the expanded tool list normally.
46
- - Search respects server filters and Pi's tool exclusions. An explicit tool
47
- allowlist must include both `mcp_search` and the native tools you want to load.
90
+ - Discovery respects server filters; activation also respects Pi's tool exclusions. An explicit tool
91
+ allowlist must include both `mcp_tools` and the native tools you want to load.
48
92
 
49
93
  ### Commands
50
94
 
51
95
  | Command | Purpose |
52
96
  | --- | --- |
53
- | `/mcp` | Show server connection status, catalog sizes, and the loaded tool count. |
97
+ | `/mcp`, `/mcp list`, `/mcp status` | Show a server status matrix with catalog and loaded-tool counts. |
98
+ | `/mcp inspect <server>` | Inspect status and configuration, including disabled servers. Connection values are hidden. |
99
+ | `/mcp tools <server>` | Browse the server's tools and inspect descriptions without activating tools. |
100
+ | `/mcp reload` | Apply configuration changes without restarting Pi. |
101
+ | `/mcp enable <server>` | Enable a server in its effective configuration file. |
102
+ | `/mcp disable <server>` | Disable a server, close its connection, and deactivate its tools. |
54
103
  | `/mcp auth <server>` | Authenticate an OAuth-enabled HTTP server. |
55
104
  | `/mcp reconnect <server>` | Replace a connection and refresh its catalog. |
56
105
  | `/mcp refresh <server>` | Refresh a server's catalog without loading additional tools. |
57
106
 
58
- After refreshing a changed schema, search for the tool again to load its current
59
- definition. Calls validate the live catalog before execution and refuse removed
107
+ The status matrix uses glyphs to distinguish idle (`○`), connected (`●`),
108
+ connecting (`▶︎`), disabled (`○`), and failed (`✘︎`) servers. Idle is normal:
109
+ connections open on demand. A dash (`—`) means the catalog hasn't been fetched,
110
+ not that the server has no tools. The **Loaded** column counts tools currently
111
+ active for the assistant.
112
+
113
+ After refreshing a changed schema, activate the tool again with its exact
114
+ identifier to load its current definition. Calls validate the live catalog before execution and refuse removed
60
115
  or changed tools. The extension does not retry failed tool invocations; after an
61
116
  interrupted call, check whether the operation completed before trying again.
62
117
 
@@ -136,12 +191,12 @@ Commands use `/bin/sh` on Unix or Pi's shell selection on Windows, inherit Pi's
136
191
  process environment, and run in the server's configured `cwd` (the project
137
192
  directory by default). They run once per connection, including reconnections,
138
193
  not during configuration loading, status display, or cached discovery. Cold
139
- searches can connect and therefore execute commands. Concurrent connection
194
+ searches and activations can connect and therefore execute commands. Concurrent connection
140
195
  requests share the same resolution.
141
196
 
142
197
  The client trims stdout and rejects empty output, nonzero exits, output above
143
198
  64 KiB, and resolution taking more than 10 seconds (or a shorter `timeoutMs`).
144
- Session shutdown cancels pending commands. Cancelling an individual search stops
199
+ Session shutdown cancels pending commands. Cancelling an individual search or activation stops
145
200
  waiting but leaves shared connection work running for other callers. The client
146
201
  discards command stderr and does not include resolved secrets in errors, session
147
202
  records, or catalog caches. Commands themselves remain responsible for avoiding
@@ -185,22 +240,60 @@ Every definition must include a `url` or `command`, even when `disabled` is true
185
240
  These options are specific to Pi MCP Client, not standardized MCP connection
186
241
  fields. Other clients may reject them when you copy a definition.
187
242
 
188
- Configuration changes take effect when Pi reloads the extension or starts a new
189
- session.
243
+ After editing your configuration, run `/mcp reload` to apply it without restarting
244
+ Pi. Reload validates the new configuration before replacing the current setup;
245
+ invalid configuration leaves the previous setup intact. It closes existing
246
+ connections, which reopen on demand, and deactivates tools from changed, removed,
247
+ or disabled server definitions. Unchanged active tools remain available.
248
+
249
+ To toggle a server without editing JSON, use `/mcp disable <server>` or
250
+ `/mcp enable <server>`. The change persists in the trusted project's `.mcp.json`
251
+ if that file defines the server; otherwise, it persists in the global
252
+ `~/.pi/agent/mcp.json`. Untrusted project files are neither read nor changed.
253
+ The command reports which scope changed. It updates only the `disabled` option,
254
+ preserves other values (including secret references), and reformats the file as
255
+ indented JSON. Repeating a toggle that's already set leaves the file unchanged.
256
+
257
+ Both commands wait for active agent work to finish, then apply configuration as
258
+ `/mcp reload` does: connections close and reopen on demand, while unchanged active
259
+ tools from other servers remain available. Disabling removes the server from
260
+ search and deactivates its tools. Enabling does not connect, authenticate, or load
261
+ tools; ask the assistant to discover the capabilities you need. Other running Pi
262
+ sessions pick up the saved change when they reload their MCP configuration.
263
+
264
+ Use `/mcp inspect <server>` to check the effective transport, protocol, filters,
265
+ and connection status without connecting or running secret commands. Connection
266
+ values—including commands, arguments, URLs, headers, and environment variables—
267
+ are hidden because any of them can contain credentials.
268
+
269
+ Use `/mcp tools <server>` to fetch the current catalog and browse a scrollable
270
+ list. Each row shows the tool name and description, trimmed to the terminal width
271
+ with an ellipsis. Select a tool to see a multiline signature and parameter details,
272
+ with each parameter in a separate paragraph. Browsing respects your include and
273
+ exclude filters and doesn't activate tools or add their schemas to the assistant's
274
+ context. This command requires an interactive UI.
190
275
 
191
276
  ### Discovery and caching
192
277
 
193
278
  Connections start on demand, never while the extension factory loads. A search
194
279
  without a cached catalog contacts configured servers, with at most four discoveries
195
- in flight. A server-scoped search only contacts that server. Failed servers are
196
- reported as unsearched, not mistaken for an empty catalog.
280
+ in flight. A server-scoped search only contacts that server. Activation discovers
281
+ only the servers named by its identifiers, with the same concurrency bound.
282
+ Failed servers are reported as unavailable, not mistaken for an empty catalog.
197
283
 
198
284
  Catalogs are cached privately under `~/.pi/agent/cache/pi-mcp-client/`, keyed by
199
285
  server configuration and working directory. Disk caches expire after 24 hours.
200
- They contain tool metadata, not configured credentials. Cached search needs no
201
- connection; invocation refreshes the live catalog before calling the tool.
286
+ They contain tool metadata, not configured credentials. Cached discovery and
287
+ activation need no connection; invocation refreshes the live catalog before
288
+ calling the tool.
202
289
  Connections remain open until shutdown or explicit reconnection.
203
290
 
291
+ When a connected server reports a tool-list change, the extension invalidates its
292
+ memory and disk catalogs. The next discovery or activation fetches the current
293
+ list, including new or removed tools. Notifications don't replace active tool
294
+ definitions: changed schemas require another `mcp_tools({activate: [...]})` before use. Disconnected, cache-only searches
295
+ can't receive notifications and still use the 24-hour disk-cache expiry.
296
+
204
297
  ### OAuth
205
298
 
206
299
  Set `"oauth": true` under `mcpServers.<server>` in `mcp.json`, without an
@@ -225,8 +318,9 @@ Only load configuration you trust. Server executables and secret commands run
225
318
  with your user permissions; trusted project configuration can replace global
226
319
  connections and settings.
227
320
 
228
- Server metadata is untrusted. Search activates tools but does not approve their
229
- side effects or provide per-call confirmation. Use tool filters and Pi permission
321
+ Server metadata is untrusted. Discovery never activates tools. Explicit
322
+ activation exposes schemas but does not approve tool side effects or provide
323
+ per-call confirmation. Use tool filters and Pi permission
230
324
  extensions for additional controls. Cancelling a call does not guarantee that the
231
325
  server rolled back its effects.
232
326
 
@@ -267,7 +361,7 @@ unavailable server is not an empty catalog.
267
361
  | `connection_failed` | Server executable, working directory, endpoint, network, and TLS configuration. |
268
362
  | `timeout` | Server responsiveness and the applicable request, secret-command, or OAuth time limit. |
269
363
  | `protocol_error` | Server compatibility and the `protocol` setting. |
270
- | `tool_changed` | Server filters and the current tool schema; search again. Reload Pi if connection configuration changed. |
364
+ | `tool_changed` | Server filters and the current tool schema; activate the exact identifier again. Reload Pi if connection configuration changed. |
271
365
  | `tool_error` | The server's tool result and inputs; verify the outcome before retrying. |
272
366
  | `oauth_failed` | Browser access to the callback and support for dynamically registered public clients. |
273
367
  | `callback_unavailable` | Another process using local port 19847. |