Skip to content

Commit 1169b81

Browse files
ARHAEEMclaude
andcommitted
fix(test): sandbox tool-config tests away from the live ~/.airtable-user-mcp
switchProfile()/toggleTool()/toggleCategory() all save() to tools-config.json; the main ToolConfigManager suite ran unsandboxed, so every run rewrote the user's LIVE config — a Windows EPERM rename race when the real daemon holds the file, and it could flip the real active profile mid-run. A file-level AIRTABLE_USER_MCP_HOME tmp-dir hook now covers the whole file (paths resolve lazily, so the env override takes effect at call time). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 61c8df8 commit 1169b81

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

packages/mcp-server/test/test-tool-config.test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,22 @@ import {
1414
BUILTIN_PROFILES,
1515
} from '../src/tool-config.js';
1616

17+
// Sandbox the WHOLE file: switchProfile()/toggleTool()/toggleCategory() all
18+
// call save(), which writes tools-config.json. Without this, tests write the
19+
// LIVE ~/.airtable-user-mcp/tools-config.json — a Windows EPERM rename race
20+
// when the real daemon holds the file, and they flip the user's real profile.
21+
const FILE_HOME = join(tmpdir(), `tool-config-test-${process.pid}-${Date.now()}`);
22+
const PREV_FILE_HOME = process.env.AIRTABLE_USER_MCP_HOME;
23+
before(async () => {
24+
await mkdir(FILE_HOME, { recursive: true });
25+
process.env.AIRTABLE_USER_MCP_HOME = FILE_HOME;
26+
});
27+
after(async () => {
28+
if (PREV_FILE_HOME === undefined) delete process.env.AIRTABLE_USER_MCP_HOME;
29+
else process.env.AIRTABLE_USER_MCP_HOME = PREV_FILE_HOME;
30+
await rm(FILE_HOME, { recursive: true, force: true });
31+
});
32+
1733
describe('TOOL_CATEGORIES', () => {
1834
it('maps all tools to valid categories', () => {
1935
const tools = Object.keys(TOOL_CATEGORIES);

0 commit comments

Comments
 (0)