pi-mcp-client 0.4.0 → 0.6.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.
@@ -0,0 +1,294 @@
1
+ # Commands
2
+
3
+ [Back to the README](../README.md)
4
+
5
+ These are commands **you run in Pi**, not tools the assistant calls. Use them to
6
+ manage servers, inspect capabilities, use prompts, and watch resource changes. The assistant's
7
+ separate interface is documented in the [tool reference](tool-reference.md).
8
+
9
+ ## Command reference
10
+
11
+ | Command | Purpose |
12
+ | --- | --- |
13
+ | `/mcp`, `/mcp list`, `/mcp status` | Show a server status matrix with catalog and loaded-tool counts. |
14
+ | `/mcp add --scope <scope> [options] <server> <url>` | Save an HTTP server without connecting. For stdio, use `<server> -- <command> [args...]`. |
15
+ | `/mcp remove --scope <scope> <server>` | Remove a definition from the selected scope, retaining credentials. |
16
+ | `/mcp import --scope <scope> <path>` | Preview and select servers from Claude/Cursor JSON or Codex TOML, then confirm a scoped import. |
17
+ | `/mcp get <server>` | Inspect status and configuration, including disabled servers. Connection values are hidden. |
18
+ | `/mcp tools <server>` | Browse the server's tools and inspect descriptions without activating tools. |
19
+ | `/mcp prompts <server>` | Browse prompt metadata, then select a prompt and enter arguments. |
20
+ | `/mcp prompt <server> <name> [argument=value ...]` | Open a named prompt with prefilled arguments, then fetch and review a preview. |
21
+ | `/mcp reload` | Apply configuration changes without restarting Pi. |
22
+ | `/mcp enable <server>` | Enable a server in its effective configuration file. |
23
+ | `/mcp disable <server>` | Disable a server, close its connection, and deactivate its tools. |
24
+ | `/mcp login <server> [--no-browser]` | Authenticate an HTTP server without changing its configuration; optionally paste the callback URL in an interactive dialog. |
25
+ | `/mcp logout <server>` | Remove local OAuth credentials and attempt remote revocation, including for disabled servers. |
26
+ | `/mcp reconnect <server>` | Replace a connection and refresh its catalog. |
27
+ | `/mcp refresh <server>` | Refresh tool, resource, and prompt metadata without fetching content or loading additional tools. |
28
+ | `/mcp subscribe <server> <uri>` | Watch changes to one exact resource URI without fetching content. |
29
+ | `/mcp unsubscribe <server> <uri>` | Stop watching one resource. |
30
+ | `/mcp subscriptions` | List active resource watches and their change markers. |
31
+
32
+ See [Authentication](authentication.md) for login and logout procedures, and
33
+ [Apply changes](configuration.md#apply-changes) for reload behavior.
34
+
35
+ ## Inspect servers and tools
36
+
37
+ The `/mcp` status matrix distinguishes idle (`○`), connected (`●`), connecting
38
+ (`▶︎`), disabled (`○`), and failed (`✘︎`) servers. Idle is normal: connections open
39
+ on demand. A dash (`—`) means the catalog hasn't been fetched, not that the server
40
+ has no tools. The **Loaded** column counts tools currently active for the
41
+ assistant.
42
+
43
+ Use `/mcp get <server>` to check the effective transport, protocol, filters,
44
+ and connection status without connecting or running secret commands. Connection
45
+ values—including commands, arguments, URLs, headers, and environment variables—
46
+ are hidden because any of them can contain credentials. Authentication status
47
+ shows whether OAuth tokens are stored, not whether they are valid. A locked or
48
+ unavailable credential store is reported separately from missing tokens. Header
49
+ and stdio credentials are identified as externally managed; inspection never
50
+ executes them.
51
+
52
+ Use `/mcp tools <server>` to fetch the current catalog and browse a scrollable
53
+ list. Rows show tool names and descriptions, trimmed to the terminal width with
54
+ an ellipsis. Select a tool to see a multiline signature and parameter details,
55
+ with each parameter in a separate paragraph. Browsing respects your include and
56
+ exclude filters and doesn't activate tools or add their schemas to the assistant's
57
+ context. This command requires an interactive UI.
58
+
59
+ Refreshing a catalog doesn't replace active tool definitions. After a schema
60
+ change, ask the assistant to activate the exact tool again. See
61
+ [tool changes and caching](behavior.md#discovery-and-caching). Failed tool calls
62
+ aren't retried automatically; verify whether an interrupted operation completed
63
+ before trying again.
64
+
65
+ ## Use server prompts
66
+
67
+ Prompts are server-maintained task instructions that **you** choose to use. For a
68
+ server that provides an `explain` prompt, browse or open it directly:
69
+
70
+ ```text
71
+ /mcp prompts docs
72
+ /mcp prompt docs explain topic="OAuth flows"
73
+ ```
74
+
75
+ 1. Select a prompt. Browsing fetches metadata only and doesn't add anything to the
76
+ conversation.
77
+ 2. Select an argument to edit its string value. Required arguments must be supplied;
78
+ optional arguments can remain omitted. An empty string is distinct from an
79
+ omitted value. Inline `argument=value` pairs prefill the editor. Quoting follows
80
+ the configuration commands' rules, without shell or environment expansion.
81
+ 3. Choose **Fetch preview** to send the arguments to the selected MCP server.
82
+ Your conversation and local files aren't automatically shared. Argument values
83
+ are limited to 4,096 characters each and 64 KiB in total.
84
+ 4. Review the source-labeled messages using **Next page** and **Previous page**.
85
+ Choose **Back** to change arguments, or **Cancel** to discard the preview.
86
+ 5. Choose **Use prompt** to send exactly the reviewed snapshot to the model and
87
+ start a turn. This saves the content in the session. No second fetch occurs.
88
+
89
+ Text and embedded text resources are supported. Images, audio, binary resources,
90
+ and other unsupported blocks are identified in the preview and prevent use of the
91
+ whole prompt; they aren't silently omitted. Prompts exceeding 2,000 lines or
92
+ 50 KiB are refused, not truncated or written to spill files. Links aren't followed.
93
+
94
+ These commands require an interactive TUI or RPC session. In the TUI, press Escape
95
+ to cancel a pending fetch. Cancelling doesn't undo arguments already sent to the
96
+ server. Using a prompt doesn't activate tools or approve their side effects. See
97
+ [prompt snapshots](behavior.md#prompt-snapshots) for trust and lifecycle behavior.
98
+
99
+ ## Enable and disable servers
100
+
101
+ Use `/mcp disable <server>` or `/mcp enable <server>` to change the `disabled`
102
+ option without editing JSON. The command reports which scope changed: the trusted
103
+ project's `.mcp.json` if it defines the server, otherwise the global
104
+ `~/.pi/agent/mcp.json`. Untrusted project files are neither read nor changed.
105
+
106
+ Toggles preserve other values, including secret references, and reformat the file
107
+ as indented JSON. Repeating a toggle that's already set leaves the file unchanged.
108
+ Both commands wait for active agent work to finish, then
109
+ [apply the configuration](configuration.md#apply-changes).
110
+
111
+ Disabling removes the server from discovery and deactivates its tools. Enabling
112
+ doesn't connect, authenticate, or load tools; ask the assistant to discover the
113
+ capabilities you need.
114
+
115
+ ## Add and remove servers
116
+
117
+ Both commands require an explicit `--scope global` or `--scope project`:
118
+
119
+ - **Global:** `~/.pi/agent/mcp.json`.
120
+ - **Project:** `.mcp.json` in the current trusted project. Untrusted project files
121
+ are neither read nor changed.
122
+
123
+ Add an HTTP server by URL, or a stdio server after `--`:
124
+
125
+ ```text
126
+ /mcp add --scope global docs https://docs.mcp.cloudflare.com/mcp
127
+ /mcp add --scope project local -- node "/path with spaces/server.js"
128
+ ```
129
+
130
+ Put options before the server name. `--transport http` or `--transport stdio` is
131
+ optional; the URL form selects HTTP and the `--` form selects stdio. Arguments
132
+ support single and double quotes and backslash escaping, but are never evaluated
133
+ by a shell. Shell syntax such as `$(...)`, pipes, and globs stays literal. For
134
+ Windows paths with backslashes, single quotes preserve the path verbatim.
135
+
136
+ | Option | Purpose |
137
+ | --- | --- |
138
+ | `--replace` | Replace the complete definition in the selected scope, or create an override of a same-named definition in the other scope. Existing fields aren't merged. |
139
+ | `--header 'Name: value'` | Add an HTTP header. Repeat for different header names. |
140
+ | `--env KEY=value` | Add a stdio environment override. Repeat for different variable names. |
141
+ | `--oauth-client-id ID` | Use a pre-registered public client. |
142
+ | `--oauth-scope SCOPE` | Request an OAuth scope. Repeat for additional scopes. |
143
+ | `--oauth-callback-port PORT` | Set the loopback callback port. |
144
+
145
+ Retain environment references rather than typing tokens:
146
+
147
+ ```text
148
+ /mcp add --scope global --header 'Authorization: Bearer ${DOCS_TOKEN}' docs https://mcp.example.com/mcp
149
+ /mcp add --scope global --oauth-client-id '${CLIENT_ID}' service https://mcp.example.com/mcp
150
+ ```
151
+
152
+ Define referenced environment variables before running the command. Validation
153
+ checks the resolved configuration, but saves the references, not their values.
154
+ Secret commands in headers or environment overrides are saved without running
155
+ them. Avoid literal credentials in command input or project files; use
156
+ [environment references and secret commands](configuration.md#secret-commands).
157
+
158
+ Adding never starts a server, opens a browser, or activates tools. Duplicate names
159
+ in global or trusted project configuration are rejected unless you supply
160
+ `--replace`. Project definitions take precedence; writing a global definition
161
+ doesn't replace a project override. Other server options, such as tool filters,
162
+ remain available by editing the configuration file.
163
+
164
+ Remove a definition from a specific scope:
165
+
166
+ ```text
167
+ /mcp remove --scope project local
168
+ ```
169
+
170
+ Removal is distinct from disabling and logout: it deletes the selected definition,
171
+ not its OAuth credentials. Run `/mcp logout <server>` first if you also want to
172
+ remove credentials. Removing a project override exposes any same-named global
173
+ definition; the command reports when a definition in the other scope remains.
174
+ Removing a name absent from the selected scope fails without changing either file.
175
+
176
+ Successful edits [apply immediately](configuration.md#apply-changes). Writes
177
+ preserve unrelated settings, follow existing file symlinks, and replace files
178
+ atomically. New files are private; existing file permissions are preserved. If
179
+ global and project configuration point to the same file, scoped edits are refused
180
+ until you separate them. Empty configuration files are retained rather than deleted.
181
+
182
+ ## Import server definitions
183
+
184
+ Import directly from an explicitly named local file. JSON and TOML are detected
185
+ automatically; no conversion file is needed:
186
+
187
+ ```text
188
+ /mcp import --scope global ~/.codex/config.toml
189
+ /mcp import --scope global ~/.claude.json
190
+ /mcp import --scope project "/path with spaces/mcp.json"
191
+ ```
192
+
193
+ The command requires an interactive TUI or RPC session and an explicit
194
+ `--scope global` or `--scope project`. Project scope requires a trusted project.
195
+ Relative source paths resolve against Pi's current directory; `~/` is supported.
196
+ The path isn't evaluated by a shell, and no application settings are scanned.
197
+
198
+ 1. If the source contains other top-level settings, confirm that only MCP server
199
+ definitions should be considered. Model, permission, and credential-store
200
+ settings aren't imported.
201
+ 2. For a Claude file containing `projects.<path>.mcpServers`, choose a source
202
+ group or **All groups**. Global and project definitions remain separate during
203
+ review. A source project doesn't select or authorize the destination scope.
204
+ 3. Review each server's name, transport, enabled state, and any validation or
205
+ unsupported-field problems. Commands, arguments, URLs, headers, and environment
206
+ values stay hidden. Review the original file before importing connections you
207
+ don't already trust. Unsupported entries can only be skipped; their fields
208
+ aren't silently dropped.
209
+ 4. Choose **Skip**, add the definition, or **Choose a different name**. Name
210
+ conflicts require an explicit replacement or override choice. A replacement
211
+ replaces the entire definition, including headers and environment variables;
212
+ credentials and other fields aren't merged. A global import shadowed by a
213
+ project definition is labeled as such and doesn't change the effective server.
214
+ 5. Review the selected destination names and actions, then confirm the import.
215
+ The confirmation warns that inline credentials are copied with the selected
216
+ definitions. Existing Pi OAuth credentials are retained, but no external
217
+ credential store is read or migrated.
218
+
219
+ Nothing is saved until the final confirmation. Cancellation, a session or trust
220
+ change, or a changed destination configuration prevents saving the preview. All
221
+ selected definitions are validated and written together using one atomic file
222
+ replacement, then applied through the normal configuration reconciliation.
223
+ The source snapshot isn't reread after confirmation, and the source and
224
+ destination cannot be the same file. No server starts, secret command runs,
225
+ login opens, or tool activates during import. Enabled connections become
226
+ available on demand afterward; imported disabled servers stay disabled.
227
+
228
+ ### Supported formats
229
+
230
+ Files must be UTF-8 and are limited to 1 MiB and 100 servers across all source
231
+ groups. Only stdio and Streamable HTTP are supported. JSON comments, JSON trailing
232
+ commas, SSE, VS Code, and MCPorter formats aren't supported. TOML comments,
233
+ multiline strings, quoted keys, and trailing commas follow TOML syntax.
234
+
235
+ **Claude/Cursor JSON:** Read a top-level `mcpServers` object and, for Claude,
236
+ `projects.<path>.mcpServers` groups. Supported server fields are `type`, `command`,
237
+ `args`, `cwd`, `env`, `url`, `headers`, `disabled`, and `description`.
238
+ `${VAR}` references are preserved and must resolve in Pi before import. Default
239
+ expressions and client-specific variables such as `${env:TOKEN}` or
240
+ `${workspaceFolder}` are refused rather than translated. In environment and
241
+ header values, bare `$VAR` and leading `!` remain literal: the importer escapes
242
+ them so they don't become Pi variable expansions or secret commands.
243
+
244
+ **Codex TOML:** Read the `mcp_servers` table, with these mappings:
245
+
246
+ | Codex setting | Imported setting |
247
+ | --- | --- |
248
+ | `command`, `args`, `cwd`, `url` | Copied without resolving values. Literal `${...}` in these fields is refused because Pi would interpolate it. |
249
+ | `enabled` | Inverted to `disabled`. |
250
+ | `env`, `http_headers` | Literal environment/header values, including literal `${VAR}`, `$VAR`, and `!`. |
251
+ | `env_vars`, `env_http_headers`, `bearer_token_env_var` | Unresolved environment references, not copies of their current values. Overlapping entries are refused. |
252
+ | `startup_timeout_sec` or `startup_timeout_ms` | `startupTimeoutMs`, defaulting to Codex's 10 seconds. Both source options together are refused. |
253
+ | `tool_timeout_sec` | `toolTimeoutMs`, defaulting to Codex's 60 seconds. |
254
+ | `enabled_tools`, `disabled_tools` | `includeTools`, `excludeTools`. Names containing `*` are refused rather than converted into wildcard patterns. |
255
+ | `scopes` | `oauthScopes`. |
256
+
257
+ Timeouts must fit Pi's 100–600000 ms range. Startup and tool deadlines stay
258
+ separate; they don't replace the timeout for metadata or resource requests.
259
+ Only local execution is supported. `required = true`, remote environment
260
+ placement, remote `env_vars` entries, and per-server/tool approval policies are
261
+ refused rather than dropped. `required = false` and
262
+ `experimental_environment = "local"` are accepted.
263
+
264
+ For either format, relative executable, argument, and working-directory paths
265
+ retain Pi's path semantics, not the source application's or import file's
266
+ directory; verify them before importing.
267
+
268
+ ## Watch resource changes
269
+
270
+ Subscriptions are explicit user commands, not model-facing tool operations:
271
+
272
+ ```text
273
+ /mcp subscribe warehouse schema://tables/events
274
+ /mcp subscriptions
275
+ /mcp unsubscribe warehouse schema://tables/events
276
+ ```
277
+
278
+ Use an exact absolute URI from discovery, a template read, or a resource link.
279
+ The configured server must support resource subscriptions. The extension uses the
280
+ SDK's negotiated protocol: legacy resource subscriptions or modern filtered
281
+ streams. It never opens the URI as a file or generic URL.
282
+
283
+ An update marks the watch as changed (`↻`) and shows a UI notification. Repeated
284
+ updates coalesce into that marker until you unsubscribe. No content is fetched,
285
+ no model turn starts, and existing resource results remain unchanged. Ask the
286
+ assistant to read the resource for a new snapshot; unsubscribe and subscribe again
287
+ to reset the change marker.
288
+
289
+ Watches are memory-only, limited to 50 per server connection, and require an
290
+ interactive UI (TUI or RPC). Repeating a subscribe command is idempotent. Session
291
+ replacement, tree navigation, configuration reload, disconnection, and exit clear
292
+ the affected watches. They are never restored or automatically retried; use
293
+ `/mcp subscriptions` to inspect active watches. Cancellation and connection
294
+ failures can leave an uncertain server-side outcome; cleanup is best-effort.
@@ -0,0 +1,159 @@
1
+ # Configuration
2
+
3
+ [Back to the README](../README.md)
4
+
5
+ You configure which servers the assistant can access. Add connections to
6
+ `~/.pi/agent/mcp.json`, or `.mcp.json` in a trusted project. For command-based
7
+ setup, see [Add and remove servers](commands.md#add-and-remove-servers). To reuse
8
+ an existing Claude/Cursor JSON or Codex TOML file, see
9
+ [Import server definitions](commands.md#import-server-definitions).
10
+
11
+ ## Files and transports
12
+
13
+ The files use the common Claude/Cursor-style `mcpServers` format, not a universal
14
+ MCP configuration standard. Live configuration must use JSON, not VS Code's
15
+ `servers` format or Codex TOML. The import command can translate Codex TOML into
16
+ this format. `PI_CODING_AGENT_DIR` overrides the global Pi directory.
17
+ Project definitions replace same-named global definitions in full; fields and
18
+ filters aren't merged. Untrusted project definitions aren't loaded or edited.
19
+ An explicitly named import source is read as data for review; saving into project
20
+ scope still requires project trust.
21
+
22
+ ```json
23
+ {
24
+ "mcpServers": {
25
+ "docs": {
26
+ "url": "https://mcp.example.com/mcp",
27
+ "headers": {
28
+ "Authorization": "Bearer ${DOCS_TOKEN}"
29
+ }
30
+ },
31
+ "local": {
32
+ "command": "node",
33
+ "args": ["/absolute/path/to/server.js"],
34
+ "env": {
35
+ "DATABASE_URL": "${DATABASE_URL}"
36
+ }
37
+ }
38
+ }
39
+ }
40
+ ```
41
+
42
+ | Field | Purpose |
43
+ | --- | --- |
44
+ | `type` | Optional `stdio` or `http`. If omitted, inferred from `command` or `url`. A conflicting type is rejected. |
45
+ | `command`, `args` | Executable and arguments for a stdio server. No shell is used. |
46
+ | `cwd` | Working directory for stdio; defaults to Pi's current directory. Relative paths resolve there. |
47
+ | `env` | Additional environment variables for stdio. |
48
+ | `url` | Streamable HTTP endpoint; mutually exclusive with `command`. |
49
+ | `headers` | HTTP request headers, including optional bearer authentication. |
50
+
51
+ Strings in `command`, `args`, `cwd`, `env`, `url`, and `headers` support `${VAR}`
52
+ interpolation. Missing variables prevent that server from connecting.
53
+
54
+ Only stdio and Streamable HTTP are supported. The extension rejects `type: "sse"`
55
+ and unsupported connection fields rather than silently changing their meaning.
56
+
57
+ The extension uses `@modelcontextprotocol/client` 2.0.0 and defaults to automatic
58
+ SDK protocol-version negotiation. On stdio, negotiation probes using an additional
59
+ short-lived process. Set `"protocol": "legacy"` if the server requires an explicit
60
+ legacy handshake.
61
+
62
+ ## Secret commands
63
+
64
+ In **`headers` and stdio `env` values only**, a leading `!` runs a secret-generating
65
+ shell command when the server connects:
66
+
67
+ ```json
68
+ {
69
+ "mcpServers": {
70
+ "example": {
71
+ "url": "https://mcp.example.com/mcp",
72
+ "headers": {
73
+ "Authorization": "!token=$(op read 'op://Private/Example/token') && printf 'Bearer %s' \"$token\""
74
+ }
75
+ }
76
+ }
77
+ }
78
+ ```
79
+
80
+ These two fields also support Pi-style `$VAR` interpolation, `$$` for a literal
81
+ `$`, and `$!` for a literal `!`. Only a leading `!` in the original configuration
82
+ triggers execution; interpolated values and command output never do. Shell
83
+ commands handle their own variable expansion.
84
+
85
+ Commands use `/bin/sh` on Unix or Pi's shell selection on Windows, inherit Pi's
86
+ process environment, and run in the server's configured `cwd` (the project
87
+ directory by default). They run once per connection, including reconnections,
88
+ not during configuration loading, status display, or cached discovery. Cold
89
+ searches and activations can connect and therefore execute commands. Concurrent
90
+ connection requests share the same resolution.
91
+
92
+ The extension trims stdout and rejects empty output, nonzero exits, output above
93
+ 64 KiB, and resolution taking more than 10 seconds (or a shorter `timeoutMs`).
94
+ Session shutdown cancels pending commands. Cancelling an individual search or
95
+ activation stops waiting but leaves shared connection work running for other
96
+ callers.
97
+
98
+ The extension discards command stderr and doesn't include resolved secrets in
99
+ errors, session records, or catalog caches. Commands themselves remain responsible
100
+ for avoiding side effects or writing secrets to disk. Only configure commands you
101
+ trust; project configuration still requires project trust.
102
+
103
+ ## Pi-specific options
104
+
105
+ Put descriptions, authentication choices, filters, and timeouts directly in each
106
+ server definition:
107
+
108
+ ```json
109
+ {
110
+ "mcpServers": {
111
+ "docs": {
112
+ "url": "https://mcp.example.com/mcp",
113
+ "description": "Search product documentation",
114
+ "includeTools": ["get_*", "search_*"]
115
+ }
116
+ }
117
+ }
118
+ ```
119
+
120
+ | Field | Purpose |
121
+ | --- | --- |
122
+ | `description` | Short capability description for the assistant's server directory. |
123
+ | `oauthClientId` | Optional pre-registered public client ID. Supports `${ENV_VAR}` interpolation, not secret commands. |
124
+ | `oauthScopes` | Optional array of 1–100 unique OAuth scope tokens to request at login. Omitted scopes use SDK/server defaults. Values are literal, without interpolation. |
125
+ | `oauthCallbackPort` | Optional loopback callback port, from 1 to 65535. Defaults to `19847`. |
126
+ | `disabled` | Prevent this server from connecting or exposing tools and resources. |
127
+ | `includeTools` | Optional allowlist of original MCP tool names; `*` matches any sequence. An empty list exposes no tools. |
128
+ | `excludeTools` | Denylist applied after `includeTools`. |
129
+ | `timeoutMs` | Request timeout, from 100 to 600000 ms. Defaults: 15 seconds for discovery/HTTP requests, 30 seconds for stdio tool calls. |
130
+ | `startupTimeoutMs` | Optional timeout for SDK connection setup and protocol negotiation, from 100 to 600000 ms. Defaults to `timeoutMs` or 15 seconds. |
131
+ | `toolTimeoutMs` | Optional timeout for tool calls only, from 100 to 600000 ms. Overrides `timeoutMs` for calls without changing metadata or resource deadlines. |
132
+ | `protocol` | `auto` (default) for SDK protocol-version negotiation, or `legacy` for an explicit legacy handshake. |
133
+
134
+ OAuth client IDs, scopes, and callback ports require HTTP without an Authorization
135
+ header. HTTP authentication is automatic; remove the obsolete `oauth` field from
136
+ existing definitions. See [authentication](authentication.md).
137
+
138
+ Every definition must include a `url` or `command`, even when `disabled` is true.
139
+ These options are specific to Pi MCP Client, not standardized MCP connection
140
+ fields. Other clients may reject them when you copy a definition. The import command
141
+ accepts only its documented subset of server fields and refuses unsupported
142
+ entries rather than dropping options.
143
+
144
+ Tool filters don't restrict resource reads. See
145
+ [trust and permissions](behavior.md#trust-and-permissions) for access boundaries
146
+ and [authentication](authentication.md) for OAuth setup.
147
+
148
+ ## Apply changes
149
+
150
+ After editing a file, run `/mcp reload`. The extension validates the new
151
+ configuration before replacing the current setup; invalid configuration leaves
152
+ the previous setup intact. Reload closes connections, which reopen on demand,
153
+ and deactivates tools from changed, removed, or disabled definitions. Unchanged
154
+ active tools remain available.
155
+
156
+ Server-management commands apply saved changes using the same reconciliation.
157
+ Other running Pi sessions pick up those changes when you reload their MCP
158
+ configuration. See [Commands](commands.md) for toggling, inspecting, adding, and
159
+ removing servers.
@@ -0,0 +1,157 @@
1
+ # Assistant tool reference
2
+
3
+ [Back to the README](../README.md)
4
+
5
+ This page documents **the assistant's interface**. The examples illustrate tool
6
+ calls the assistant makes; they aren't slash commands or JavaScript for you to
7
+ run. Describe your task in natural language. For operations you control directly,
8
+ see [Commands](commands.md).
9
+
10
+ The `mcp_tools` tool supports four mutually exclusive operations:
11
+
12
+ | Operation | What the assistant can do | What it doesn't do |
13
+ | --- | --- | --- |
14
+ | `query` | Discover tool, resource, and prompt metadata. | Read content or activate tools. |
15
+ | `activate` | Load full schemas for exact tool identifiers. | Invoke tools. |
16
+ | `read` | Fetch one resource as conversation context. | Activate tools or follow links automatically. |
17
+ | `complete` | Request server suggestions for a template variable. | Read resources, activate tools, or select a value. |
18
+
19
+ The assistant passes exactly one of `query`, `activate`, `read`, or `complete`.
20
+ The optional `kind`, `server`, and `limit` fields are query-only; reads and
21
+ completions carry their server inside their respective objects.
22
+
23
+ ## Discover capabilities
24
+
25
+ ```js
26
+ // Search tool and resource metadata on one server.
27
+ mcp_tools({ query: "database schema", server: "warehouse", limit: 5 })
28
+
29
+ // Restrict one search to tools.
30
+ mcp_tools({ query: "list teams", server: "linear", kind: "tools" })
31
+ ```
32
+
33
+ `kind` defaults to `all`, or accepts `tools`, `resources`, and `prompts`. Discovery
34
+ returns up to five candidates by default, or up to 50 with `limit`, across all kinds.
35
+
36
+ Tool candidates show an exact activation identifier, a short description,
37
+ required parameter names only, and `[loaded]` if already active. Resource
38
+ candidates show the owning server, title or name, exact URI, description, and
39
+ content type when supplied. Concrete resources and tools include exact next-call
40
+ arguments; templates include a read-call shape and variable names.
41
+
42
+ Prompt candidates show the owning server, name, description, argument metadata,
43
+ and a user-only command such as `/mcp prompt docs explain`. The assistant can
44
+ recommend this command but can't retrieve or run prompts through `mcp_tools`.
45
+ Only you can [select, preview, and use a prompt](commands.md#use-server-prompts).
46
+
47
+ ```js
48
+ // Discover prompt metadata without fetching the prompt content.
49
+ mcp_tools({ query: "explain authentication", server: "docs", kind: "prompts" })
50
+ ```
51
+
52
+ Search uses local BM25-based ranking of metadata, with names and resource titles
53
+ weighted more strongly than descriptions, and support for prefix matching.
54
+ Resource and prompt content isn't fetched or searched. See
55
+ [discovery and caching](behavior.md#discovery-and-caching) for connection behavior.
56
+
57
+ ## Activate and call tools
58
+
59
+ ```js
60
+ mcp_tools({ activate: ["linear.list_teams", "linear.get_team"] })
61
+ ```
62
+
63
+ Activation accepts 1–50 exact `server.tool` or `mcp__server__tool` identifiers,
64
+ ignores duplicates, and works without a prior search. Typos never activate fuzzy
65
+ matches: failures list nearby catalog names when available so the assistant can
66
+ retry with an exact identifier. Each identifier reports `loaded`, `already loaded`,
67
+ or `not loaded` with a reason. Partial success keeps the tools that loaded.
68
+
69
+ Full schemas become available on the model turn after activation. When discovery
70
+ is needed, first use follows three steps: discover, activate, then call the native
71
+ tool. There is no invocation proxy. Previously loaded tools remain available;
72
+ [session behavior](behavior.md#sessions) describes restoration and tool restrictions.
73
+
74
+ ## Read resources as context
75
+
76
+ For a request such as “Use the authentication guide to explain this API,” the
77
+ assistant can discover and read relevant context:
78
+
79
+ ```js
80
+ mcp_tools({ query: "authentication guide", kind: "resources" })
81
+ mcp_tools({ read: { server: "docs", uri: "docs://authentication" } })
82
+ ```
83
+
84
+ A read fetches one exact resource URI through its configured server's MCP
85
+ `resources/read` operation. It doesn't open a local file or make a generic HTTP
86
+ request, even for `file:` or `https:` URIs. There is no fallback when the server
87
+ can't read the URI. The server still controls which data it returns.
88
+
89
+ Tool-returned resource links include an exact `mcp_tools({read: ...})` call. The
90
+ assistant can read such links directly, without prior discovery or activation;
91
+ linked resources don't have to appear in the catalog.
92
+
93
+ Reading attaches content as the tool result itself, not as a second message. The
94
+ result identifies the source server and URIs and labels the content as untrusted
95
+ data. See [resource snapshots](behavior.md#resource-snapshots) for freshness and
96
+ session privacy, and [large results](troubleshooting.md#large-results) for output
97
+ limits and private spill files.
98
+
99
+ ## Read parameterized resources
100
+
101
+ Discovery also lists URI templates, such as `schema://tables/{table}`, without
102
+ enumerating every possible table. Templates have a `[template]` label, variable
103
+ names, and a read-call shape. The assistant supplies known argument values:
104
+
105
+ ```js
106
+ mcp_tools({ query: "table schema", server: "warehouse", kind: "resources" })
107
+ mcp_tools({
108
+ read: {
109
+ server: "warehouse",
110
+ template: "schema://tables/{table}",
111
+ arguments: { table: "events" }
112
+ }
113
+ })
114
+ ```
115
+
116
+ The `read` object accepts either `uri` or `template` plus `arguments`, never both.
117
+ The selected server must advertise the exact template. The official SDK expands
118
+ strings or string arrays into a concrete URI, then reads it through that same
119
+ server. Template variables aren't an input schema: no required fields or allowed
120
+ values are inferred. The assistant should use values from your request or prior
121
+ results and ask you when a needed value is unknown rather than inventing an
122
+ identifier.
123
+
124
+ Argument data is limited to 64 KiB and expanded URIs to 4,096 characters. Template
125
+ reads share exact reads' authorization, cancellation, output limits, and snapshot
126
+ rules. Expanded output includes the template, supplied arguments, and resource
127
+ content; see [result display](behavior.md#result-display).
128
+
129
+ ## Complete resource arguments
130
+
131
+ The assistant can ask a server for suggested values for one advertised template
132
+ variable:
133
+
134
+ ```js
135
+ mcp_tools({
136
+ complete: {
137
+ server: "warehouse",
138
+ template: "schema://tables/{table}",
139
+ argument: { name: "table", value: "ev" }
140
+ }
141
+ })
142
+ ```
143
+
144
+ `value` is the current prefix and can be empty. For dependent suggestions, the
145
+ assistant can add `arguments: { knownVariable: "value" }` inside `complete`.
146
+ These context values must be strings, not arrays. The server must advertise
147
+ completion support and the exact template; the variable must occur in that
148
+ template.
149
+
150
+ The result contains `values` and, when supplied by the server, `total` and
151
+ `hasMore`. A narrower prefix can reduce the matches. Suggestions are untrusted
152
+ server data, not a required-field schema or instructions. Requests are limited
153
+ to 64 KiB; output uses the same [limits and spill files](troubleshooting.md#large-results)
154
+ as other results.
155
+
156
+ Resource subscriptions aren't part of this tool. Only you can
157
+ [watch resource changes](commands.md#watch-resource-changes) with `/mcp` commands.