Files
magpie/docs
yetone 2c1b593675 library: Zed takes MCP servers, in its settings.json context_servers (lc on Discord)
lc on Discord ("agent未识别到zed"): the MCP server editor's agent chips
had no Zed. magpie already edits Zed's settings.json for its model, and
Zed reads its MCP servers from context_servers in that same file, so Zed
is now an MCP target like the other agents.

What Zed takes, from its own source (zed-industries/zed 2c99f547):
- crates/settings_content/src/project.rs ContextServerSettingsContent is
  untagged: a command as command/args/env (enabled, remote, timeout
  beside it), a url as url/headers (enabled, timeout, oauth), or an
  extension's entry as settings. docs/src/ai/mcp.md writes the same.
- crates/context_server/src/transport/http.rs only POSTs (and DELETEs):
  streamable HTTP, no SSE. So an SSE server is refused for Zed and its
  chip is greyed with the existing reason (AgentView.NoSSE).
- stdio_transport.rs hands command.envs over as written and http.rs sends
  headers as written: no ${NAME}. Zed is refNone, so a server naming a
  variable is refused and its chip greyed (AgentView.NoEnvRefs).

Changes:
- targets.go: "zed" gets mcpFile{agent.zed's settings.json, fmtZed}; the
  path is agent.zed's for every OS (~/.config/zed, $XDG_CONFIG_HOME/zed,
  %APPDATA%\Zed, $MAGPIE_ZED_CONFIG_DIR).
- mcp.go: fmtZed under "context_servers", encoded as Cursor/Desktop are;
  magpie owns url/headers/command/args/env only, so enabled, remote,
  timeout and oauth the user sets on magpie's entry stay. The file is
  JSONC and edited in place (edit.SetJSON/DelJSON), so comments, other
  settings and the user's own servers are kept.
- mcp.go, sync.go: an entry Zed's extensions configure (settings, no
  command or url) is never written over: a library server by that name
  is a Problem for Zed (errZedExtension), asking for another name.
- envref.go: a comment citing why Zed has no syntax.
- docs/subsystems/library.md: Zed's file, format, no SSE, no ${NAME},
  the extension guard, and the new tests.

Tests:
- internal/library/zed_mcp_test.go TestZedMCP, on a Zed-style JSONC
  settings.json with comments, trailing commas, a user stdio server
  (enabled:false, timeout), a user remote server and an extension's
  entry, at the default path and under MAGPIE_ZED_CONFIG_DIR: found
  servers, the page's chips, written entries, SSE/${NAME}/extension
  refusals, user keys kept through an edit, uncheck and remove leaving
  only the user's, comments kept, a Sync rewriting nothing.
- internal/gui/tests/library-zed-mcp.test.cjs: Zed's chip on every row
  and in the editor, a click gives it the server, greyed with the reason
  for SSE and ${NAME}; Chromium and WebKit, en/zh/zh-TW/ja/de, 1100 and
  560px, no sideways scroll. No new strings.

Broken by hand, each went red and was restored: no zed target, no
extension guard, SSE allowed, enabled owned by magpie, wrong key (Go);
Zed without noSSE (GUI).

Run (temp HOME, Go caches pinned): gofmt -l internal/ (clean); go vet
-tags nogui ./... on darwin, GOOS=linux and GOOS=windows; go vet
./internal/library ./internal/agent; go build ./..., GOOS=linux go build
-tags nogui ./..., GOOS=windows go build ./...; go test -tags nogui ./...
(all ok); node --test library-zed-mcp.test.cjs (22/22, both engines).

Not verified: a real Zed reading the written file (the live
~/.config/zed was never touched); Linux and Windows beyond vet/build;
Zed found in WSL (not in ownFolder, so no MCP target there); a
project's .zed/settings.json (not added).
2026-10-10 00:37:32 +08:00
..