feat(coding-agent): allow project mcp.json to override enabled and exposure of global servers

A .pi/mcp.json entry without command, url, or type overrides only enabled,
exposure, and toolExposure of the global server with the same name. /mcp can
enable or disable a global server for the trusted project, and pi mcp list
shows the override.

closes #10277
This commit is contained in:
Armin Ronacher 2026-10-02 18:34:49 +02:00
parent c71a496ff9
commit 1387af7b42
6 changed files with 152 additions and 28 deletions

View file

@ -31,6 +31,16 @@ Use `/mcp` inside an interactive session to inspect connections, sign in, reconn
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.
A project entry without `command`, `url`, or `type` overrides only `enabled`, `exposure`, and `toolExposure` of the user-level server with the same name and keeps the rest, including `env`, `headers`, and `auth`. For example, this turns off a user-level server in one project:
```json
{
"mcpServers": {
"internal-tools": { "enabled": false }
}
}
```
The format matches other MCP clients:
```json
@ -77,7 +87,7 @@ Keep personal servers and servers with credentials in the user-level file. Use t
`/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.
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.
Exposure and enabled-state changes are saved to the file that defines the server without replacing unrelated content. In a trusted project, "Enable in this project" and "Disable in this project" add a project override for a user-level server; later changes to that server are saved to the override. 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.
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.