From f837f0e94de5ea15c98ec687df46ea129bad8149 Mon Sep 17 00:00:00 2001 From: Willie Date: Thu, 1 Oct 2026 16:08:23 +0800 Subject: [PATCH] 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 --- internal/mcp/disabled_test.go | 107 ++++++++++-------- internal/mcp/migrate_test.go | 6 +- internal/mcp/model.go | 22 +--- internal/mcp/plan.go | 16 ++- internal/mcp/render.go | 18 ++- internal/mcp/source.go | 1 - skills/skillshare/references/mcp.md | 8 +- ui/src/components/mcp/MCPProjectView.test.tsx | 6 +- ui/src/components/mcp/MCPProjectView.tsx | 6 +- ui/src/components/mcp/mcpView.test.ts | 8 +- ui/src/components/mcp/mcpView.ts | 6 +- ui/src/i18n/locales/de.json | 1 - ui/src/i18n/locales/en.json | 1 - ui/src/i18n/locales/es.json | 1 - ui/src/i18n/locales/fa.json | 1 - ui/src/i18n/locales/fr.json | 1 - ui/src/i18n/locales/id.json | 1 - ui/src/i18n/locales/ja.json | 1 - ui/src/i18n/locales/ko.json | 1 - ui/src/i18n/locales/pt-BR.json | 1 - ui/src/i18n/locales/zh-CN.json | 1 - ui/src/i18n/locales/zh-TW.json | 1 - website/docs/reference/commands/mcp.md | 17 ++- .../current/reference/commands/mcp.md | 17 ++- .../current/reference/commands/mcp.md | 18 ++- .../current/reference/commands/mcp.md | 16 ++- .../current/reference/commands/mcp.md | 16 ++- 27 files changed, 175 insertions(+), 124 deletions(-) diff --git a/internal/mcp/disabled_test.go b/internal/mcp/disabled_test.go index 43c53a74d..f1e9bdf4c 100644 --- a/internal/mcp/disabled_test.go +++ b/internal/mcp/disabled_test.go @@ -5,6 +5,7 @@ import ( "maps" "os" "path/filepath" + "reflect" "slices" "strings" "testing" @@ -81,7 +82,8 @@ func TestDisabledRejected(t *testing.T) { } } -// Loading drops pi from an old switch, but saving a new one for pi still fails. +// A project's own config cannot see the global server, so it has no command or url to give +// Pi's switch, and saving one for pi fails. func TestPiSwitchRejectedOnSave(t *testing.T) { s := testService(t) s.ProjectRoot = filepath.Join(s.Home, "project") @@ -312,7 +314,7 @@ func TestSwitchWithoutTargetsFollowsTheProject(t *testing.T) { }{ "only what the project uses": {"claude, opencode, kilocode, pi", "opencode, kilocode", []string{"kilocode", "opencode"}}, "only what the server reaches": {"claude, codex, pi", "claude, opencode", []string{"claude"}}, - "skips an Agent with no switch": {"cursor, opencode, pi", "cursor, opencode, pi", []string{"opencode"}}, + "skips an Agent with no switch": {"cursor, opencode, pi", "cursor, opencode, pi", []string{"opencode", "pi"}}, } { t.Run(name, func(t *testing.T) { s, tmp := projectsService(t, "mcp:\n servers:\n docs:\n command: tool\n targets: ["+tc.global+"]\n projects:\n $TMP/p1:\n targets: ["+tc.project+"]\n servers:\n docs:\n disabled: true\n") @@ -334,60 +336,71 @@ func TestSwitchWithoutTargetsFollowsTheProject(t *testing.T) { } } -// Pi's built-in MCP has no per-project switch, so a switch that names no targets leaves Pi -// alone even where the project and the global server both reach it. -func TestSwitchLeavesPiAlone(t *testing.T) { - s, tmp := projectsService(t, "mcp:\n servers:\n docs:\n command: tool\n targets: [opencode, pi]\n projects:\n $TMP/p1:\n targets: [opencode, pi]\n servers:\n mine:\n command: tool\n targets: [pi]\n docs:\n disabled: true\n") - plan, err := s.Preview() +// Pi replaces a global entry with the project entry of the same name, so its switch carries +// the global server's command or url, and nothing else: args, env, headers and the url's +// query stay out of the project file. +func TestPiSwitchCarriesTheGlobalEndpoint(t *testing.T) { + s, tmp := projectsService(t, "mcp:\n servers:\n docs:\n command: tool\n args: [--port, \"3000\"]\n env: {TOKEN: {fromEnv: TOKEN}}\n targets: [opencode, pi]\n web:\n url: https://example.com/mcp?key=secret\n headers: {Authorization: {fromEnv: AUTH}}\n targets: [pi]\n projects:\n $TMP/p1:\n targets: [opencode, pi]\n servers:\n docs:\n disabled: true\n web:\n disabled: true\n") + plan := applyProjects(t, s) + for _, c := range plan.Changes { + if c.Root == filepath.Join(tmp, "p1") && !c.Switch { + t.Fatalf("not a switch: %+v", c) + } + } + data, err := os.ReadFile(filepath.Join(tmp, "p1", ".pi", "mcp.json")) if err != nil { t.Fatal(err) } - var got []string - for _, c := range plan.Changes { - if c.Root == filepath.Join(tmp, "p1") && c.Name == "docs" { - got = append(got, c.Target) - } + var file struct{ McpServers map[string]map[string]any } + if err := json.Unmarshal(data, &file); err != nil { + t.Fatal(err) } - if !slices.Equal(got, []string{"opencode"}) { - t.Fatalf("got %v", got) + want := map[string]map[string]any{"docs": {"command": "tool", "enabled": false}, "web": {"url": "https://example.com/mcp", "enabled": false}} + if !reflect.DeepEqual(file.McpServers, want) { + t.Fatalf("project .pi/mcp.json: %s", data) + } + if global, _ := os.ReadFile(filepath.Join(tmp, ".pi", "agent", "mcp.json")); !strings.Contains(string(global), "3000") { + t.Fatalf("global .pi/agent/mcp.json lost the server: %s", global) } } -// Before 0.23.0 an adapter user could turn a global server off for one project in Pi. Pi's -// built-in MCP has no such switch, so loading drops pi from the entry instead of failing sync. -func TestPiSwitchLeavesPiOnLoad(t *testing.T) { - s, tmp := projectsService(t, `mcp: - targets: [opencode] - projects: - $TMP/both: - servers: - docs: - disabled: true - targets: [pi, opencode] - $TMP/only: - servers: - docs: - disabled: true - targets: [pi] -`) - plan, err := s.Preview() - if err != nil || plan.Blocked { - t.Fatalf("%+v %v", plan, err) - } - if len(plan.Changes) != 1 || plan.Changes[0].Target != "opencode" || plan.Changes[0].Root != filepath.Join(tmp, "both") { - t.Fatalf("changes: %+v", plan.Changes) - } - if want := "Pi cannot turn off a server per project; the next sync removes pi from these entries: docs (both, only)"; len(plan.Notices) != 1 || plan.Notices[0] != want { - t.Fatalf("notices: %q", plan.Notices) - } - if _, err := s.Mutate(Mutation{Name: "other", Server: &Server{Command: "other"}}, "", false); err != nil { +// The switch follows the global server, and removing it takes the Pi entry away. +func TestPiSwitchFollowsTheGlobalServer(t *testing.T) { + s, tmp := projectsService(t, "mcp:\n servers:\n docs:\n command: tool\n targets: [pi]\n projects:\n $TMP/p1:\n targets: [pi]\n servers:\n docs:\n disabled: true\n") + applyProjects(t, s) + project := filepath.Join(tmp, "p1", ".pi", "mcp.json") + config, _ := os.ReadFile(s.ConfigPath) + if err := os.WriteFile(s.ConfigPath, []byte(strings.Replace(string(config), "command: tool", "command: tool2", 1)), 0600); err != nil { t.Fatal(err) } - data, _ := os.ReadFile(s.ConfigPath) - if strings.Contains(string(data), "- pi") || strings.Count(string(data), "- opencode") != 2 || !strings.Contains(string(data), "targets: []") { - t.Fatalf("saved config: %s", data) + applyProjects(t, s) + if data, _ := os.ReadFile(project); !strings.Contains(string(data), `"tool2"`) { + t.Fatalf("switch did not follow the global command: %s", data) } - if source, err := LoadSource(s.ConfigPath); err != nil || len(source.Notices) != 0 { - t.Fatalf("%v %v", source, err) + config, _ = os.ReadFile(s.ConfigPath) + if err := os.WriteFile(s.ConfigPath, []byte(strings.Replace(string(config), " docs:\n disabled: true\n", " {}\n", 1)), 0600); err != nil { + t.Fatal(err) + } + applyProjects(t, s) + if data, _ := os.ReadFile(project); strings.Contains(string(data), "docs") { + t.Fatalf("switch still in Pi: %s", data) + } +} + +// A switch that names pi keeps it; there is nothing left to migrate. +func TestPiSwitchNamedInTargetsStays(t *testing.T) { + s, tmp := projectsService(t, "mcp:\n servers:\n docs:\n command: tool\n targets: [opencode, pi]\n projects:\n $TMP/p1:\n servers:\n docs:\n disabled: true\n targets: [pi]\n") + plan, err := s.Preview() + if err != nil || plan.Blocked || len(plan.Notices) != 0 { + t.Fatalf("%+v %v", plan, err) + } + var got []string + for _, c := range plan.Changes { + if c.Root == filepath.Join(tmp, "p1") { + got = append(got, c.Target) + } + } + if !slices.Equal(got, []string{"pi"}) { + t.Fatalf("got %v", got) } } diff --git a/internal/mcp/migrate_test.go b/internal/mcp/migrate_test.go index db990edcf..a295777e7 100644 --- a/internal/mcp/migrate_test.go +++ b/internal/mcp/migrate_test.go @@ -36,7 +36,7 @@ mcp: targets: [pi, opencode] ` -var retiredFields = []string{"piExtension", "piOptionsPrune", "idleTimeout", "includeTools", "directTools", "[pi, opencode]"} +var retiredFields = []string{"piExtension", "piOptionsPrune", "idleTimeout", "includeTools", "directTools"} // legacyService is a service over legacyConfig that records the files it backs up. func legacyService(t *testing.T) (*Service, *[]string) { @@ -78,9 +78,9 @@ func TestSyncSavesTheConfigWithoutRetiredSettings(t *testing.T) { if err != nil || plan.Blocked { t.Fatalf("%+v %v", plan, err) } - // Five retired kinds, the tool policy lists converted from includeTools, and what Pi's + // Four retired kinds, the tool policy lists converted from includeTools, and what Pi's // built-in MCP needs, which the sync keeps saying after the config is saved. - if len(plan.Notices) != 7 || plan.Notices[6] != PiBuiltinNotice || !plan.Migrates { + if len(plan.Notices) != 6 || plan.Notices[5] != PiBuiltinNotice || !plan.Migrates { t.Fatalf("notices: %q", plan.Notices) } result, err := s.Apply(plan.Revision) diff --git a/internal/mcp/model.go b/internal/mcp/model.go index b2f086c51..62bbbda2f 100644 --- a/internal/mcp/model.go +++ b/internal/mcp/model.go @@ -88,6 +88,9 @@ type Server struct { // Agent's global config defines. Unselecting an Agent already covers a server // Skillshare defines, so a disabled server carries no command or url. Disabled bool `yaml:"disabled,omitempty" json:"disabled,omitempty"` + // global is the global server a project's switch-only entry turns off, when the plan + // knows it. Pi needs its command or url to take the switch. + global *Server } // legacyServerFields chose Pi's MCP extension and opted in to pruning Pi fields, before @@ -161,9 +164,7 @@ func (m migration) reachesPi(server *yaml.Node) bool { // pi-mcp-extension is also keyed "piExtension."; // - pi-mcp-adapter piOptions are dropped, keyed "piOptions."; // - directTools and piOptions includeTools/excludeTools become Pi exposure settings or -// tools (adoptAdapterTools), keyed "piTools", or are dropped, keyed "piTools."; -// - pi and piAccounts leave the targets of a switch-only entry, keyed "piSwitch": Pi has -// no per-project switch, and an entry left with no targets stays, turning nothing off. +// tools (adoptAdapterTools), keyed "piTools", or are dropped, keyed "piTools.". func migrateServers(servers *yaml.Node, m migration) map[string][]string { found := map[string][]string{} servers = deref(servers) @@ -201,21 +202,6 @@ func migrateServers(servers *yaml.Node, m migration) map[string][]string { if options := deref(field(server, "piOptions")); options != nil && options.Kind == yaml.MappingNode && len(options.Content) == 0 { drop(server, "piOptions") } - disabled := deref(field(server, "disabled")) - targets := deref(field(server, "targets")) - if disabled == nil || disabled.Tag != "!!bool" || disabled.Value != "true" || targets == nil || targets.Kind != yaml.SequenceNode { - continue - } - kept := []*yaml.Node{} - for _, target := range targets.Content { - if value := deref(target).Value; value != "pi" && !slices.Contains(m.piAccounts, value) { - kept = append(kept, target) - } - } - if len(kept) < len(targets.Content) { - targets.Content = kept - found["piSwitch"] = append(found["piSwitch"], name) - } } return found } diff --git a/internal/mcp/plan.go b/internal/mcp/plan.go index c49b1f97e..48b21a8e4 100644 --- a/internal/mcp/plan.go +++ b/internal/mcp/plan.go @@ -35,6 +35,10 @@ func switchOnly(target string, entry map[string]any) bool { if strings.HasPrefix(target, claudeOffPrefix) { return true } + if target == "pi" { + // Pi's switch carries the global server's command or url; see renderDisabled. + return len(entry) == 2 && entry["enabled"] == false && (entry["command"] != nil || entry["url"] != nil) + } return len(entry) == 1 && (entry["enabled"] == false || entry["disabled"] == true) } @@ -261,23 +265,29 @@ func SwitchTargets(server Server, defaults, reached []string) TargetList { func followingSwitches(servers map[string]Server, defaults []string, global *Source) map[string]Server { out := maps.Clone(servers) for name, server := range servers { - if !server.Disabled || server.Targets != nil { + if !server.Disabled { continue } var reached []string if global != nil { if shared, ok := global.Servers[name]; ok { + server.global = &shared if reached = shared.Targets; reached == nil { reached = global.Targets } } } + if server.Targets != nil { + out[name] = server + continue + } server.Targets = SwitchTargets(server, defaults, reached) - // The off list is per account, so an account that has the server gets the switch too. + // Claude Code's off list is per account, so an account that has the server gets the + // switch too. Pi accounts all read the project's one .pi/mcp.json, which pi writes. if global != nil { for _, account := range sortedKeys(global.Accounts) { agent := global.Accounts[account].Agent - if _, err := renderDisabled(agent, server); err == nil && slices.Contains(defaults, agent) && (reached == nil || slices.Contains(reached, account)) { + if _, err := renderDisabled(agent, server); err == nil && agent == "claude" && slices.Contains(defaults, agent) && (reached == nil || slices.Contains(reached, account)) { server.Targets = append(server.Targets, account) } } diff --git a/internal/mcp/render.go b/internal/mcp/render.go index 55620bb50..4ace4f792 100644 --- a/internal/mcp/render.go +++ b/internal/mcp/render.go @@ -2,6 +2,7 @@ package mcp import ( "fmt" + "net/url" "sort" ) @@ -21,10 +22,25 @@ func renderDisabled(target string, s Server) (map[string]any, error) { // Codex fails its whole config load with "invalid transport". The project file is // usually committed, so one person's switch would break Codex for a teammate. return nil, fmt.Errorf("codex cannot turn off a global server from a project file: on a machine whose global config lacks the server, Codex stops loading its whole config; set enabled = false in ~/.codex/config.toml instead") + case target == "pi" && s.global != nil: + // Pi replaces a global entry with the project entry of the same name and skips one + // without a command or url. A disabled server is never started, so its command or + // url alone is enough; args, env, headers and the url's query, which may hold a key, + // stay out of the project file, which may be committed. Validate already refuses a + // url with credentials or a fragment. + if s.global.Command != "" { + return map[string]any{"command": s.global.Command, "enabled": false}, nil + } + u, err := url.Parse(s.global.URL) + if err != nil { + return nil, fmt.Errorf("pi: invalid url of the global server: %w", err) + } + u.RawQuery = "" + return map[string]any{"url": u.String(), "enabled": false}, nil case target == "pi": // Pi replaces a global entry with the project entry of the same name, and skips one // without a command or url, so a switch-only entry leaves the global server on. - return nil, fmt.Errorf("pi cannot turn off a global server with a switch-only entry: a Pi project entry replaces the global one, so it needs the server's command or url; add the complete server with piOptions: {\"enabled\": false} instead") + return nil, fmt.Errorf("pi cannot turn off a server the global config does not define for it: a Pi project entry replaces the global one, so it needs the server's command or url; add the complete server with piOptions: {\"enabled\": false} instead") } return nil, fmt.Errorf("%s cannot turn off a global server from a project file; disabled supports claude, opencode and kilocode", target) } diff --git a/internal/mcp/source.go b/internal/mcp/source.go index 437962fd4..b32780703 100644 --- a/internal/mcp/source.go +++ b/internal/mcp/source.go @@ -343,7 +343,6 @@ func legacyNotices(legacy map[string][]legacyName) []string { if len(adapter) > 0 { add("Pi's built-in MCP does not read "+strings.Join(adapter, ", ")+"; the next sync removes them", keys...) } - add("Pi cannot turn off a server per project; the next sync removes pi from these entries", "piSwitch") add("directTools, includeTools and excludeTools become tool settings; the next sync converts them", "piTools") add("directTools, includeTools or excludeTools the server already covers, or that are not tool lists, are dropped; the next sync removes them", "piTools.directTools", "piTools.excludeTools", "piTools.includeTools") return notices diff --git a/skills/skillshare/references/mcp.md b/skills/skillshare/references/mcp.md index beb4066b9..4d9d22817 100644 --- a/skills/skillshare/references/mcp.md +++ b/skills/skillshare/references/mcp.md @@ -233,8 +233,10 @@ skillshare mcp edit docs --pi-options '{}' --no-tui values are refused; command values in `piOptions` are rejected even under non-secret keys such as `oauth.clientId`. - Pi server names allow only letters, digits, `_` and `-`. -- Pi cannot take a switch-only `disabled` entry. Use `piOptions: {enabled: false}` on - a complete server instead. +- A `disabled` entry under `mcp.projects` turns a global server off for Pi too: Skillshare + writes the global server's `command` (or `url` without the query) with `enabled: false` + to `.pi/mcp.json`. A project's own config cannot see the global server, so `pi` there + is an error. ## Tool policy @@ -290,7 +292,7 @@ printing `Updated config.yaml for 0.23.0 (backup: )`. `--dry-run` writes n apply to servers that reach Pi without their own value. - `piOptions.includeTools`/`excludeTools` → `tools.allow`/`tools.deny` (a `directTools` next to them still becomes `piOptions.exposure`). -- Other adapter-only `piOptions` are dropped; `pi` is removed from `disabled` entries. +- Other adapter-only `piOptions` are dropped. - `--pi-extension` and `--pi-options-prune`: drop them. `--direct-tools`: use `--pi-options '{"exposure":"direct"}'`, or `--pi-options '{"toolExposure":{"TOOL":"direct"}}'`. - `mcp import --from pi` still reads `mcp-adapter.json` (read-only; `mcp.json` wins on diff --git a/ui/src/components/mcp/MCPProjectView.test.tsx b/ui/src/components/mcp/MCPProjectView.test.tsx index f7905ec26..fe9824582 100644 --- a/ui/src/components/mcp/MCPProjectView.test.tsx +++ b/ui/src/components/mcp/MCPProjectView.test.tsx @@ -51,9 +51,11 @@ describe('MCP project view', () => { await waitFor(() => expect(mcpApi.save).toHaveBeenLastCalledWith({ name: 'context7', replace: true, server: { disabled: true }, project: '/work/app' })); }); - it('says Pi keeps loading a server turned off here, since Pi has no per-project switch', () => { + // Pi's switch carries the global server's command, so Pi turns it off here like the others. + it('turns a server off here for Pi too', () => { view({ docs: { command: 'npx', targets: ['opencode', 'pi'] } }, { targets: ['opencode', 'pi'], servers: { docs: { disabled: true } } }); - expect(screen.getByText('Still loads in Pi, which has no per-project switch.')).toBeInTheDocument(); + expect(screen.getByRole('img', { name: 'Off in OpenCode, Pi' })).toBeInTheDocument(); + expect(screen.queryByText(/Still loads in/)).not.toBeInTheDocument(); }); it("offers to import servers found in this project's Agent files, reading that project's file", async () => { diff --git a/ui/src/components/mcp/MCPProjectView.tsx b/ui/src/components/mcp/MCPProjectView.tsx index c891e13e8..3fc067bdc 100644 --- a/ui/src/components/mcp/MCPProjectView.tsx +++ b/ui/src/components/mcp/MCPProjectView.tsx @@ -45,7 +45,7 @@ function projectViewModel(data: MCPList, root: string, offered: readonly string[ const unmanaged = data.unmanaged.filter((u) => u.project === root); // A switch for a global server belongs to the list above; everything else is the project's own. const own = Object.fromEntries(Object.entries(servers).filter(([n, s]) => !(s.disabled && globals[n]))); - // A switch that names no targets follows the project, and Pi has none. + // A switch that names no targets follows the project. Pi's needs a global server's command or url. const targetsOf = (n: string) => own[n]?.targets ?? (own[n]?.disabled ? targets.filter((x) => x !== 'pi') : targets); const offTargets = mcpOffTargets; const switchable = (server: MCPServer) => switchTargets(server, defaults, targets); @@ -187,12 +187,12 @@ export default function MCPProjectView({ data, root, offered, onChanged, onRemov const off = Boolean(entry?.disabled); const to = switchable(server); // Off shows as Agent logos. A sentence is kept for the switch that cannot be used, which needs a reason. - const written = (entry?.targets ?? to).filter((x) => mcpOffTargets.includes(x)); + const written = (entry?.targets ?? to).filter((x) => mcpOffTargets.includes(x) || x === 'pi'); const reason = entry && !off ? t('mcp.projects.overridden') : off ? (written.length === 0 ? t('mcp.projects.noSwitchHere') : '') : to.length > 0 ? '' // Some Agent could turn it off, just none this project uses. - : switchTargets(server, defaults, mcpOffTargets).length > 0 ? t('mcp.projects.noSwitchHere') : t('mcp.projects.noSwitch'); + : switchTargets(server, defaults, [...mcpOffTargets, 'pi']).length > 0 ? t('mcp.projects.noSwitchHere') : t('mcp.projects.noSwitch'); // What the page has to admit: the badge says off, yet an Agent without a switch keeps // loading the server here, and a list saved with the entry does not follow the project. const stillOn = off ? targets.filter((x) => (server.targets ?? defaults).includes(x) && !written.includes(x)) : []; diff --git a/ui/src/components/mcp/mcpView.test.ts b/ui/src/components/mcp/mcpView.test.ts index 915eba53e..f1f30cf1f 100644 --- a/ui/src/components/mcp/mcpView.test.ts +++ b/ui/src/components/mcp/mcpView.test.ts @@ -74,9 +74,13 @@ describe('MCP view helpers', () => { describe('switchTargets', () => { const context7 = { command: 'npx', targets: ['claude', 'opencode', 'kilocode', 'pi'] }; - // Pi has no per-project switch, so it is never among them. it('turns a global server off only for the Agents the project uses', () => { - expect(switchTargets(context7, [], ['opencode', 'pi'])).toEqual(['opencode']); + expect(switchTargets(context7, [], ['opencode', 'pi'])).toEqual(['opencode', 'pi']); + }); + + // Pi's switch carries the global server's command or url, so a switch entry alone cannot reach it. + it('leaves Pi out for a switch entry, which has no command or url', () => { + expect(switchTargets({ disabled: true }, ['opencode', 'pi'], ['opencode', 'pi'])).toEqual(['opencode']); }); it('follows the default targets of a server that names none', () => { diff --git a/ui/src/components/mcp/mcpView.ts b/ui/src/components/mcp/mcpView.ts index 5b523f7fe..6aeea46f1 100644 --- a/ui/src/components/mcp/mcpView.ts +++ b/ui/src/components/mcp/mcpView.ts @@ -282,9 +282,10 @@ export const isResolvable = (change: MCPChange) => /** Whether importing can settle a conflict. It reads the Agent's global file, which never holds a project's switch. */ export const canImportConflict = (change: MCPChange) => isResolvable(change) && !change.switch; -/** Agents a project can turn a global server off for: those it uses, that the server reaches and that have a switch. */ +/** Agents a project can turn a global server off for: those it uses, that the server reaches and that have a switch. + * Pi takes one when given the global server itself, whose command or url its switch carries. */ export const switchTargets = (server: MCPServer, defaults: string[], projectTargets: readonly string[]) => - (server.targets ?? defaults).filter((x) => mcpOffTargets.includes(x) && projectTargets.includes(x)); + (server.targets ?? defaults).filter((x) => (mcpOffTargets.includes(x) || (x === 'pi' && Boolean(server.command || server.url))) && projectTargets.includes(x)); /** The Agents a server of one scope goes to. A switch that names none follows the scope's, where the Agent has a switch, as sync works it out. */ export const reachOf = (server: MCPServer, defaults: string[]) => @@ -337,7 +338,6 @@ const noticeKeys: Record = { const legacyNoticeKeys: Record = { 'Pi now uses its built-in MCP; the next sync updates the config': 'mcp.notice.piExtension', 'piOptionsPrune is no longer used; the next sync removes it': 'mcp.notice.piOptionsPrune', - 'Pi cannot turn off a server per project; the next sync removes pi from these entries': 'mcp.notice.piSwitch', 'directTools, includeTools and excludeTools become tool settings; the next sync converts them': 'mcp.notice.piTools', 'directTools, includeTools or excludeTools the server already covers, or that are not tool lists, are dropped; the next sync removes them': 'mcp.notice.piToolsDropped', }; diff --git a/ui/src/i18n/locales/de.json b/ui/src/i18n/locales/de.json index e1f8a49f2..b617225dd 100644 --- a/ui/src/i18n/locales/de.json +++ b/ui/src/i18n/locales/de.json @@ -1430,7 +1430,6 @@ "mcp.notice.piExtension": "Pi nutzt jetzt sein integriertes MCP; der nächste Sync aktualisiert die Konfiguration: {names}", "mcp.notice.piOptionsPrune": "piOptionsPrune wird nicht mehr verwendet; der nächste Sync entfernt es: {names}", "mcp.notice.adapterOptions": "Das integrierte MCP von Pi liest {fields} nicht; der nächste Sync entfernt sie: {names}", - "mcp.notice.piSwitch": "Pi kann einen Server nicht in nur einem Projekt ausschalten; der nächste Sync entfernt Pi aus diesen Einträgen: {names}", "mcp.notice.piTools": "directTools, includeTools und excludeTools werden zu Tool-Einstellungen; der nächste Sync wandelt sie um: {names}", "mcp.notice.piToolsDropped": "directTools, includeTools oder excludeTools, die der Server schon abdeckt oder die keine Tool-Listen sind, entfernt der nächste Sync: {names}", "mcp.notice.toolPolicy": "{agent} kann diesen Teil der Tool-Richtlinie nicht anwenden ({parts}): {names}", diff --git a/ui/src/i18n/locales/en.json b/ui/src/i18n/locales/en.json index 6ba8850fb..0c633def3 100644 --- a/ui/src/i18n/locales/en.json +++ b/ui/src/i18n/locales/en.json @@ -1430,7 +1430,6 @@ "mcp.notice.piExtension": "Pi now uses its built-in MCP; the next sync updates the config: {names}", "mcp.notice.piOptionsPrune": "piOptionsPrune is no longer used; the next sync removes it: {names}", "mcp.notice.adapterOptions": "Pi's built-in MCP does not read {fields}; the next sync removes them: {names}", - "mcp.notice.piSwitch": "Pi cannot turn off a server in one project; the next sync removes Pi from these entries: {names}", "mcp.notice.piTools": "directTools, includeTools and excludeTools become tool settings; the next sync converts them: {names}", "mcp.notice.piToolsDropped": "directTools, includeTools or excludeTools that the server already covers, or that are not tool lists, are dropped by the next sync: {names}", "mcp.notice.toolPolicy": "{agent} cannot apply this part of the tool policy ({parts}): {names}", diff --git a/ui/src/i18n/locales/es.json b/ui/src/i18n/locales/es.json index fa6189edc..a71bee503 100644 --- a/ui/src/i18n/locales/es.json +++ b/ui/src/i18n/locales/es.json @@ -1430,7 +1430,6 @@ "mcp.notice.piExtension": "Pi ahora usa su MCP integrado; la próxima sincronización actualiza la configuración: {names}", "mcp.notice.piOptionsPrune": "piOptionsPrune ya no se usa; la próxima sincronización lo quita: {names}", "mcp.notice.adapterOptions": "El MCP integrado de Pi no lee {fields}; la próxima sincronización los quita: {names}", - "mcp.notice.piSwitch": "Pi no puede desactivar un servidor en un solo proyecto; la próxima sincronización quita Pi de estas entradas: {names}", "mcp.notice.piTools": "directTools, includeTools y excludeTools pasan a ser ajustes de herramientas; la próxima sincronización los convierte: {names}", "mcp.notice.piToolsDropped": "La próxima sincronización quita los directTools, includeTools o excludeTools que el servidor ya cubre o que no son listas de herramientas: {names}", "mcp.notice.toolPolicy": "{agent} no puede aplicar esta parte de la política de herramientas ({parts}): {names}", diff --git a/ui/src/i18n/locales/fa.json b/ui/src/i18n/locales/fa.json index 9bf42730c..3a69049f9 100644 --- a/ui/src/i18n/locales/fa.json +++ b/ui/src/i18n/locales/fa.json @@ -1430,7 +1430,6 @@ "mcp.notice.piExtension": "Pi اکنون از MCP داخلی خود استفاده می‌کند؛ همگام‌سازی بعدی پیکربندی را به‌روز می‌کند: {names}", "mcp.notice.piOptionsPrune": "piOptionsPrune دیگر استفاده نمی‌شود؛ همگام‌سازی بعدی آن را حذف می‌کند: {names}", "mcp.notice.adapterOptions": "MCP داخلی Pi این‌ها را نمی‌خواند: {fields}؛ همگام‌سازی بعدی آن‌ها را حذف می‌کند: {names}", - "mcp.notice.piSwitch": "Pi نمی‌تواند یک سرور را فقط در یک پروژه خاموش کند؛ همگام‌سازی بعدی Pi را از این مدخل‌ها حذف می‌کند: {names}", "mcp.notice.piTools": "directTools، includeTools و excludeTools به تنظیمات ابزار تبدیل می‌شوند؛ همگام‌سازی بعدی آن‌ها را تبدیل می‌کند: {names}", "mcp.notice.piToolsDropped": "همگام‌سازی بعدی directTools، includeTools یا excludeTools را که سرور از قبل پوشش می‌دهد یا فهرست ابزار نیستند حذف می‌کند: {names}", "mcp.notice.toolPolicy": "{agent} نمی‌تواند این بخش از سیاست ابزار را اعمال کند ({parts}): {names}", diff --git a/ui/src/i18n/locales/fr.json b/ui/src/i18n/locales/fr.json index 73a128c37..330445dc2 100644 --- a/ui/src/i18n/locales/fr.json +++ b/ui/src/i18n/locales/fr.json @@ -1430,7 +1430,6 @@ "mcp.notice.piExtension": "Pi utilise désormais son MCP intégré ; la prochaine synchronisation met à jour la configuration : {names}", "mcp.notice.piOptionsPrune": "piOptionsPrune n'est plus utilisé ; la prochaine synchronisation le supprime : {names}", "mcp.notice.adapterOptions": "Le MCP intégré de Pi ne lit pas {fields} ; la prochaine synchronisation les supprime : {names}", - "mcp.notice.piSwitch": "Pi ne peut pas désactiver un serveur dans un seul projet ; la prochaine synchronisation retire Pi de ces entrées : {names}", "mcp.notice.piTools": "directTools, includeTools et excludeTools deviennent des réglages d'outils ; la prochaine synchronisation les convertit : {names}", "mcp.notice.piToolsDropped": "La prochaine synchronisation supprime les directTools, includeTools ou excludeTools que le serveur couvre déjà ou qui ne sont pas des listes d'outils : {names}", "mcp.notice.toolPolicy": "{agent} ne peut pas appliquer cette partie de la politique d'outils ({parts}) : {names}", diff --git a/ui/src/i18n/locales/id.json b/ui/src/i18n/locales/id.json index 940c2e03e..4c4db1d5f 100644 --- a/ui/src/i18n/locales/id.json +++ b/ui/src/i18n/locales/id.json @@ -1430,7 +1430,6 @@ "mcp.notice.piExtension": "Pi sekarang memakai MCP bawaannya; sinkronisasi berikutnya memperbarui konfigurasi: {names}", "mcp.notice.piOptionsPrune": "piOptionsPrune tidak dipakai lagi; sinkronisasi berikutnya menghapusnya: {names}", "mcp.notice.adapterOptions": "MCP bawaan Pi tidak membaca {fields}; sinkronisasi berikutnya menghapusnya: {names}", - "mcp.notice.piSwitch": "Pi tidak bisa mematikan server di satu proyek saja; sinkronisasi berikutnya menghapus Pi dari entri ini: {names}", "mcp.notice.piTools": "directTools, includeTools, dan excludeTools menjadi pengaturan alat; sinkronisasi berikutnya mengonversinya: {names}", "mcp.notice.piToolsDropped": "Sinkronisasi berikutnya menghapus directTools, includeTools, atau excludeTools yang sudah dicakup server atau yang bukan daftar alat: {names}", "mcp.notice.toolPolicy": "{agent} tidak bisa menerapkan bagian kebijakan alat ini ({parts}): {names}", diff --git a/ui/src/i18n/locales/ja.json b/ui/src/i18n/locales/ja.json index 1285da8d4..70bca8130 100644 --- a/ui/src/i18n/locales/ja.json +++ b/ui/src/i18n/locales/ja.json @@ -1430,7 +1430,6 @@ "mcp.notice.piExtension": "Pi は内蔵 MCP を使うようになりました。次の sync で config を更新します: {names}", "mcp.notice.piOptionsPrune": "piOptionsPrune は使われなくなりました。次の sync で削除します: {names}", "mcp.notice.adapterOptions": "Pi の内蔵 MCP は {fields} を読みません。次の sync で削除します: {names}", - "mcp.notice.piSwitch": "Pi は 1 つのプロジェクトだけでサーバーをオフにできません。次の sync でこれらのエントリから Pi を外します: {names}", "mcp.notice.piTools": "directTools、includeTools、excludeTools はツール設定に変わります。次の sync で変換します: {names}", "mcp.notice.piToolsDropped": "サーバーがすでに設定済みの、またはツールのリストでない directTools、includeTools、excludeTools は次の sync で削除されます: {names}", "mcp.notice.toolPolicy": "{agent} はツールポリシーのこの部分({parts})を適用できません: {names}", diff --git a/ui/src/i18n/locales/ko.json b/ui/src/i18n/locales/ko.json index 2cb16fae5..156c44460 100644 --- a/ui/src/i18n/locales/ko.json +++ b/ui/src/i18n/locales/ko.json @@ -1430,7 +1430,6 @@ "mcp.notice.piExtension": "Pi는 이제 내장 MCP를 사용합니다. 다음 sync에서 설정을 업데이트합니다: {names}", "mcp.notice.piOptionsPrune": "piOptionsPrune은 더 이상 사용되지 않습니다. 다음 sync에서 제거합니다: {names}", "mcp.notice.adapterOptions": "Pi 내장 MCP는 {fields}을(를) 읽지 않습니다. 다음 sync에서 제거합니다: {names}", - "mcp.notice.piSwitch": "Pi는 한 프로젝트에서만 서버를 끌 수 없습니다. 다음 sync에서 이 항목들에서 Pi를 제거합니다: {names}", "mcp.notice.piTools": "directTools, includeTools, excludeTools는 도구 설정으로 바뀝니다. 다음 sync에서 변환합니다: {names}", "mcp.notice.piToolsDropped": "서버가 이미 설정했거나 도구 목록이 아닌 directTools, includeTools, excludeTools는 다음 sync에서 제거됩니다: {names}", "mcp.notice.toolPolicy": "{agent}은(는) 도구 정책의 이 부분({parts})을 적용할 수 없습니다: {names}", diff --git a/ui/src/i18n/locales/pt-BR.json b/ui/src/i18n/locales/pt-BR.json index 5fe4618a5..b8085b8c8 100644 --- a/ui/src/i18n/locales/pt-BR.json +++ b/ui/src/i18n/locales/pt-BR.json @@ -1430,7 +1430,6 @@ "mcp.notice.piExtension": "O Pi agora usa o MCP integrado; a próxima sincronização atualiza a configuração: {names}", "mcp.notice.piOptionsPrune": "piOptionsPrune não é mais usado; a próxima sincronização o remove: {names}", "mcp.notice.adapterOptions": "O MCP integrado do Pi não lê {fields}; a próxima sincronização os remove: {names}", - "mcp.notice.piSwitch": "O Pi não consegue desligar um servidor em um só projeto; a próxima sincronização remove o Pi destas entradas: {names}", "mcp.notice.piTools": "directTools, includeTools e excludeTools viram configurações de ferramentas; a próxima sincronização os converte: {names}", "mcp.notice.piToolsDropped": "A próxima sincronização remove directTools, includeTools ou excludeTools que o servidor já cobre ou que não são listas de ferramentas: {names}", "mcp.notice.toolPolicy": "{agent} não consegue aplicar esta parte da política de ferramentas ({parts}): {names}", diff --git a/ui/src/i18n/locales/zh-CN.json b/ui/src/i18n/locales/zh-CN.json index 2510592ff..3927b9ca7 100644 --- a/ui/src/i18n/locales/zh-CN.json +++ b/ui/src/i18n/locales/zh-CN.json @@ -1430,7 +1430,6 @@ "mcp.notice.piExtension": "Pi 现在使用内置 MCP,下次同步会更新配置:{names}", "mcp.notice.piOptionsPrune": "piOptionsPrune 已不再使用,下次同步会移除:{names}", "mcp.notice.adapterOptions": "Pi 内置 MCP 不会读取 {fields},下次同步会移除:{names}", - "mcp.notice.piSwitch": "Pi 无法在单个项目中关闭 server,下次同步会从这些条目中移除 Pi:{names}", "mcp.notice.piTools": "directTools、includeTools 和 excludeTools 会转为工具设置,下次同步会转换:{names}", "mcp.notice.piToolsDropped": "server 已涵盖、或不是工具列表的 directTools、includeTools 或 excludeTools,下次同步会移除:{names}", "mcp.notice.toolPolicy": "{agent} 无法应用这部分工具策略({parts}):{names}", diff --git a/ui/src/i18n/locales/zh-TW.json b/ui/src/i18n/locales/zh-TW.json index 8cc531391..1a6ac76a2 100644 --- a/ui/src/i18n/locales/zh-TW.json +++ b/ui/src/i18n/locales/zh-TW.json @@ -1430,7 +1430,6 @@ "mcp.notice.piExtension": "Pi 現在使用內建 MCP,下次同步會更新設定:{names}", "mcp.notice.piOptionsPrune": "piOptionsPrune 已不再使用,下次同步會移除:{names}", "mcp.notice.adapterOptions": "Pi 內建 MCP 不會讀取 {fields},下次同步會移除:{names}", - "mcp.notice.piSwitch": "Pi 無法在單一專案關閉 server,下次同步會從這些項目移除 Pi:{names}", "mcp.notice.piTools": "directTools、includeTools 與 excludeTools 會轉成工具設定,下次同步會轉換:{names}", "mcp.notice.piToolsDropped": "server 已涵蓋、或不是工具清單的 directTools、includeTools 或 excludeTools,下次同步會移除:{names}", "mcp.notice.toolPolicy": "{agent} 無法套用這部分工具政策({parts}):{names}", diff --git a/website/docs/reference/commands/mcp.md b/website/docs/reference/commands/mcp.md index 42df55e00..ce09d7050 100644 --- a/website/docs/reference/commands/mcp.md +++ b/website/docs/reference/commands/mcp.md @@ -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 diff --git a/website/i18n/ja/docusaurus-plugin-content-docs/current/reference/commands/mcp.md b/website/i18n/ja/docusaurus-plugin-content-docs/current/reference/commands/mcp.md index fb9280f11..e819ea50b 100644 --- a/website/i18n/ja/docusaurus-plugin-content-docs/current/reference/commands/mcp.md +++ b/website/i18n/ja/docusaurus-plugin-content-docs/current/reference/commands/mcp.md @@ -274,14 +274,14 @@ Agent は自身の global MCP ファイルと project のファイルを合わ ファイルで定義されたサーバーはすべての project で読み込まれます。1 つの project だけでそれを読み込まれないようにするには、**Agent の global ファイルが使っているのと同じ名前**のエントリを追加し、 `disabled` を指定します。 -これは以下の 3 つのクライアントでのみ機能します。 +これは以下の 4 つのクライアントでのみ機能します。 | クライアント | 対応 | Skillshare が書き込む内容 | |---|---|---| | Claude Code | Yes | `~/.claude.json`: この project の `disabledMcpServers` リストにその名前を追加 | | OpenCode | Yes | `opencode.json`: `"NAME": {"enabled": false}` | | Kilo Code | Yes | `kilo.jsonc`: `"NAME": {"enabled": false}` | -| Pi | No | 完全なエントリが必要:command/url を持つサーバーに `piOptions: {enabled: false}` を設定 | +| Pi | Yes(`mcp.projects` から) | `.pi/mcp.json`: `"NAME": {"command": "...", "enabled": false}`、下記参照 | | Codex | No | 下記参照 | | その他すべてのクライアント | No | 選択するとエラー。何も書き込まれない | @@ -293,6 +293,13 @@ global config がそのサーバーを定義しているマシンでは `enabled 別のメンバーの Codex の起動を止めてしまう可能性があります。代わりに、マシンごとに `~/.codex/config.toml` で `enabled = false` を指定してサーバーをオフにしてください。 +Pi は project の同名エントリで global エントリを丸ごと置き換え、`command` も `url` もないエントリは読み飛ばします。 +そのため Pi には、global サーバーの `command`、またはクエリを除いた `url` を `enabled: false` と一緒に書き込みます。 +オフにしたサーバーは起動しないので、args、env、headers は project ファイルに書き込まれず、他の project では +そのサーバーがそのまま使われます。sync のたびにエントリは global サーバーから書き直されます。global サーバーが +必要なので、これは global config の `mcp.projects` 配下の project でのみ機能します。project 自身の config からは +global サーバーが見えないため、そこで `disabled` エントリに `pi` を指定するとエラーになります。 + ### OpenCode と Kilo Code ```bash @@ -819,9 +826,8 @@ Pi だけの簡単な設定なら、`pi mcp add` でグローバルファイル ユーザーの承認が必要です。 Pi のサーバー名には英数字、`_`、`-` のみを使えます。Pi では project のエントリが同名の global -エントリを丸ごと置き換えるため、スイッチだけの `disabled` エントリは Pi を対象にできません。 -1 つの project で global サーバーをオフにするには、完全なエントリに `piOptions: {enabled: false}` -を設定してください。 +エントリを丸ごと置き換えます。1 つの project で global サーバーをオフにするには、 +[1 つの project だけで global サーバーをオフにする](#turn-off-a-global-server-in-one-project)を参照してください。 ### その他の Pi 設定 {#pi-options} @@ -906,7 +912,6 @@ sync がサーバーをこれらの extension から移すとき、`sync mcp --d | `mcp.directTools`、または `mcp.projects` 配下の project の `directTools` | 既定値が、Pi に届き自身の値を持たない各サーバーに上記のとおり書き込まれる。project の `false` はグローバルの値より優先される | | `piOptions.includeTools` / `excludeTools` | `tools.allow` / `tools.deny`。一緒に設定した `directTools` は引き続き `piOptions.exposure` になる | | `piOptions` 内のその他の `pi-mcp-adapter` フィールド: `approveTools`、`auth`、`bearerToken`、`bearerTokenEnv`、`bearerTokenStore`、`caFile`、`debug`、`exposeResources`、`idleTimeout`、`inheritEnv`、`lifecycle`、`protocolVersion`、`requestHeadersCommand`、`requestTimeoutMs`、`searchKeywords`、`socket`、`tasks`、`toolPrefix`、`trace` | Pi の内蔵 MCP が読まないため削除される | -| `disabled` エントリの `targets` 内の `pi` | そのリストから `pi` が削除される。Pi はスイッチだけのエントリを受け付けないため、そのサーバーはその project で再びオンになる。オフのままにするには、`piOptions: {enabled: false}` を持つ完全なエントリを追加する | サーバーがすでに設定している exposure を上書きしてしまう `directTools`、`includeTools`、`excludeTools`、 またはツール名のリストではないものは、それぞれ独自の warning とともに破棄されます。 diff --git a/website/i18n/ko/docusaurus-plugin-content-docs/current/reference/commands/mcp.md b/website/i18n/ko/docusaurus-plugin-content-docs/current/reference/commands/mcp.md index 80aa758c8..8b21757db 100644 --- a/website/i18n/ko/docusaurus-plugin-content-docs/current/reference/commands/mcp.md +++ b/website/i18n/ko/docusaurus-plugin-content-docs/current/reference/commands/mcp.md @@ -360,14 +360,14 @@ Agent는 자체 global MCP 파일과 프로젝트 파일을 함께 읽습니다. 막으려면, **Agent의 global 파일이 사용하는 것과 동일한 이름**으로 항목을 추가하고 `disabled`로 표시하세요. -이는 다음 세 client에서만 동작합니다. +이는 다음 네 client에서만 동작합니다. | Client | Supported | What Skillshare writes | |---|---|---| | Claude Code | 예 | `~/.claude.json`: 이름을 이 프로젝트의 `disabledMcpServers` 목록에 추가 | | OpenCode | 예 | `opencode.json`: `"NAME": {"enabled": false}` | | Kilo Code | 예 | `kilo.jsonc`: `"NAME": {"enabled": false}` | -| Pi | 아니요 | 완전한 항목 필요: command/url이 있는 서버에 `piOptions: {enabled: false}` 사용 | +| Pi | 예, `mcp.projects`에서 | `.pi/mcp.json`: `"NAME": {"command": "...", "enabled": false}`, 아래 참조 | | Codex | 아니요 | 아래 참고 | | Every other client | 아니요 | 하나를 선택하면 오류가 발생하며 아무것도 작성되지 않음 | @@ -384,6 +384,14 @@ Codex는 다른 이유로 거부됩니다. Codex는 `.codex/config.toml`을 필 Codex 시작을 막을 수 있습니다. 대신 `~/.codex/config.toml`에서 `enabled = false`로 머신별로 서버를 끄세요. +Pi는 같은 이름의 프로젝트 항목으로 global 항목을 통째로 대체하고, `command`나 `url`이 없는 항목은 +건너뜁니다. 그래서 Pi에는 global 서버의 `command`, 또는 query를 뺀 `url`을 `enabled: false`와 함께 +씁니다. 꺼진 서버는 시작되지 않으므로 args, env, headers는 프로젝트 파일에 쓰지 않으며, 다른 +프로젝트는 그 서버를 그대로 사용합니다. sync할 때마다 이 항목은 global 서버를 기준으로 다시 +작성됩니다. global 서버가 필요하므로 global 구성의 `mcp.projects` 아래 프로젝트에서만 동작합니다. +프로젝트 자체 구성에서는 global 서버를 볼 수 없으므로, 그곳의 `disabled` 항목에 `pi`를 쓰면 +오류가 납니다. + ### OpenCode and Kilo Code ```bash @@ -934,9 +942,8 @@ project에는 `-l`을 추가하세요. `pi mcp list`는 활성 서버를 모두 `pi mcp login NAME`은 사용자 승인이 필요합니다. Pi 서버 이름에는 영문자, 숫자, `_`, `-`만 쓸 수 있습니다. Pi에서는 프로젝트 항목이 같은 이름의 -global 항목을 통째로 대체하므로 스위치만 있는 `disabled` 항목은 Pi를 target으로 삼을 수 -없습니다. 한 프로젝트에서 global 서버를 끄려면 완전한 항목에 `piOptions: {enabled: false}`를 -사용하세요. +global 항목을 통째로 대체합니다. 한 프로젝트에서 global 서버를 끄려면 +[Turn off a global server in one project](#turn-off-a-global-server-in-one-project)를 참고하세요. ### 기타 Pi 설정 {#pi-options} @@ -1025,7 +1032,6 @@ config도 그대로 로드됩니다. `sync mcp --dry-run`과 `sync mcp`는 발 | `mcp.directTools`, 또는 `mcp.projects` 아래 프로젝트의 `directTools` | Pi에 전달되고 자체 값이 없는 각 서버에 기본값이 위와 같이 작성됩니다. 프로젝트의 `false`는 global 값을 재정의합니다 | | `piOptions.includeTools` / `excludeTools` | `tools.allow` / `tools.deny`가 되며, 함께 설정한 `directTools`는 여전히 `piOptions.exposure`가 됩니다 | | `piOptions`의 그 밖의 `pi-mcp-adapter` 필드: `approveTools`, `auth`, `bearerToken`, `bearerTokenEnv`, `bearerTokenStore`, `caFile`, `debug`, `exposeResources`, `idleTimeout`, `inheritEnv`, `lifecycle`, `protocolVersion`, `requestHeadersCommand`, `requestTimeoutMs`, `searchKeywords`, `socket`, `tasks`, `toolPrefix`, `trace` | Pi 내장 MCP가 읽지 않으므로 제거됩니다 | -| `disabled` 항목의 `targets`에 있는 `pi` | 그 목록에서 `pi`가 제거됩니다. Pi는 스위치만 있는 항목을 받지 않으므로, 그 서버는 해당 프로젝트에서 다시 켜집니다. 계속 끄려면 `piOptions: {enabled: false}`가 있는 완전한 항목을 추가하세요 | 서버가 이미 설정한 exposure를 덮어쓰게 되거나 도구 이름 목록이 아닌 `directTools`, `includeTools`, `excludeTools`는 별도의 warning과 함께 버려집니다. diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/commands/mcp.md b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/commands/mcp.md index 52d4d9e73..8ae61bd25 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/commands/mcp.md +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/commands/mcp.md @@ -362,14 +362,14 @@ mcp: 某个项目中加载,请添加一个**名称与该 Agent 的 global 文件所用名称相同**的条目, 并将其标记为 `disabled`。 -这个方法仅适用于三个 client: +这个方法仅适用于四个 client: | Client | 是否支持 | Skillshare 写入的内容 | |---|---|---| | Claude Code | 是 | `~/.claude.json`:在此项目的 `disabledMcpServers` 列表中写入名称 | | OpenCode | 是 | `opencode.json`:`"NAME": {"enabled": false}` | | Kilo Code | 是 | `kilo.jsonc`:`"NAME": {"enabled": false}` | -| Pi | 否 | 需要完整条目:在有 command/url 的 server 上使用 `piOptions: {enabled: false}` | +| Pi | 是,从 `mcp.projects` | `.pi/mcp.json`: `"NAME": {"command": "...", "enabled": false}`,见下文 | | Codex | 否 | 见下文 | | 其他所有 client | 否 | 选择其中任何一个都会报错;不会写入任何内容 | @@ -386,6 +386,13 @@ Codex 因不同的原因被拒绝。它确实会将 `.codex/config.toml` 逐字 可能会导致另一位队友的 Codex 无法启动。请改为在每台机器上单独 关闭该 server,在 `~/.codex/config.toml` 中设置 `enabled = false`。 +Pi 会用项目中的同名条目整条替换 global 条目,并跳过没有 `command` 或 `url` 的条目。 +因此对 Pi,Skillshare 会写入 global server 的 `command`,或去掉 query 的 `url`,再加上 +`enabled: false`。被关闭的 server 不会启动,所以 args、env 和 headers 都不会写进项目文件, +其他项目也照常使用该 server。每次同步都会根据 global server 重写这个条目。这需要 global +server,所以只适用于 global 配置中 `mcp.projects` 下的项目;项目自己的配置看不到 global +server,在那里的 `disabled` 条目中使用 `pi` 会报错。 + ### OpenCode 和 Kilo Code ```bash @@ -911,8 +918,8 @@ mcp: `pi mcp list` 会启动每个已启用的 server 来检查连接;`pi mcp login NAME` 需要用户批准。 Pi 的 server 名称只允许字母、数字、`_` 和 `-`。Pi 的项目条目会整条替换 global -中的同名条目,因此 Pi 不接受只有开关的 `disabled` 条目。要在单个项目中关闭 -global server,请改为在完整条目上使用 `piOptions: {enabled: false}`。 +中的同名条目;要在单个项目中关闭 global server,请参阅 +[在单个项目中关闭一个 global server](#turn-off-a-global-server-in-one-project)。 ### 其他 Pi 设置 {#pi-options} @@ -996,7 +1003,6 @@ pi-mcp-adapter` 或 `pi-mcp-extension`、`directTools`,以及下方列出的 ` | `mcp.directTools`,或 `mcp.projects` 下某个项目的 `directTools` | 该默认值会写入每个送往 Pi 且没有自身值的 server,转换方式同上。项目的 `false` 会覆盖 global 值 | | `piOptions.includeTools` / `excludeTools` | `tools.allow` / `tools.deny`;同时设置的 `directTools` 仍会转为 `piOptions.exposure` | | `piOptions` 中其他 `pi-mcp-adapter` 字段:`approveTools`、`auth`、`bearerToken`、`bearerTokenEnv`、`bearerTokenStore`、`caFile`、`debug`、`exposeResources`、`idleTimeout`、`inheritEnv`、`lifecycle`、`protocolVersion`、`requestHeadersCommand`、`requestTimeoutMs`、`searchKeywords`、`socket`、`tasks`、`toolPrefix`、`trace` | 移除,因为 Pi 的内置 MCP 不会读取它们 | -| `disabled` 条目 `targets` 中的 `pi` | 从该列表中移除 `pi`。Pi 不接受只有开关的条目,因此该 server 在那个 project 中会重新启用;要保持关闭,请添加带有 `piOptions: {enabled: false}` 的完整条目 | 如果 `directTools`、`includeTools` 或 `excludeTools` 会覆盖该 server 已设置的 exposure,或者不是工具名称列表,就会被丢弃,并给出单独的 warning。 diff --git a/website/i18n/zh-Hant/docusaurus-plugin-content-docs/current/reference/commands/mcp.md b/website/i18n/zh-Hant/docusaurus-plugin-content-docs/current/reference/commands/mcp.md index 41e16cd35..e27b97e17 100644 --- a/website/i18n/zh-Hant/docusaurus-plugin-content-docs/current/reference/commands/mcp.md +++ b/website/i18n/zh-Hant/docusaurus-plugin-content-docs/current/reference/commands/mcp.md @@ -328,14 +328,14 @@ global 檔案中的 server 會在每個 project 中載入。若要讓它在某 project 中不要載入,請新增一個**使用該 Agent 的 global 檔案中相同名稱**的項目, 並標記為 `disabled`。 -這只適用於三種 clients: +這只適用於四種 clients: | Client | 是否支援 | Skillshare 會寫入什麼 | |---|---|---| | Claude Code | 是 | `~/.claude.json`:名稱會加入這個 project 的 `disabledMcpServers` 清單 | | OpenCode | 是 | `opencode.json`:`"NAME": {"enabled": false}` | | Kilo Code | 是 | `kilo.jsonc`:`"NAME": {"enabled": false}` | -| Pi | 否 | 需要完整 entry:在有 command/url 的 server 上使用 `piOptions: {enabled: false}` | +| Pi | 是,從 `mcp.projects` | `.pi/mcp.json`: `"NAME": {"command": "...", "enabled": false}`,見下方 | | Codex | 否 | 見下方說明 | | 其他所有 client | 否 | 選擇它會是錯誤;不會寫入任何內容 | @@ -352,6 +352,13 @@ global 檔案之上,所以在 global config 有定義該 server 的機器上 可能導致另一個隊友的 Codex 無法啟動。請改為逐機器關閉該 server, 在 `~/.codex/config.toml` 中設定 `enabled = false`。 +Pi 會用 project 中的同名項目整筆取代 global 項目,並略過沒有 `command` 或 `url` 的項目。 +因此對 Pi,Skillshare 會寫入 global server 的 `command`,或去掉 query 的 `url`,再加上 +`enabled: false`。被關閉的 server 不會啟動,所以 args、env 和 headers 都不會寫進 project +檔案,其他 project 也照常使用該 server。每次同步都會依 global server 重寫這個項目。這需要 +global server,所以只適用於 global config 中 `mcp.projects` 底下的 project;project 自己的 +config 看不到 global server,在那裡的 `disabled` 項目中使用 `pi` 會報錯。 + ### OpenCode and Kilo Code ```bash @@ -873,8 +880,8 @@ mcp: server 檢查連線;`pi mcp login NAME` 需要使用者授權。 Pi 的 server 名稱只接受字母、數字、`_` 和 `-`。Pi 的 project 項目會整筆取代 global -中的同名項目,因此 Pi 無法接受只有開關的 `disabled` 項目。要在單一 project 中關閉 -global server,請改在完整的項目上使用 `piOptions: {enabled: false}`。 +中的同名項目;要在單一 project 中關閉 global server,請見 +[Turn off a global server in one project](#turn-off-a-global-server-in-one-project)。 ### 其他 Pi 設定 {#pi-options} @@ -958,7 +965,6 @@ servers,例如: | `mcp.directTools`,或 `mcp.projects` 下某個 project 的 `directTools` | 預設值會依上述方式,寫入每個送往 Pi 且沒有自己值的 server。project 的 `false` 會覆寫 global 的值 | | `piOptions.includeTools` / `excludeTools` | `tools.allow` / `tools.deny`;同時設定的 `directTools` 仍會轉為 `piOptions.exposure` | | `piOptions` 中其他 `pi-mcp-adapter` 欄位:`approveTools`、`auth`、`bearerToken`、`bearerTokenEnv`、`bearerTokenStore`、`caFile`、`debug`、`exposeResources`、`idleTimeout`、`inheritEnv`、`lifecycle`、`protocolVersion`、`requestHeadersCommand`、`requestTimeoutMs`、`searchKeywords`、`socket`、`tasks`、`toolPrefix`、`trace` | 移除,因為 Pi 內建 MCP 不會讀取它們 | -| `disabled` 項目 `targets` 中的 `pi` | 從該清單中移除 `pi`。Pi 無法接受只有開關的項目,所以該 server 在那個 project 會重新啟用;要繼續關閉,請加上帶有 `piOptions: {enabled: false}` 的完整項目 | 若 `directTools`、`includeTools` 或 `excludeTools` 會覆寫 server 已設定的曝光模式,或不是 工具名稱清單,就會被捨棄,並顯示各自的 warning。