@subimpact/e 0.99.4 → 0.99.6
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.
- package/CHANGELOG.md +18 -0
- package/dist/bundle/chunks/{chunk-4GK5QWPL.js → chunk-K6Q3GXDV.js} +1 -1
- package/dist/bundle/chunks/{chunk-EWH2CBXL.js → chunk-KYW6YCWU.js} +11 -11
- package/dist/bundle/chunks/{virtual-modules-33PKUUYB.js → virtual-modules-KIL67DKU.js} +1 -1
- package/dist/bundle/cli-runtime.js +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/core/agent-session.js +1 -1
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/bug-report.js +1 -1
- package/dist/core/bug-report.js.map +1 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +5 -1
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/slash-commands.js +1 -1
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/modes/interactive/bug-report.js +1 -1
- package/dist/modes/interactive/bug-report.js.map +1 -1
- package/dist/modes/interactive/components/first-time-setup.js +1 -1
- package/dist/modes/interactive/components/first-time-setup.js.map +1 -1
- package/dist/modes/interactive/components/pi-logo.js.map +1 -1
- package/dist/modes/interactive/external-editor.js +1 -1
- package/dist/modes/interactive/external-editor.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +1 -1
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/package-manager-cli.js +3 -3
- package/dist/package-manager-cli.js.map +1 -1
- package/docs/cli.md +3 -62
- package/docs/configuration.md +0 -2
- package/docs/docs.json +0 -4
- package/docs/extensions.md +5 -25
- package/docs/llama-cpp.md +1 -1
- package/docs/models.md +4 -21
- package/docs/sdk.md +1 -6
- package/docs/security.md +0 -2
- package/docs/settings.md +5 -7
- package/package.json +1 -1
- package/docs/mcp.md +0 -248
package/docs/models.md
CHANGED
|
@@ -100,7 +100,9 @@ Choose the conservative end of any published range. A model without a lifetime f
|
|
|
100
100
|
|
|
101
101
|
Compatibility settings should describe verified differences in the endpoint's request or response behavior. Do not enable them based only on an endpoint advertising OpenAI or Anthropic compatibility.
|
|
102
102
|
|
|
103
|
-
|
|
103
|
+
<a id="use-classifier-models"></a>
|
|
104
|
+
|
|
105
|
+
## Classifier models
|
|
104
106
|
|
|
105
107
|
Classifier models do not chat. They answer typed questions about JSON state: pick one of several choices, answer yes or no, or give a score, each with probabilities. Pi includes TypeSafe's Jev model from these providers:
|
|
106
108
|
|
|
@@ -114,26 +116,7 @@ Classifier models do not chat. They answer typed questions about JSON state: pic
|
|
|
114
116
|
|
|
115
117
|
Chat models on a [llama.cpp router](llama-cpp.md#classification) are also listed as classifier models.
|
|
116
118
|
|
|
117
|
-
Classifier models
|
|
118
|
-
|
|
119
|
-
```js
|
|
120
|
-
const jev = await models.getModelOfType("classifier", "typesafe", "jev-latest");
|
|
121
|
-
const result = await models.classify(jev, {
|
|
122
|
-
state: { message: "The change works, thanks." },
|
|
123
|
-
questions: {
|
|
124
|
-
approved: {
|
|
125
|
-
type: "bool",
|
|
126
|
-
instructions: "Does the user approve of the result?",
|
|
127
|
-
criteria: { true: "Approval", false: "No approval" },
|
|
128
|
-
},
|
|
129
|
-
},
|
|
130
|
-
});
|
|
131
|
-
return result.answers;
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
When the service reports token counts, as all System One services do, `result.usage` carries them with their cost. Pi adds the usage of a script's classifier calls to the `codemode` tool result, so it counts toward the session cost in the footer and `/session`. The cost uses the model's catalog price; models without one, such as TypeSafe's direct `jev-latest`, report tokens at no cost.
|
|
135
|
-
|
|
136
|
-
Extensions call classifiers through `ctx.modelRegistry.classify()`, without codemode. [Virtual models](virtual-models.md#route-requests) can use them to route requests; see the `jev-router.ts` example.
|
|
119
|
+
Classifier models remain catalog entries but Pi cannot invoke them: there is no classifier tool and no `classify()` in the extension API. They do not appear in `/model`. Scripts that need `classify()` do not run in Pi.
|
|
137
120
|
|
|
138
121
|
## Add a custom provider
|
|
139
122
|
|
package/docs/sdk.md
CHANGED
|
@@ -109,11 +109,7 @@ Use `DefaultResourceLoader` when you want standard discovery with selected overr
|
|
|
109
109
|
|
|
110
110
|
<a id="inlineextension"></a>
|
|
111
111
|
|
|
112
|
-
Inline extension factories can be supplied through `DefaultResourceLoader`. Give one an `InlineExtension` name only when it needs a stable name in diagnostics and startup output. A named inline extension with `replaceable: true` is left out when another extension registers a tool, command, or flag with a name it registers during loading, instead of both loading with a conflict. The CLI's built-in
|
|
113
|
-
|
|
114
|
-
<a id="codemode-mcp"></a>
|
|
115
|
-
|
|
116
|
-
The CLI loads `codemode`, `tool_search`, and MCP as built-in extensions. SDK sessions do not; add `createCodemodeExtension()`, `createToolSearchExtension()`, and `createMcpExtension()` to the `extensionFactories` of `DefaultResourceLoader`. `codemode` and `tool_search` are registered inactive: enable them through the `defaultTools` setting (`["+codemode", "+tool_search"]` keeps the other default tools), or let the MCP extension activate them: `codemode` for servers with `codemode` exposure, `tool_search` for servers with `deferred` exposure. The MCP extension connects its servers on `session_start`, so call `session.bindExtensions()`. See [Codemode and MCP](../examples/sdk/14-codemode-mcp.ts).
|
|
112
|
+
Inline extension factories can be supplied through `DefaultResourceLoader`. Give one an `InlineExtension` name only when it needs a stable name in diagnostics and startup output. A named inline extension with `replaceable: true` is left out when another extension registers a tool, command, or flag with a name it registers during loading, instead of both loading with a conflict. The CLI's built-in llama.cpp extension is replaceable. A named entry with `builtin: true` is not an inline extension: it supplies the code of the `builtin:<name>` extension, which loads like a configured extension file. It loads by default, is listed in `pi config`, and is disabled by `-builtin:<name>` in the `extensions` setting or by `noExtensions`; `additionalExtensionPaths: ["builtin:<name>"]` loads it explicitly. It loads after project trust is resolved, so it cannot handle `project_trust`. The CLI's built-in extensions use it.
|
|
117
113
|
|
|
118
114
|
See the focused examples for [models](../examples/sdk/02-custom-model.ts), [tools](../examples/sdk/05-tools.ts), [extensions](../examples/sdk/06-extensions.ts), and [full control](../examples/sdk/12-full-control.ts).
|
|
119
115
|
|
|
@@ -134,7 +130,6 @@ See the focused examples for [models](../examples/sdk/02-custom-model.ts), [tool
|
|
|
134
130
|
| [Sessions](../examples/sdk/11-sessions.ts) | Control session persistence and restoration |
|
|
135
131
|
| [Full control](../examples/sdk/12-full-control.ts) | Replace default discovery and state services |
|
|
136
132
|
| [Session runtime](../examples/sdk/13-session-runtime.ts) | Replace the active session safely |
|
|
137
|
-
| [Codemode and MCP](../examples/sdk/14-codemode-mcp.ts) | Add the `codemode`, `tool_search`, and MCP extensions |
|
|
138
133
|
|
|
139
134
|
<a id="exports"></a>
|
|
140
135
|
|
package/docs/security.md
CHANGED
|
@@ -37,7 +37,6 @@ Project trust does not limit what tool calls can access or affect. After Pi star
|
|
|
37
37
|
Pi requires a project-trust decision when it finds any of these resources from the current working directory:
|
|
38
38
|
|
|
39
39
|
- `.pi/settings.json`
|
|
40
|
-
- `.pi/mcp.json`
|
|
41
40
|
- `.pi/extensions`, `.pi/skills`, `.pi/prompts`, or `.pi/themes`
|
|
42
41
|
- `.pi/SYSTEM.md` or `.pi/APPEND_SYSTEM.md`
|
|
43
42
|
- project `.agents/skills` in the current directory or an ancestor directory
|
|
@@ -47,7 +46,6 @@ A bare `.pi` directory does not require project trust.
|
|
|
47
46
|
Granting project trust allows Pi to load:
|
|
48
47
|
|
|
49
48
|
- project settings
|
|
50
|
-
- project MCP servers from `.pi/mcp.json`
|
|
51
49
|
- extensions, skills, prompt templates, themes, and system-prompt files under `.pi`
|
|
52
50
|
- missing packages configured through project settings
|
|
53
51
|
- project-local and project-package extensions
|
package/docs/settings.md
CHANGED
|
@@ -38,16 +38,14 @@ See [Choose a Model](models.md) for model selection and thinking controls.
|
|
|
38
38
|
| Setting | Type | Default | Description |
|
|
39
39
|
|---|---|---|---|
|
|
40
40
|
| `defaultTools` | `string[]` | `read`, `bash`, `edit`, `write` | Tools enabled at startup. Plain names replace the defaults; `+name` adds a tool and `-name` removes one. An empty array disables all built-in tools but not extension or SDK tools. |
|
|
41
|
-
| `codemode.mode` | `"on"` \| `"only"` | `"on"` | How the `codemode` tool presents tools while it is active. `on`: declared tools get their `codemode` declaration appended to their description, and `codemode` lists only tools that are not declared. `only`: `codemode` lists every tool scripts can call, and active built-in and extension tools are hidden from the model, so it reaches them through `codemode`. |
|
|
42
|
-
| `codemode.inlineBudget` | number | `3000` | Estimated tokens (characters / 4) the `codemode` tool's description may spend on tool declarations. Tools that do not fit are left out and found with `searchTools()`. `0` lists only namespaces. |
|
|
43
41
|
|
|
44
|
-
Available built-in tools are `read`, `bash`, `powershell`, `edit`, `write`, `grep`, `find`, and `ls`. `defaultTools` can also name
|
|
42
|
+
Available built-in tools are `read`, `bash`, `powershell`, `edit`, `write`, `grep`, `find`, and `ls`. `defaultTools` can also name extension tools registered inactive.
|
|
45
43
|
|
|
46
|
-
A list of only `+name` and `-name` entries changes the inherited selection instead of replacing it. For example, this enables `
|
|
44
|
+
A list of only `+name` and `-name` entries changes the inherited selection instead of replacing it. For example, this enables `grep` next to the default tools:
|
|
47
45
|
|
|
48
46
|
```json
|
|
49
47
|
{
|
|
50
|
-
"defaultTools": ["+
|
|
48
|
+
"defaultTools": ["+grep"]
|
|
51
49
|
}
|
|
52
50
|
```
|
|
53
51
|
|
|
@@ -157,13 +155,13 @@ Resource paths in user settings resolve from the agent directory. Paths in proje
|
|
|
157
155
|
|
|
158
156
|
Resource arrays support glob exclusions with `!pattern`, exact inclusion with `+path`, and exact exclusion with `-path`. Pi loads resources listed in both user-level and project settings.
|
|
159
157
|
|
|
160
|
-
The built-in
|
|
158
|
+
The built-in extension is named `builtin:llama.cpp` in `extensions`. It loads by default; `-builtin:llama.cpp` disables it. A `+builtin:<name>` or `-builtin:<name>` entry in project settings overrides the user setting. `pi config` lists it under Built-in. `--no-extensions` disables it too, and `-e builtin:<name>` loads it explicitly.
|
|
161
159
|
|
|
162
160
|
## Updates, telemetry, and warnings
|
|
163
161
|
|
|
164
162
|
| Setting | Type | Default | Description |
|
|
165
163
|
|---|---|---|---|
|
|
166
164
|
| `collapseChangelog` | boolean | `false` | Show a condensed changelog after an update. |
|
|
167
|
-
| `enableInstallTelemetry` | boolean | `
|
|
165
|
+
| `enableInstallTelemetry` | boolean | `false` | Opt in to selected provider attribution headers (upstream pi branding). Does not control update checks. e sends no telemetry by default. |
|
|
168
166
|
| `enableAnalytics` | boolean | `false` | Opt in to analytics data sharing. Currently used only by the experimental first-run setup. |
|
|
169
167
|
| `warnings.anthropicExtraUsage` | boolean | `true` | Warn when Anthropic subscription authentication may use paid extra usage. |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@subimpact/e",
|
|
3
|
-
"version": "0.99.
|
|
3
|
+
"version": "0.99.6",
|
|
4
4
|
"description": "Minimal terminal coding harness. Fork of earendil-works/pi (MIT) with the MCP, codemode, and tool-search built-ins removed; compatibility with the classical pi extension/package ecosystem.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"piConfig": {
|
package/docs/mcp.md
DELETED
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
# MCP Servers
|
|
2
|
-
|
|
3
|
-
Pi connects to [Model Context Protocol](https://modelcontextprotocol.io) servers over stdio or streamable HTTP and makes their tools and resources available to the model.
|
|
4
|
-
|
|
5
|
-
## Quick setup
|
|
6
|
-
|
|
7
|
-
Add a local stdio server, check the connection, then start Pi:
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
pi mcp add filesystem -- npx -y @modelcontextprotocol/server-filesystem .
|
|
11
|
-
pi mcp list
|
|
12
|
-
pi
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
For a remote server:
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
pi mcp add docs --url https://example.com/mcp --bearer-token-env-var DOCS_TOKEN
|
|
19
|
-
pi mcp list
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
These commands add user-level servers by default. Add `--local` or `-l` to write the project configuration instead:
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
pi mcp add -l tools --env API_KEY='${TOOLS_KEY}' -- uvx tools-mcp
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
Use `/mcp` inside an interactive session to inspect connections, sign in, reconnect, change exposure, or enable and disable servers. Run `/reload` after adding, removing, or changing a server outside the session.
|
|
29
|
-
|
|
30
|
-
## Configure servers
|
|
31
|
-
|
|
32
|
-
Pi reads user-level servers from `~/.pi/agent/mcp.json` and project servers from `.pi/mcp.json`. Project configuration is read only after [project trust](security.md#understand-project-trust) is granted. A project entry replaces a user-level entry with the same name.
|
|
33
|
-
|
|
34
|
-
The format matches other MCP clients:
|
|
35
|
-
|
|
36
|
-
```json
|
|
37
|
-
{
|
|
38
|
-
"mcpServers": {
|
|
39
|
-
"filesystem": {
|
|
40
|
-
"command": "npx",
|
|
41
|
-
"args": ["-y", "@modelcontextprotocol/server-filesystem", "."]
|
|
42
|
-
},
|
|
43
|
-
"docs": {
|
|
44
|
-
"url": "https://example.com/mcp",
|
|
45
|
-
"headers": { "Authorization": "Bearer ${DOCS_TOKEN}" },
|
|
46
|
-
"description": "Search and read the product documentation"
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
Stdio servers use `command`, `args`, `env`, and `cwd`. Relative `cwd` values resolve against the session directory. A leading `~/` in `command`, an argument, or `cwd` names the home directory.
|
|
53
|
-
|
|
54
|
-
HTTP servers use `url`, `headers`, and `oauth` (see [Authenticate with OAuth](#authenticate-with-oauth)). The legacy SSE transport is not supported.
|
|
55
|
-
|
|
56
|
-
Both server types support:
|
|
57
|
-
|
|
58
|
-
- `timeout`: per-request timeout in seconds (default 60). Progress notifications reset it.
|
|
59
|
-
- `enabled: false`: keep the entry without connecting to it.
|
|
60
|
-
- `exposure` and `toolExposure`: control how tools reach the model (see [Control tool exposure](#control-tool-exposure)).
|
|
61
|
-
- `description`: what the server offers, in a sentence. It lists the server in the system prompt (see [Control tool exposure](#control-tool-exposure)), tool search ranks the server's tools by it, and codemode's `describeNamespace()` returns it. Without it, the first line of the server instructions is used once the server connects.
|
|
62
|
-
|
|
63
|
-
Keep personal servers and servers with credentials in the user-level file. Use the project file only for servers the project requires, and only in trusted projects.
|
|
64
|
-
|
|
65
|
-
### Configuration rules
|
|
66
|
-
|
|
67
|
-
- Server names may contain only letters, digits, `_`, and `-`. Tools are named `mcp__<server>__<tool>`, with every character other than letters, digits, and `_` replaced by `_`; tools of a server whose names then collide all get a hash suffix. Server names that differ only in `-` and `_` count as the same server: a second one is rejected, and a `mcp.json` server overrides a registered one.
|
|
68
|
-
- `type` is optional. A `command` selects stdio and a `url` selects streamable HTTP. When present, `type` must be `stdio`, `http`, or `streamable-http`.
|
|
69
|
-
- `sse` is rejected. Servers that document an SSE endpoint often also provide streamable HTTP, commonly at `/mcp` instead of `/sse`.
|
|
70
|
-
- `command` is one executable and `args` contains its arguments. It is not a shell command string.
|
|
71
|
-
- `env` and `headers` values can use environment variables such as `${GITHUB_TOKEN}`. They can also run a command with `!command`, but the command must make up the whole value, for example `"Authorization": "!echo Bearer $(gh auth token)"`.
|
|
72
|
-
- Invalid entries are reported and skipped without preventing other servers from connecting.
|
|
73
|
-
|
|
74
|
-
`pi mcp add` and `pi mcp remove` cover common changes from a shell. See [MCP commands](cli.md#mcp-commands) for their options.
|
|
75
|
-
|
|
76
|
-
### Inspect or change a server
|
|
77
|
-
|
|
78
|
-
`/mcp` lists configured servers with their state, tool count, exposure, and configuration source. Servers that need attention appear first. Select a server to inspect its tools and connection details, reconnect, sign in or out, change exposure, or enable and disable it.
|
|
79
|
-
|
|
80
|
-
Exposure and enabled-state changes are saved to the file that defines the server without replacing unrelated content. Disabled servers remain listed. Outside the interactive TUI, `/mcp` prints server status; `/mcp login <server>`, `/mcp logout <server>`, and `/mcp reconnect <server>` perform those actions directly.
|
|
81
|
-
|
|
82
|
-
Shell commands work without a session: `pi mcp add`, `pi mcp remove`, `pi mcp list`, `pi mcp login`, and `pi mcp logout`. Shell commands do not load extensions.
|
|
83
|
-
|
|
84
|
-
### Diagnose connection problems
|
|
85
|
-
|
|
86
|
-
Run `pi mcp list` to connect to every enabled server and print its state, tools, and errors. It exits with status 1 when an entry is invalid or an enabled server is not connected. `/mcp` shows the full connection error and the tail of stderr from a failed stdio server.
|
|
87
|
-
|
|
88
|
-
Pi reports configuration errors, failed connections, and required sign-ins once after startup. Server logging notifications are appended to `~/.pi/agent/mcp.log` as `<time> [<server>] <level> <logger>: <message>`. The file moves to `mcp.log.1` after it grows past 5 MB.
|
|
89
|
-
|
|
90
|
-
Pi connects every enabled server in the background when a session starts. A server's tools appear once it connects; the `codemode` description does not list them, so it does not change when servers connect. The first prompt waits up to 10 seconds only for servers with `direct` tools, which must be declared in its request. Other servers are waited for when they are needed: a codemode script waits for the servers it names (`mcp__<server>`) and, when it calls `searchTools()` or reads `ALL_TOOLS`, for all of them; `tool_search` and the resource tools also wait for all of them. HTTP network errors and transient statuses (408, 429, and 5xx) are retried twice. A dropped connection is shown as disconnected and reconnects on the next call. When a server announces a changed tool list, new tools are added and withdrawn tools become unreachable.
|
|
91
|
-
|
|
92
|
-
Stopping a stdio server closes its stdin, sends SIGTERM, then sends SIGKILL to its process group. This also stops servers launched through wrappers such as `npx` or `uvx`.
|
|
93
|
-
|
|
94
|
-
## Migrate configuration from another client
|
|
95
|
-
|
|
96
|
-
Move the converted entry under `mcpServers` in `mcp.json`, then run `pi mcp list` to validate it.
|
|
97
|
-
|
|
98
|
-
| Client | Conversion |
|
|
99
|
-
|---|---|
|
|
100
|
-
| Claude Desktop, Claude Code, or Cursor | Copy the existing `mcpServers` entry. |
|
|
101
|
-
| VS Code | Move an entry from the top-level `servers` object and replace `${input:...}` prompts with `${NAME}` environment variables. |
|
|
102
|
-
| Codex | Convert `[mcp_servers.<name>]` TOML fields such as `command`, `args`, `env`, and `url` to JSON. |
|
|
103
|
-
| OpenCode | Convert `"type": "local"` to a stdio entry, split its `command` array into `command` and `args`, rename `environment` to `env`, and replace `{env:NAME}` with `${NAME}`. Convert `"type": "remote"` to a URL entry. |
|
|
104
|
-
|
|
105
|
-
## Authenticate with OAuth
|
|
106
|
-
|
|
107
|
-
Remote servers that use OAuth, such as Sentry, need no credentials in `mcp.json`:
|
|
108
|
-
|
|
109
|
-
```json
|
|
110
|
-
{
|
|
111
|
-
"mcpServers": {
|
|
112
|
-
"sentry": { "url": "https://mcp.sentry.dev/mcp" }
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
When the server rejects an unauthenticated connection, `/mcp` shows that it needs sign-in. Select "Sign in", run `/mcp login sentry`, or run `pi mcp login sentry`. Pi opens the authorization page and waits for approval. If the browser runs on another machine, such as over SSH, paste its redirected URL into the sign-in screen. A running session uses the new credentials on its next turn.
|
|
118
|
-
|
|
119
|
-
Pi registers itself with the authorization server, stores tokens in `~/.pi/agent/mcp-auth.json`, and refreshes access tokens when they expire or the server rejects them. If a server later requests additional scope, Pi asks for sign-in again. Signing out deletes the stored credentials.
|
|
120
|
-
|
|
121
|
-
Credentials belong to a server name and URL. Servers with the same URL under different names, such as one per account, sign in separately; servers with the same name and URL in different `mcp.json` files share one sign-in.
|
|
122
|
-
|
|
123
|
-
OAuth applies to HTTP servers without an `Authorization` header. For a server that does not support dynamic client registration, configure a registered client:
|
|
124
|
-
|
|
125
|
-
```json
|
|
126
|
-
{
|
|
127
|
-
"mcpServers": {
|
|
128
|
-
"example": {
|
|
129
|
-
"url": "https://mcp.example.com/mcp",
|
|
130
|
-
"oauth": { "clientId": "my-client", "clientSecret": "${EXAMPLE_SECRET}", "callbackPort": 8765 }
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
The redirect URI must match the registered URI. `callbackPort` uses `http://127.0.0.1:<port>/callback`. To use another URI, set `callbackUrl`; it must use HTTP on `localhost`, `127.0.0.1`, or `[::1]`. Pi sends it exactly as written. When `callbackUrl` omits a port, Pi uses `callbackPort` or a free port and adds it to the URI, as allowed for loopback redirects by RFC 8252. `clientSecret` is optional and can use an environment variable or command.
|
|
137
|
-
|
|
138
|
-
Set `scope` to a space-separated list for servers that do not advertise their required scopes. Otherwise, Pi requests the advertised scopes. Later scope requests are added to the configured value.
|
|
139
|
-
|
|
140
|
-
Pi registers as `pi`. Some servers only accept registrations from known clients. Set `clientName` to send another name:
|
|
141
|
-
|
|
142
|
-
```json
|
|
143
|
-
{
|
|
144
|
-
"mcpServers": {
|
|
145
|
-
"figma": { "url": "https://mcp.figma.com/mcp", "oauth": { "clientName": "Claude Code" } }
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
The name is only sent when Pi registers a client. To register again under a new name, sign out first.
|
|
151
|
-
|
|
152
|
-
Pi finds the authorization server through the server's protected resource metadata (RFC 9728) and checks that the authorization server's metadata names the expected issuer (RFC 8414). Some servers advertise the wrong authorization server or none, so sign-in opens a page that does not exist. Set `authServerMetadataUrl` to the metadata document of the right authorization server:
|
|
153
|
-
|
|
154
|
-
```json
|
|
155
|
-
{
|
|
156
|
-
"mcpServers": {
|
|
157
|
-
"example": {
|
|
158
|
-
"url": "https://mcp.example.com/mcp",
|
|
159
|
-
"oauth": { "authServerMetadataUrl": "https://example.okta.com/.well-known/openid-configuration" }
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
Pi uses that document instead of discovery and trusts it as configured, so only point it at a document you trust. The URL must use HTTPS, except on `localhost`, `127.0.0.1`, or `[::1]`.
|
|
166
|
-
|
|
167
|
-
## Control tool exposure
|
|
168
|
-
|
|
169
|
-
Each server tool is registered as `mcp__<server>__<tool>`. The server's `exposure` determines how the model reaches it:
|
|
170
|
-
|
|
171
|
-
| Exposure | Behavior | Typical use |
|
|
172
|
-
|---|---|---|
|
|
173
|
-
| `codemode` (default) | Callable from [`codemode`](cli.md#tools) scripts, but neither declared to the model nor listed in the codemode description. Scripts find tools with `searchTools()`, `describeTool()`, or `ALL_TOOLS`. | General MCP servers, especially when scripts should combine or filter calls. |
|
|
174
|
-
| `deferred` | Not declared until [`tool_search`](cli.md#tools) loads a match for the next model call. | Large servers whose tools should be called directly after discovery. |
|
|
175
|
-
| `direct` | Declared to the model like a built-in tool and also callable from codemode. | Small, frequently used tool sets. |
|
|
176
|
-
| `hidden` | Registered but unreachable. | Servers or tools that should remain unavailable. |
|
|
177
|
-
|
|
178
|
-
`codemode-deferred` is accepted as an alias for `codemode`.
|
|
179
|
-
|
|
180
|
-
Servers with `codemode` or `deferred` tools are listed in the `mcp_servers` section of the system prompt, with how their tools are reached and one line from the configured `description` or, once connected, from the server instructions. Pi updates the section when a prompt starts, after waiting for servers with `direct` tools. When it changed, for example because a server connected and its summary became available, Pi appends the new section to the conversation instead of changing tool declarations, so earlier messages stay cached. `describeNamespace()` and the `namespace` option of `searchTools()` accept `mcp__dev-radius`, `mcp__dev_radius`, `dev-radius`, or `dev_radius`.
|
|
181
|
-
|
|
182
|
-
Pi activates `codemode` when a server with `codemode` exposure connects. It activates `tool_search` for a server with `deferred` exposure. To make the model see a tool without searching, give it `direct` exposure with `toolExposure`.
|
|
183
|
-
|
|
184
|
-
`toolExposure` overrides the server exposure for individual tools. Keys are exact server tool names or patterns where `*` matches any characters. Exact names win over patterns; among patterns, the first match wins. A server with `hidden` exposure can expose only selected tools:
|
|
185
|
-
|
|
186
|
-
```json
|
|
187
|
-
{
|
|
188
|
-
"mcpServers": {
|
|
189
|
-
"github": {
|
|
190
|
-
"url": "https://api.githubcopilot.com/mcp/",
|
|
191
|
-
"exposure": "deferred",
|
|
192
|
-
"toolExposure": {
|
|
193
|
-
"search_code": "direct",
|
|
194
|
-
"get_*": "codemode",
|
|
195
|
-
"delete_*": "hidden"
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
`pi mcp list` marks tools whose exposure differs from their server. The Tools view in `/mcp` also shows the effective exposure.
|
|
203
|
-
|
|
204
|
-
Tools with `codemode` or `deferred` exposure can be reached through either indirect mechanism: codemode scripts can call them, and `tool_search` can load them. Codemode calls do not depend on the active tool set, so they remain available after `/tree`, resume, and fork. Tools loaded by `tool_search` are recorded in the transcript and remain declared on that branch.
|
|
205
|
-
|
|
206
|
-
To keep `codemode` active without MCP servers, add `"defaultTools": ["+codemode"]` to [settings](settings.md#tools). To prevent automatic codemode activation, set `"autoEnableCodemode": false` beside `mcpServers`. A project value overrides the user-level value. Pi warns once when neither `codemode` nor `tool_search` is active and non-direct tools cannot be called.
|
|
207
|
-
|
|
208
|
-
Text results over 20 KB reach the model with their middle removed around a `…N chars truncated…` marker. The full text is saved to a temporary file named in the result. Codemode scripts receive the complete result and can reduce it before returning output to the model.
|
|
209
|
-
|
|
210
|
-
Codemode scripts receive the complete MCP `CallToolResult`, including `content`, `structuredContent`, and `isError`. A result with `isError` resolves inside scripts but is reported as an error for direct calls. `image(result.content[0])` forwards an image block. Server instructions are not part of any tool description; scripts read them with `describeNamespace("mcp__<server>")`, which also returns the server's tool names.
|
|
211
|
-
|
|
212
|
-
## Use resources
|
|
213
|
-
|
|
214
|
-
When a connected server offers [resources](https://modelcontextprotocol.io/specification/2025-11-25/server/resources), Pi adds the resource tools used by Codex and OpenCode:
|
|
215
|
-
|
|
216
|
-
- `list_mcp_resources` lists resources as JSON: `{ server?, resources: [{ server, uri, name, ... }], nextCursor? }`. With `server`, it lists one page; `cursor` continues with the next page. Without `server`, it lists every resource from every server.
|
|
217
|
-
- `list_mcp_resource_templates` lists URI templates for resources the servers do not list directly.
|
|
218
|
-
- `read_mcp_resource` reads a resource by `server` and `uri`. Text reaches the model as text and images as images. Other binary resources are saved to temporary files, and the model receives the path. Scripts receive `{ server, uri, contents }`.
|
|
219
|
-
|
|
220
|
-
These tools reach every enabled, non-hidden server with resources. Their exposure is the widest exposure among those servers: `direct`, then `codemode` or `deferred`. Resource links in tool results identify `read_mcp_resource` and the server.
|
|
221
|
-
|
|
222
|
-
Resources for MCP Apps, identified by `ui://` URIs or `text/html;profile=mcp-app`, are omitted because Pi does not render them. Resource icons are also omitted.
|
|
223
|
-
|
|
224
|
-
Reading and listing resources is retried once after a transient HTTP error (408, 429, or 5xx). Tool calls are not retried because the server may already have performed them.
|
|
225
|
-
|
|
226
|
-
## Permissions
|
|
227
|
-
|
|
228
|
-
Every MCP call passes through Pi's tool pipeline. Extension `tool_call` and `tool_result` handlers, including permission gates, therefore apply to MCP tools. Calls made from codemode scripts carry the codemode call ID as `parentToolCallId`.
|
|
229
|
-
|
|
230
|
-
`pi.getAllTools()` reports the annotations declared by each server: `readOnlyHint`, `destructiveHint`, `idempotentHint`, and `openWorldHint`. Permission extensions can use these hints to decide which calls require confirmation (see [Tool exposure](extensions.md#tool-exposure)). Resource tools are marked read-only.
|
|
231
|
-
|
|
232
|
-
## Extensions and SDK
|
|
233
|
-
|
|
234
|
-
### Add servers from extensions
|
|
235
|
-
|
|
236
|
-
Extensions can add servers for the current session with `pi.registerMcpServer(name, config)`, using the same shape as an `mcpServers` entry (see [MCP servers in extensions](extensions.md#mcp-servers)). Registered servers connect like configured servers and appear in `/mcp` with the extension as their source.
|
|
237
|
-
|
|
238
|
-
Changes to enabled state or exposure apply only to the current session. A file-configured server with the same name takes precedence, and `/mcp` lists the overridden registration. `pi mcp` shell commands do not load extensions and only see file-configured servers.
|
|
239
|
-
|
|
240
|
-
### Replace the built-in MCP support
|
|
241
|
-
|
|
242
|
-
An installed extension that registers `/mcp`, such as `pi-mcp-adapter`, replaces the built-in MCP support for sessions. Pi then does not read `mcp.json` or connect its servers in a session, and `/mcp` belongs to the extension. Remove the extension to restore the built-in behavior. To disable built-in MCP support without a replacement, disable `mcp` under Built-in in `pi config`, or set `"extensions": ["-builtin:mcp"]` in [settings](settings.md#resources).
|
|
243
|
-
|
|
244
|
-
An extension that registers `codemode` or `tool_search` similarly replaces the built-in tool with that name. Shell-level `pi mcp` commands always use the built-in implementation.
|
|
245
|
-
|
|
246
|
-
### Use MCP from the SDK
|
|
247
|
-
|
|
248
|
-
SDK sessions do not load built-in extensions. Add the MCP extension, the codemode extension for `codemode` servers, and the tool-search extension for `deferred` servers to the resource loader. See [Codemode and MCP](sdk.md#codemode-mcp).
|