feat(mcp): turn off a global server for Pi from the project switch

A Pi project entry replaces the global one and is skipped without a
command or url, so a switch-only entry left the server on in Pi and the
project page could not turn it off there. Reporters want a server off in
one project while every other project keeps loading it.

For a project under mcp.projects, the switch now writes the global
server's command, or its url without the query, with enabled: false to
the project's .pi/mcp.json. A disabled server never starts, so args, env
and headers stay out of a file that may be committed, and every sync
rewrites the entry from the global server. A project's own config cannot
see the global server, so pi there is still refused. The migration that
dropped pi from switch-only entries is gone.

Refs #305
This commit is contained in:
Willie
2026-10-01 16:08:23 +08:00
parent 886e3672a2
commit f837f0e94d
27 changed files with 175 additions and 124 deletions
+12 -5
View File
@@ -367,14 +367,14 @@ defined in the global file therefore loads in every project. To stop it loading
one project, add an entry **with the same name the Agent's global file uses** and
mark it `disabled`.
This works with three clients only:
This works with four clients only:
| Client | Supported | What Skillshare writes |
|---|---|---|
| Claude Code | Yes | `~/.claude.json`: the name, in this project's `disabledMcpServers` list |
| OpenCode | Yes | `opencode.json`: `"NAME": {"enabled": false}` |
| Kilo Code | Yes | `kilo.jsonc`: `"NAME": {"enabled": false}` |
| Pi | No | Requires a complete entry: use `piOptions: {enabled: false}` on a server with command/url |
| Pi | Yes, from `mcp.projects` | `.pi/mcp.json`: `"NAME": {"command": "...", "enabled": false}`, see below |
| Codex | No | See below |
| Every other client | No | Selecting one is an error; nothing is written |
@@ -391,6 +391,14 @@ no `command` or `url`, and Codex then fails to load its whole configuration with
could stop Codex from starting for another. Turn the server off per machine instead,
with `enabled = false` in `~/.codex/config.toml`.
Pi replaces a global entry with the project entry of the same name, and skips an entry
without a `command` or `url`. So for Pi, Skillshare writes the global server's `command`,
or its `url` without the query, next to `enabled: false`. A disabled server is never
started, so args, env and headers stay out of the project file, and other projects keep
the server. Every sync rewrites the entry from the global server. This needs the global
server, so it works for a project under `mcp.projects` in the global config; a project's
own config cannot see the global one, and `pi` in a `disabled` entry there is an error.
### OpenCode and Kilo Code
```bash
@@ -959,8 +967,8 @@ file; add `-l` for a project. `pi mcp list` checks connections by starting every
server; `pi mcp login NAME` requires user approval.
Pi server names allow only letters, digits, `_` and `-`. A Pi project entry replaces the
global entry of the same name, so Pi cannot take a switch-only `disabled` entry. To turn
off a global server in one project, use `piOptions: {enabled: false}` on a complete entry.
global entry of the same name; to turn off a global server in one project, see
[Turn off a global server in one project](#turn-off-a-global-server-in-one-project).
### Other Pi settings {#pi-options}
@@ -1051,7 +1059,6 @@ What the next sync does:
| `mcp.directTools`, or a project's `directTools` under `mcp.projects` | The default is written into each server that reaches Pi and has no value of its own, as above. A project's `false` overrides the global value |
| `piOptions.includeTools` / `excludeTools` | `tools.allow` / `tools.deny`; a `directTools` next to them still becomes `piOptions.exposure` |
| Other `pi-mcp-adapter` fields in `piOptions`: `approveTools`, `auth`, `bearerToken`, `bearerTokenEnv`, `bearerTokenStore`, `caFile`, `debug`, `exposeResources`, `idleTimeout`, `inheritEnv`, `lifecycle`, `protocolVersion`, `requestHeadersCommand`, `requestTimeoutMs`, `searchKeywords`, `socket`, `tasks`, `toolPrefix`, `trace` | Removed, because Pi's built-in MCP does not read them |
| `pi` in the `targets` of a `disabled` entry | `pi` is removed from that list. Pi cannot take a switch-only entry, so that server is on again there; to keep it off, add a complete entry with `piOptions: {enabled: false}` |
A `directTools`, `includeTools` or `excludeTools` that would overwrite an exposure the
server already sets, or that is not a list of tool names, is dropped with its own