Skip to content

Commit 2de7073

Browse files
Delete mcp.json if it exists since this will only be confusing. (#10107)
* Delte mcp.json if it exists since this will only be confusing to the user. * Test
1 parent 7f133d1 commit 2de7073

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

src/firebase_studio/migrate.spec.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ describe("migrate", () => {
5656
let commandStub: sinon.SinonStub;
5757
let trackStub: sinon.SinonStub;
5858
let confirmStub: sinon.SinonStub;
59+
let unlinkStub: sinon.SinonStub;
5960
let spawnStub: sinon.SinonStub;
6061

6162
beforeEach(() => {
@@ -103,7 +104,7 @@ describe("migrate", () => {
103104

104105
writeFileStub = sandbox.stub(fs, "writeFile").resolves();
105106
mkdirStub = sandbox.stub(fs, "mkdir").resolves();
106-
sandbox.stub(fs, "unlink").resolves();
107+
unlinkStub = sandbox.stub(fs, "unlink").resolves();
107108
sandbox.stub(fs, "readdir").resolves([]);
108109
accessStub = sandbox.stub(fs, "access").rejects({ code: "ENOENT" });
109110

@@ -503,6 +504,11 @@ describe("migrate", () => {
503504
expect(confirmStub.called).to.be.true;
504505
});
505506

507+
it("should delete .idx/mcp.json if it exists", async () => {
508+
await migrate(testRoot);
509+
expect(unlinkStub.calledWith(path.join(testRoot, ".idx", "mcp.json"))).to.be.true;
510+
});
511+
506512
it("should configure Dart MCP server for Flutter apps if dart is available", async () => {
507513
accessStub.withArgs(sinon.match("pubspec.yaml")).resolves();
508514
commandStub.withArgs("dart").returns(true);

src/firebase_studio/migrate.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,15 @@ async function cleanupUnusedFiles(rootPath: string): Promise<void> {
587587
const message = err instanceof Error ? err.message : String(err);
588588
logger.debug(`Could not delete ${modifiedPath}: ${message}`);
589589
}
590+
591+
const mcpJsonPath = path.join(rootPath, ".idx", "mcp.json");
592+
try {
593+
await fs.unlink(mcpJsonPath);
594+
logger.info("✅ Cleaned up .idx/mcp.json");
595+
} catch (err: unknown) {
596+
const message = err instanceof Error ? err.message : String(err);
597+
logger.debug(`Could not delete ${mcpJsonPath}: ${message}`);
598+
}
590599
}
591600

592601
/**

0 commit comments

Comments
 (0)