fix(setup): preserve configured MCP server environment (#1607)

* fix(setup): preserve configured MCP server environment

* fix(setup): validate retained server environment before writes
This commit is contained in:
Feng
2026-10-11 06:23:02 +08:00
committed by GitHub
parent 3e931a7e35
commit 52331ab637
8 changed files with 479 additions and 32 deletions
@@ -248,7 +248,7 @@ describe("Grok Build server table edits", () => {
expect(configured).toContain("share = false");
expect(configured).toContain("[mcp_servers.rea]");
expect(configured).toContain("startup_timeout_sec = 30");
expect(configured).not.toContain('OLD = "1"');
expect(configured).toContain('OLD = "1"');
expect(configured).not.toContain('command = "old"');
expect(parseToml(configured)).toMatchObject({
mcp_servers: {
@@ -258,6 +258,7 @@ describe("Grok Build server table edits", () => {
args: ["mcp"],
startup_timeout_sec: 30,
env: {
OLD: "1",
JAVA_HOME: "/opt/jdk-21",
HOPPER_LAUNCHER_PATH: "/Hopper Path",
GHIDRA_INSTALL_DIR: "/opt/ghidra",
@@ -507,7 +508,7 @@ describe("Grok Build text that resembles a server table", () => {
const configured = await readFile(configPath, "utf8");
expect(configured).not.toContain("mcp_servers . rea");
expect(configured).not.toContain("\\u0072ea");
expect(configured).not.toContain('OLD = "1"');
expect(configured).toContain('OLD = "1"');
expect(
configured
.split("\n")
@@ -515,7 +516,12 @@ describe("Grok Build text that resembles a server table", () => {
).toHaveLength(1);
expect(parseToml(configured)).toMatchObject({
mcp_servers: {
rea: { command: "rea", args: ["mcp"], startup_timeout_sec: 30 },
rea: {
command: "rea",
args: ["mcp"],
startup_timeout_sec: 30,
env: { OLD: "1" },
},
},
});
});