diff --git a/.story_kit/work/1_upcoming/270_bug_qa_test_server_overwrites_root_mcp_json_with_wrong_port.md b/.story_kit/work/1_upcoming/270_bug_qa_test_server_overwrites_root_mcp_json_with_wrong_port.md new file mode 100644 index 0000000..d212000 --- /dev/null +++ b/.story_kit/work/1_upcoming/270_bug_qa_test_server_overwrites_root_mcp_json_with_wrong_port.md @@ -0,0 +1,27 @@ +--- +name: "QA test server overwrites root .mcp.json with wrong port" +--- + +# Bug 270: QA test server overwrites root .mcp.json with wrong port + +## Description + +When the QA agent starts a test server in a worktree (e.g. on port 3012), that server auto-detects the shared project root and calls open_project, which writes .mcp.json with the test server's port. This clobbers the root .mcp.json that should always point to the main server (port 3001). Root cause: open_project in server/src/io/fs.rs:527 unconditionally calls write_mcp_json(&p, port) with its own port, regardless of whether another server instance already owns the project. + +## How to Reproduce + +1. QA agent starts on a story\n2. QA agent starts a test server in the worktree on a non-default port (e.g. 3012)\n3. Test server auto-opens the project root\n4. Root .mcp.json is overwritten with test port + +## Actual Result + +Root .mcp.json contains the QA test server's port (e.g. 3012) instead of the main server's port (3001). Interactive Claude sessions lose MCP connectivity. + +## Expected Result + +Root .mcp.json always points to the primary server's port. Test servers started by QA agents should not overwrite it. + +## Acceptance Criteria + +- [ ] QA test servers do not overwrite root .mcp.json +- [ ] Root .mcp.json always reflects the primary server's port +- [ ] Worktree .mcp.json files are only written during worktree creation