Fix: prevent mcp operations losing var placeholders (#7144)

This commit is contained in:
shamoon
2026-09-16 07:08:20 -07:00
committed by GitHub
parent c764d05a0c
commit 3598869ef0
2 changed files with 56 additions and 8 deletions
+36
View File
@@ -184,6 +184,42 @@ describe("utils/mcp/homepage-mcp", () => {
);
});
it("preserves env placeholders when adding a service", async () => {
process.env.HOMEPAGE_MCP_ALLOW_WRITE = "true";
const configDir = mkdtempSync(path.join(tmpdir(), "homepage-mcp-test-"));
writeFileSync(
path.join(configDir, "services.yaml"),
"- Media:\n" +
" - Jellyfin:\n" +
" href: http://{{HOMEPAGE_VAR_HOST}}:8096\n" +
" widget:\n" +
" type: jellyfin\n" +
" key: {{HOMEPAGE_VAR_JELLYFIN_KEY}}\n" +
' password: "{{HOMEPAGE_FILE_PASSWORD}}"\n',
);
const mod = await loadMcpWithConfigDir(configDir);
const response = mod.handleMcpRequest({
jsonrpc: "2.0",
id: 11,
method: "tools/call",
params: { name: "add_service", arguments: { group: "Tools", name: "Grafana" } },
});
expect(response.result.isError).toBeUndefined();
expect(readFileSync(path.join(configDir, "services.yaml"), "utf8")).toBe(
"- Media:\n" +
" - Jellyfin:\n" +
" href: http://{{HOMEPAGE_VAR_HOST}}:8096\n" +
" widget:\n" +
" type: jellyfin\n" +
" key: {{HOMEPAGE_VAR_JELLYFIN_KEY}}\n" +
' password: "{{HOMEPAGE_FILE_PASSWORD}}"\n' +
"- Tools:\n" +
" - Grafana: {}\n",
);
});
it("does not add a duplicate service in the same group", async () => {
process.env.HOMEPAGE_MCP_ALLOW_WRITE = "true";
const configDir = mkdtempSync(path.join(tmpdir(), "homepage-mcp-test-"));