pi-mcp-client 0.4.0 → 0.5.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,114 @@
1
+ # Behavior and permissions
2
+
3
+ [Back to the README](../README.md)
4
+
5
+ This page explains how the extension manages state and displays results. For the
6
+ assistant's tool-call interface, see the [tool reference](tool-reference.md).
7
+
8
+ ## Sessions
9
+
10
+ - Active tools accumulate rather than rotating with each prompt.
11
+ - Resume and branch navigation restore tools activated through `mcp_tools` on
12
+ the selected branch. Discovery results never restore tools.
13
+ - Compaction retains the acquired tool set. New sessions start fresh.
14
+ - Pi uses native deferred loading where supported by the model and provider.
15
+ Other providers receive the expanded tool list normally.
16
+ - Discovery respects server filters; activation also respects Pi's tool exclusions.
17
+ An explicit tool allowlist must include both `mcp_tools` and the native tools
18
+ the assistant needs to load.
19
+
20
+ ## Resource snapshots
21
+
22
+ Resource reads never start OAuth login, follow links in resource bodies, or
23
+ subscribe to live updates. Repeated reads fetch fresh content; earlier results
24
+ stay as snapshots. Resuming a session or navigating its branches doesn't re-read
25
+ resources. Watches have their own
26
+ [memory-only lifecycle](commands.md#watch-resource-changes) and never fetch content
27
+ automatically.
28
+
29
+ Resource content and selected metadata, including URIs, become session data and
30
+ may be sensitive. [Private spill files](troubleshooting.md#large-results) can also
31
+ contain sensitive data and aren't automatically deleted.
32
+
33
+ ## Discovery and caching
34
+
35
+ Connections start on demand, never while the extension factory loads. A search
36
+ without the requested cached metadata contacts configured servers, with at most
37
+ four server discoveries in flight. A server-scoped search only contacts that
38
+ server. Activation discovers only the servers named by its identifiers, with the
39
+ same concurrency bound. Failed servers are reported as unavailable, not mistaken
40
+ for an empty catalog.
41
+
42
+ Tool catalogs are cached privately under `~/.pi/agent/cache/pi-mcp-client/`, keyed
43
+ by server configuration and working directory. Disk caches expire after 24 hours.
44
+ They contain tool metadata, not configured credentials. Cached tool-only discovery
45
+ and activation need no connection; invocation refreshes the live catalog before
46
+ calling the tool.
47
+
48
+ Resource metadata, including template catalogs, is held only in memory for up to
49
+ five minutes, not written to the tool catalog cache. Mixed discovery therefore
50
+ may connect even when tools are cached on disk. Resource-list notifications,
51
+ disconnection, and explicit refresh invalidate resource metadata without reading
52
+ content. Tool and resource catalog failures are reported independently; healthy
53
+ candidates remain available. The SDK handles pagination. Resource catalogs are
54
+ limited to 10,000 entries and 4 MiB of descriptor data; oversized catalogs fail
55
+ rather than silently returning a partial list. Reads bypass the SDK content cache.
56
+ Connections remain open until shutdown or an explicit lifecycle action such as
57
+ reconnection or configuration reload.
58
+
59
+ When a connected server reports a tool-list change, the extension invalidates its
60
+ memory and disk catalogs. The next discovery or activation fetches the current
61
+ list, including new or removed tools. Notifications don't replace active tool
62
+ definitions: the assistant must activate changed schemas again before use. Calls
63
+ validate the live catalog before execution and refuse removed or changed tools.
64
+ Disconnected, cache-only searches can't receive notifications and still use the
65
+ 24-hour disk-cache expiry.
66
+
67
+ ## Result display
68
+
69
+ The UI labels discovery calls **mcp discover**, activation calls **mcp activate**,
70
+ resource reads **mcp read**, and argument completions **mcp complete**.
71
+
72
+ Discovery rows show `○` for inactive candidates and `●` for already active tools,
73
+ without a status suffix. These reflect the state when discovery runs; earlier
74
+ results don't update retroactively. Activation results use `✔︎` for success and
75
+ `✘︎` for failure. Descriptions stay gray; identifiers remain prominent.
76
+
77
+ Exact and template reads use the same compact status row:
78
+
79
+ ```text
80
+ mcp read
81
+ ✔︎ warehouse · schema://tables/events
82
+ ```
83
+
84
+ Expand a tool result to see JSON objects and arrays formatted with two-space
85
+ indentation and syntax highlighting. Explicit JSON resource MIME types (including
86
+ `application/*+json`) and structured content identify JSON without guessing.
87
+ Other explicit MIME types stay plain text; unlabeled text is checked for JSON.
88
+
89
+ Formatting changes only the display, not the response sent to the assistant.
90
+ Invalid or truncated JSON stays plain text. Results that would exceed formatting
91
+ limits also stay plain text. Resource-link MIME types describe the linked content,
92
+ not the displayed link label. Supported images use the existing result display;
93
+ see [large results](troubleshooting.md#large-results) for size limits.
94
+
95
+ ## Trust and permissions
96
+
97
+ Only load configuration you trust. Server executables and secret commands run
98
+ with your user permissions; trusted project configuration can replace global
99
+ connections and settings.
100
+
101
+ Server metadata and resource content are untrusted data. Discovery never
102
+ activates tools. Explicit activation exposes schemas but doesn't approve tool
103
+ side effects or provide per-call confirmation. Use tool filters and Pi permission
104
+ extensions for additional controls. Cancelling a call doesn't guarantee that the
105
+ server rolled back its effects. The extension doesn't retry failed tool
106
+ invocations; verify an interrupted operation's outcome before trying again.
107
+
108
+ `includeTools` and `excludeTools` apply only to tools, not resources. Keeping
109
+ `mcp_tools` available permits resource reads from enabled servers, subject to the
110
+ server's authorization. `kind: "tools"` filters one search; it isn't an access
111
+ restriction. Disable a server to prevent all access, or exclude `mcp_tools` through
112
+ Pi's tool restrictions to prevent discovery and resource operations. Already active
113
+ native tools have their own tool restrictions. Per-resource permission policies
114
+ aren't implemented.
@@ -0,0 +1,171 @@
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, 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 get <server>` | Inspect status and configuration, including disabled servers. Connection values are hidden. |
17
+ | `/mcp tools <server>` | Browse the server's tools and inspect descriptions without activating tools. |
18
+ | `/mcp reload` | Apply configuration changes without restarting Pi. |
19
+ | `/mcp enable <server>` | Enable a server in its effective configuration file. |
20
+ | `/mcp disable <server>` | Disable a server, close its connection, and deactivate its tools. |
21
+ | `/mcp login <server> [--no-browser]` | Authenticate an HTTP server without changing its configuration; optionally paste the callback URL in an interactive dialog. |
22
+ | `/mcp logout <server>` | Remove local OAuth credentials and attempt remote revocation, including for disabled servers. |
23
+ | `/mcp reconnect <server>` | Replace a connection and refresh its catalog. |
24
+ | `/mcp refresh <server>` | Refresh tool and resource metadata without reading resources or loading additional tools. |
25
+ | `/mcp subscribe <server> <uri>` | Watch changes to one exact resource URI without fetching content. |
26
+ | `/mcp unsubscribe <server> <uri>` | Stop watching one resource. |
27
+ | `/mcp subscriptions` | List active resource watches and their change markers. |
28
+
29
+ See [Authentication](authentication.md) for login and logout procedures, and
30
+ [Apply changes](configuration.md#apply-changes) for reload behavior.
31
+
32
+ ## Inspect servers and tools
33
+
34
+ The `/mcp` status matrix distinguishes idle (`○`), connected (`●`), connecting
35
+ (`▶︎`), disabled (`○`), and failed (`✘︎`) servers. Idle is normal: connections open
36
+ on demand. A dash (`—`) means the catalog hasn't been fetched, not that the server
37
+ has no tools. The **Loaded** column counts tools currently active for the
38
+ assistant.
39
+
40
+ Use `/mcp get <server>` to check the effective transport, protocol, filters,
41
+ and connection status without connecting or running secret commands. Connection
42
+ values—including commands, arguments, URLs, headers, and environment variables—
43
+ are hidden because any of them can contain credentials. Authentication status
44
+ shows whether OAuth tokens are stored, not whether they are valid. A locked or
45
+ unavailable credential store is reported separately from missing tokens. Header
46
+ and stdio credentials are identified as externally managed; inspection never
47
+ executes them.
48
+
49
+ Use `/mcp tools <server>` to fetch the current catalog and browse a scrollable
50
+ list. Rows show tool names and descriptions, trimmed to the terminal width with
51
+ an ellipsis. Select a tool to see a multiline signature and parameter details,
52
+ with each parameter in a separate paragraph. Browsing respects your include and
53
+ exclude filters and doesn't activate tools or add their schemas to the assistant's
54
+ context. This command requires an interactive UI.
55
+
56
+ Refreshing a catalog doesn't replace active tool definitions. After a schema
57
+ change, ask the assistant to activate the exact tool again. See
58
+ [tool changes and caching](behavior.md#discovery-and-caching). Failed tool calls
59
+ aren't retried automatically; verify whether an interrupted operation completed
60
+ before trying again.
61
+
62
+ ## Enable and disable servers
63
+
64
+ Use `/mcp disable <server>` or `/mcp enable <server>` to change the `disabled`
65
+ option without editing JSON. The command reports which scope changed: the trusted
66
+ project's `.mcp.json` if it defines the server, otherwise the global
67
+ `~/.pi/agent/mcp.json`. Untrusted project files are neither read nor changed.
68
+
69
+ Toggles preserve other values, including secret references, and reformat the file
70
+ as indented JSON. Repeating a toggle that's already set leaves the file unchanged.
71
+ Both commands wait for active agent work to finish, then
72
+ [apply the configuration](configuration.md#apply-changes).
73
+
74
+ Disabling removes the server from discovery and deactivates its tools. Enabling
75
+ doesn't connect, authenticate, or load tools; ask the assistant to discover the
76
+ capabilities you need.
77
+
78
+ ## Add and remove servers
79
+
80
+ Both commands require an explicit `--scope global` or `--scope project`:
81
+
82
+ - **Global:** `~/.pi/agent/mcp.json`.
83
+ - **Project:** `.mcp.json` in the current trusted project. Untrusted project files
84
+ are neither read nor changed.
85
+
86
+ Add an HTTP server by URL, or a stdio server after `--`:
87
+
88
+ ```text
89
+ /mcp add --scope global docs https://docs.mcp.cloudflare.com/mcp
90
+ /mcp add --scope project local -- node "/path with spaces/server.js"
91
+ ```
92
+
93
+ Put options before the server name. `--transport http` or `--transport stdio` is
94
+ optional; the URL form selects HTTP and the `--` form selects stdio. Arguments
95
+ support single and double quotes and backslash escaping, but are never evaluated
96
+ by a shell. Shell syntax such as `$(...)`, pipes, and globs stays literal. For
97
+ Windows paths with backslashes, single quotes preserve the path verbatim.
98
+
99
+ | Option | Purpose |
100
+ | --- | --- |
101
+ | `--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. |
102
+ | `--header 'Name: value'` | Add an HTTP header. Repeat for different header names. |
103
+ | `--env KEY=value` | Add a stdio environment override. Repeat for different variable names. |
104
+ | `--oauth-client-id ID` | Use a pre-registered public client. |
105
+ | `--oauth-scope SCOPE` | Request an OAuth scope. Repeat for additional scopes. |
106
+ | `--oauth-callback-port PORT` | Set the loopback callback port. |
107
+
108
+ Retain environment references rather than typing tokens:
109
+
110
+ ```text
111
+ /mcp add --scope global --header 'Authorization: Bearer ${DOCS_TOKEN}' docs https://mcp.example.com/mcp
112
+ /mcp add --scope global --oauth-client-id '${CLIENT_ID}' service https://mcp.example.com/mcp
113
+ ```
114
+
115
+ Define referenced environment variables before running the command. Validation
116
+ checks the resolved configuration, but saves the references, not their values.
117
+ Secret commands in headers or environment overrides are saved without running
118
+ them. Avoid literal credentials in command input or project files; use
119
+ [environment references and secret commands](configuration.md#secret-commands).
120
+
121
+ Adding never starts a server, opens a browser, or activates tools. Duplicate names
122
+ in global or trusted project configuration are rejected unless you supply
123
+ `--replace`. Project definitions take precedence; writing a global definition
124
+ doesn't replace a project override. Other server options, such as tool filters,
125
+ remain available by editing the configuration file.
126
+
127
+ Remove a definition from a specific scope:
128
+
129
+ ```text
130
+ /mcp remove --scope project local
131
+ ```
132
+
133
+ Removal is distinct from disabling and logout: it deletes the selected definition,
134
+ not its OAuth credentials. Run `/mcp logout <server>` first if you also want to
135
+ remove credentials. Removing a project override exposes any same-named global
136
+ definition; the command reports when a definition in the other scope remains.
137
+ Removing a name absent from the selected scope fails without changing either file.
138
+
139
+ Successful edits [apply immediately](configuration.md#apply-changes). Writes
140
+ preserve unrelated settings, follow existing file symlinks, and replace files
141
+ atomically. New files are private; existing file permissions are preserved. If
142
+ global and project configuration point to the same file, scoped edits are refused
143
+ until you separate them. Empty configuration files are retained rather than deleted.
144
+
145
+ ## Watch resource changes
146
+
147
+ Subscriptions are explicit user commands, not model-facing tool operations:
148
+
149
+ ```text
150
+ /mcp subscribe warehouse schema://tables/events
151
+ /mcp subscriptions
152
+ /mcp unsubscribe warehouse schema://tables/events
153
+ ```
154
+
155
+ Use an exact absolute URI from discovery, a template read, or a resource link.
156
+ The configured server must support resource subscriptions. The extension uses the
157
+ SDK's negotiated protocol: legacy resource subscriptions or modern filtered
158
+ streams. It never opens the URI as a file or generic URL.
159
+
160
+ An update marks the watch as changed (`↻`) and shows a UI notification. Repeated
161
+ updates coalesce into that marker until you unsubscribe. No content is fetched,
162
+ no model turn starts, and existing resource results remain unchanged. Ask the
163
+ assistant to read the resource for a new snapshot; unsubscribe and subscribe again
164
+ to reset the change marker.
165
+
166
+ Watches are memory-only, limited to 50 per server connection, and require an
167
+ interactive UI (TUI or RPC). Repeating a subscribe command is idempotent. Session
168
+ replacement, tree navigation, configuration reload, disconnection, and exit clear
169
+ the affected watches. They are never restored or automatically retried; use
170
+ `/mcp subscriptions` to inspect active watches. Cancellation and connection
171
+ failures can leave an uncertain server-side outcome; cleanup is best-effort.
@@ -0,0 +1,150 @@
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).
8
+
9
+ ## Files and transports
10
+
11
+ The files use the common Claude/Cursor-style `mcpServers` format, not a universal
12
+ MCP configuration standard. VS Code's `servers` format and Codex's TOML format
13
+ aren't supported. `PI_CODING_AGENT_DIR` overrides the global Pi directory.
14
+ Project definitions replace same-named global definitions in full; fields and
15
+ filters aren't merged. Untrusted project files are neither read nor changed.
16
+
17
+ ```json
18
+ {
19
+ "mcpServers": {
20
+ "docs": {
21
+ "url": "https://mcp.example.com/mcp",
22
+ "headers": {
23
+ "Authorization": "Bearer ${DOCS_TOKEN}"
24
+ }
25
+ },
26
+ "local": {
27
+ "command": "node",
28
+ "args": ["/absolute/path/to/server.js"],
29
+ "env": {
30
+ "DATABASE_URL": "${DATABASE_URL}"
31
+ }
32
+ }
33
+ }
34
+ }
35
+ ```
36
+
37
+ | Field | Purpose |
38
+ | --- | --- |
39
+ | `type` | Optional `stdio` or `http`. If omitted, inferred from `command` or `url`. A conflicting type is rejected. |
40
+ | `command`, `args` | Executable and arguments for a stdio server. No shell is used. |
41
+ | `cwd` | Working directory for stdio; defaults to Pi's current directory. Relative paths resolve there. |
42
+ | `env` | Additional environment variables for stdio. |
43
+ | `url` | Streamable HTTP endpoint; mutually exclusive with `command`. |
44
+ | `headers` | HTTP request headers, including optional bearer authentication. |
45
+
46
+ Strings in `command`, `args`, `cwd`, `env`, `url`, and `headers` support `${VAR}`
47
+ interpolation. Missing variables prevent that server from connecting.
48
+
49
+ Only stdio and Streamable HTTP are supported. The extension rejects `type: "sse"`
50
+ and unsupported connection fields rather than silently changing their meaning.
51
+
52
+ The extension uses `@modelcontextprotocol/client` 2.0.0 and defaults to automatic
53
+ SDK protocol-version negotiation. On stdio, negotiation probes using an additional
54
+ short-lived process. Set `"protocol": "legacy"` if the server requires an explicit
55
+ legacy handshake.
56
+
57
+ ## Secret commands
58
+
59
+ In **`headers` and stdio `env` values only**, a leading `!` runs a secret-generating
60
+ shell command when the server connects:
61
+
62
+ ```json
63
+ {
64
+ "mcpServers": {
65
+ "example": {
66
+ "url": "https://mcp.example.com/mcp",
67
+ "headers": {
68
+ "Authorization": "!token=$(op read 'op://Private/Example/token') && printf 'Bearer %s' \"$token\""
69
+ }
70
+ }
71
+ }
72
+ }
73
+ ```
74
+
75
+ These two fields also support Pi-style `$VAR` interpolation, `$$` for a literal
76
+ `$`, and `$!` for a literal `!`. Only a leading `!` in the original configuration
77
+ triggers execution; interpolated values and command output never do. Shell
78
+ commands handle their own variable expansion.
79
+
80
+ Commands use `/bin/sh` on Unix or Pi's shell selection on Windows, inherit Pi's
81
+ process environment, and run in the server's configured `cwd` (the project
82
+ directory by default). They run once per connection, including reconnections,
83
+ not during configuration loading, status display, or cached discovery. Cold
84
+ searches and activations can connect and therefore execute commands. Concurrent
85
+ connection requests share the same resolution.
86
+
87
+ The extension trims stdout and rejects empty output, nonzero exits, output above
88
+ 64 KiB, and resolution taking more than 10 seconds (or a shorter `timeoutMs`).
89
+ Session shutdown cancels pending commands. Cancelling an individual search or
90
+ activation stops waiting but leaves shared connection work running for other
91
+ callers.
92
+
93
+ The extension discards command stderr and doesn't include resolved secrets in
94
+ errors, session records, or catalog caches. Commands themselves remain responsible
95
+ for avoiding side effects or writing secrets to disk. Only configure commands you
96
+ trust; project configuration still requires project trust.
97
+
98
+ ## Pi-specific options
99
+
100
+ Put descriptions, authentication choices, filters, and timeouts directly in each
101
+ server definition:
102
+
103
+ ```json
104
+ {
105
+ "mcpServers": {
106
+ "docs": {
107
+ "url": "https://mcp.example.com/mcp",
108
+ "description": "Search product documentation",
109
+ "includeTools": ["get_*", "search_*"]
110
+ }
111
+ }
112
+ }
113
+ ```
114
+
115
+ | Field | Purpose |
116
+ | --- | --- |
117
+ | `description` | Short capability description for the assistant's server directory. |
118
+ | `oauthClientId` | Optional pre-registered public client ID. Supports `${ENV_VAR}` interpolation, not secret commands. |
119
+ | `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. |
120
+ | `oauthCallbackPort` | Optional loopback callback port, from 1 to 65535. Defaults to `19847`. |
121
+ | `disabled` | Prevent this server from connecting or exposing tools and resources. |
122
+ | `includeTools` | Optional allowlist of original MCP tool names; `*` matches any sequence. An empty list exposes no tools. |
123
+ | `excludeTools` | Denylist applied after `includeTools`. |
124
+ | `timeoutMs` | Request timeout, from 100 to 600000 ms. Defaults: 15 seconds for discovery/HTTP requests, 30 seconds for stdio tool calls. |
125
+ | `protocol` | `auto` (default) for SDK protocol-version negotiation, or `legacy` for an explicit legacy handshake. |
126
+
127
+ OAuth client IDs, scopes, and callback ports require HTTP without an Authorization
128
+ header. HTTP authentication is automatic; remove the obsolete `oauth` field from
129
+ existing definitions. See [authentication](authentication.md).
130
+
131
+ Every definition must include a `url` or `command`, even when `disabled` is true.
132
+ These options are specific to Pi MCP Client, not standardized MCP connection
133
+ fields. Other clients may reject them when you copy a definition.
134
+
135
+ Tool filters don't restrict resource reads. See
136
+ [trust and permissions](behavior.md#trust-and-permissions) for access boundaries
137
+ and [authentication](authentication.md) for OAuth setup.
138
+
139
+ ## Apply changes
140
+
141
+ After editing a file, run `/mcp reload`. The extension validates the new
142
+ configuration before replacing the current setup; invalid configuration leaves
143
+ the previous setup intact. Reload closes connections, which reopen on demand,
144
+ and deactivates tools from changed, removed, or disabled definitions. Unchanged
145
+ active tools remain available.
146
+
147
+ Server-management commands apply saved changes using the same reconciliation.
148
+ Other running Pi sessions pick up those changes when you reload their MCP
149
+ configuration. See [Commands](commands.md) for toggling, inspecting, adding, and
150
+ removing servers.
@@ -0,0 +1,147 @@
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 and resource 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` and `resources`. Discovery returns up
34
+ to five candidates by default, or up to 50 with `limit`, across both 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
+ Search uses local BM25-based ranking of metadata, with names and resource titles
43
+ weighted more strongly than descriptions, and support for prefix matching.
44
+ Resource content isn't fetched or searched. See
45
+ [discovery and caching](behavior.md#discovery-and-caching) for connection behavior.
46
+
47
+ ## Activate and call tools
48
+
49
+ ```js
50
+ mcp_tools({ activate: ["linear.list_teams", "linear.get_team"] })
51
+ ```
52
+
53
+ Activation accepts 1–50 exact `server.tool` or `mcp__server__tool` identifiers,
54
+ ignores duplicates, and works without a prior search. Typos never activate fuzzy
55
+ matches: failures list nearby catalog names when available so the assistant can
56
+ retry with an exact identifier. Each identifier reports `loaded`, `already loaded`,
57
+ or `not loaded` with a reason. Partial success keeps the tools that loaded.
58
+
59
+ Full schemas become available on the model turn after activation. When discovery
60
+ is needed, first use follows three steps: discover, activate, then call the native
61
+ tool. There is no invocation proxy. Previously loaded tools remain available;
62
+ [session behavior](behavior.md#sessions) describes restoration and tool restrictions.
63
+
64
+ ## Read resources as context
65
+
66
+ For a request such as “Use the authentication guide to explain this API,” the
67
+ assistant can discover and read relevant context:
68
+
69
+ ```js
70
+ mcp_tools({ query: "authentication guide", kind: "resources" })
71
+ mcp_tools({ read: { server: "docs", uri: "docs://authentication" } })
72
+ ```
73
+
74
+ A read fetches one exact resource URI through its configured server's MCP
75
+ `resources/read` operation. It doesn't open a local file or make a generic HTTP
76
+ request, even for `file:` or `https:` URIs. There is no fallback when the server
77
+ can't read the URI. The server still controls which data it returns.
78
+
79
+ Tool-returned resource links include an exact `mcp_tools({read: ...})` call. The
80
+ assistant can read such links directly, without prior discovery or activation;
81
+ linked resources don't have to appear in the catalog.
82
+
83
+ Reading attaches content as the tool result itself, not as a second message. The
84
+ result identifies the source server and URIs and labels the content as untrusted
85
+ data. See [resource snapshots](behavior.md#resource-snapshots) for freshness and
86
+ session privacy, and [large results](troubleshooting.md#large-results) for output
87
+ limits and private spill files.
88
+
89
+ ## Read parameterized resources
90
+
91
+ Discovery also lists URI templates, such as `schema://tables/{table}`, without
92
+ enumerating every possible table. Templates have a `[template]` label, variable
93
+ names, and a read-call shape. The assistant supplies known argument values:
94
+
95
+ ```js
96
+ mcp_tools({ query: "table schema", server: "warehouse", kind: "resources" })
97
+ mcp_tools({
98
+ read: {
99
+ server: "warehouse",
100
+ template: "schema://tables/{table}",
101
+ arguments: { table: "events" }
102
+ }
103
+ })
104
+ ```
105
+
106
+ The `read` object accepts either `uri` or `template` plus `arguments`, never both.
107
+ The selected server must advertise the exact template. The official SDK expands
108
+ strings or string arrays into a concrete URI, then reads it through that same
109
+ server. Template variables aren't an input schema: no required fields or allowed
110
+ values are inferred. The assistant should use values from your request or prior
111
+ results and ask you when a needed value is unknown rather than inventing an
112
+ identifier.
113
+
114
+ Argument data is limited to 64 KiB and expanded URIs to 4,096 characters. Template
115
+ reads share exact reads' authorization, cancellation, output limits, and snapshot
116
+ rules. Expanded output includes the template, supplied arguments, and resource
117
+ content; see [result display](behavior.md#result-display).
118
+
119
+ ## Complete resource arguments
120
+
121
+ The assistant can ask a server for suggested values for one advertised template
122
+ variable:
123
+
124
+ ```js
125
+ mcp_tools({
126
+ complete: {
127
+ server: "warehouse",
128
+ template: "schema://tables/{table}",
129
+ argument: { name: "table", value: "ev" }
130
+ }
131
+ })
132
+ ```
133
+
134
+ `value` is the current prefix and can be empty. For dependent suggestions, the
135
+ assistant can add `arguments: { knownVariable: "value" }` inside `complete`.
136
+ These context values must be strings, not arrays. The server must advertise
137
+ completion support and the exact template; the variable must occur in that
138
+ template.
139
+
140
+ The result contains `values` and, when supplied by the server, `total` and
141
+ `hasMore`. A narrower prefix can reduce the matches. Suggestions are untrusted
142
+ server data, not a required-field schema or instructions. Requests are limited
143
+ to 64 KiB; output uses the same [limits and spill files](troubleshooting.md#large-results)
144
+ as other results.
145
+
146
+ Resource subscriptions aren't part of this tool. Only you can
147
+ [watch resource changes](commands.md#watch-resource-changes) with `/mcp` commands.
@@ -0,0 +1,67 @@
1
+ # Troubleshooting
2
+
3
+ [Back to the README](../README.md)
4
+
5
+ Start with `/mcp` to inspect server status and `/mcp get <server>` to inspect
6
+ configuration without connecting. Failures use a consistent code, a short
7
+ explanation, and a recovery hint, for example:
8
+
9
+ ```text
10
+ linear: [authentication_required] Authentication is required. Run /mcp login linear.
11
+ ```
12
+
13
+ ## Diagnostic codes
14
+
15
+ Search and tool results also carry structured diagnostics in their result details:
16
+ `code`, `operation`, optional `server`, `message`, and `hint`. Partial discovery
17
+ keeps healthy servers' results and identifies servers it couldn't search. An
18
+ unavailable server isn't an empty catalog.
19
+
20
+ | Code | What to check |
21
+ | --- | --- |
22
+ | `configuration_invalid` | JSON syntax, supported fields, transport type, and required environment variables. Run `/mcp reload` after editing. |
23
+ | `authentication_required` | Run `/mcp login <server>` for OAuth, or check the Authorization header. |
24
+ | `permission_denied` | Account permissions, OAuth scopes, and service access policy. |
25
+ | `credential_store_unavailable` | Unlock or enable the OS keyring; Linux needs a Secret Service session. |
26
+ | `secret_lookup_failed` | Secret helper installation, login, exit status, nonempty stdout, and output size. |
27
+ | `connection_failed` | Server executable, working directory, endpoint, network, and TLS configuration. |
28
+ | `timeout` | Server responsiveness and the applicable request, secret-command, or OAuth time limit. |
29
+ | `protocol_error` | Server compatibility and the `protocol` setting. |
30
+ | `tool_changed` | Check server filters and ask the assistant to activate the exact tool again for its current schema. Run `/mcp reload` if connection configuration changed. |
31
+ | `tool_error` | The server's tool result and inputs; verify the outcome before retrying. |
32
+ | `resource_invalid` | The assistant needs an exact absolute resource URI from discovery or a tool-returned link. |
33
+ | `resource_not_found` | Refresh resource metadata or obtain a new link. |
34
+ | `resources_unsupported` | Ask the assistant to use the server's tools instead, or choose a resource-capable server. |
35
+ | `completions_unsupported` | Supply known template values; the assistant should ask you if a value is missing. |
36
+ | `completion_invalid` | The assistant needs an advertised template variable and a string prefix. |
37
+ | `subscriptions_unsupported` | Choose a server with subscription support, or ask the assistant to read when needed. |
38
+ | `subscription_limit` | Remove a watch before adding another; the limit is 50 per connection. |
39
+ | `catalog_changed` | Ask the assistant to retry discovery after the server catalog settles. |
40
+ | `oauth_failed` | Browser access to the callback and support for public clients, using dynamic registration or the configured client ID. |
41
+ | `oauth_issuer_changed` | Verify the authorization-server change before logging out and logging in again. |
42
+ | `callback_unavailable` | Another process using the configured loopback port (default 19847). Change `oauthCallbackPort` or use `/mcp login <server> --no-browser`. |
43
+ | `busy` | Wait for discovery to finish before reconnecting. |
44
+ | `cancelled` | Retry when ready; verify any interrupted tool operation first. |
45
+ | `operation_failed` | An unclassified failure; inspect server status and configuration. |
46
+
47
+ For setup details, see [Configuration](configuration.md),
48
+ [Authentication](authentication.md), and [Commands](commands.md).
49
+
50
+ Diagnostics never echo raw exception messages, HTTP bodies, command stderr,
51
+ credential values, or stack traces. Unknown errors stay generic rather than being
52
+ classified by potentially sensitive message text. Server-provided tool results
53
+ remain visible as content, even when the tool reports an error; they aren't
54
+ sanitized transport diagnostics. Tool-call failures aren't replayed automatically;
55
+ verify the outcome before retrying.
56
+
57
+ ## Large results
58
+
59
+ Text output is limited to 2,000 lines or 50 KiB, including resource reads and
60
+ completions. Larger results are saved in private temporary files, with paths
61
+ included in the output. Full tool results use JSON files. Supported images pass
62
+ through within an 8 MiB base64 budget; unsupported or oversized binary content is
63
+ retained in the full result file.
64
+
65
+ A resource read fetches the server's full response before applying output limits;
66
+ it isn't a streaming or partial-content reader. Temporary result files aren't
67
+ automatically deleted and may contain sensitive data.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-mcp-client",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "MCP tools for Pi, discovered on demand and called natively through the official SDK.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -20,6 +20,7 @@
20
20
  },
21
21
  "files": [
22
22
  "dist",
23
+ "docs",
23
24
  "README.md",
24
25
  "LICENSE"
25
26
  ],