Skip to content

Commit d52f6ab

Browse files
authored
[MCP] Always include core MCP tools + return instructions from firebase_init (#9045)
1 parent 2d66eb7 commit d52f6ab

File tree

14 files changed

+61
-35
lines changed

14 files changed

+61
-35
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Add core MCP tools like `firebase_init` and `firebase_get_environment` `firebase_consult_assistant` MCP back. (#9045)

src/commands/init.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { Options } from "../options";
1515
import { isEnabled } from "../experiments";
1616
import { readTemplateSync } from "../templates";
1717
import { FirebaseError } from "../error";
18+
import { logBullet } from "../utils";
1819

1920
const homeDir = os.homedir();
2021

@@ -197,6 +198,7 @@ export async function initAction(feature: string, options: Options): Promise<voi
197198
json: true,
198199
fallback: {},
199200
}),
201+
instructions: [],
200202
};
201203

202204
// HACK: Windows Node has issues with selectables as the first prompt, so we
@@ -265,7 +267,13 @@ export async function initAction(feature: string, options: Options): Promise<voi
265267
if (!fsutils.fileExistsSync(config.path(".gitignore"))) {
266268
config.writeProjectFile(".gitignore", GITIGNORE_TEMPLATE);
267269
}
268-
269270
logger.info();
270271
utils.logSuccess("Firebase initialization complete!");
272+
273+
if (setup.instructions.length) {
274+
logger.info(`\n${clc.bold("To get started:")}\n`);
275+
for (const i of setup.instructions) {
276+
logBullet(i + "\n");
277+
}
278+
}
271279
}

src/init/features/dataconnect/index.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ describe("init dataconnect", () => {
183183
rcfile: MOCK_RC,
184184
config: c.config.src,
185185
featureInfo: { dataconnect: c.requiredInfo, dataconnectSdk: { apps: [] } },
186+
instructions: [],
186187
},
187188
c.config,
188189
{},

src/init/features/dataconnect/index.ts

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,20 @@ export async function actuate(setup: Setup, config: Config, options: any): Promi
158158
flow: info.analyticsFlow,
159159
});
160160
}
161+
162+
if (info.appDescription) {
163+
setup.instructions.push(
164+
`You can visualize the Data Connect Schema in Firebase Console:
165+
166+
https://console.firebase.google.com/project/${setup.projectId!}/dataconnect/locations/${info.locationId}/services/${info.serviceId}/schema`,
167+
);
168+
}
169+
if (!setup.isBillingEnabled) {
170+
setup.instructions.push(upgradeInstructions(setup.projectId || "your-firebase-project"));
171+
}
172+
setup.instructions.push(
173+
`Install the Data Connect VS Code Extensions. You can explore Data Connect Query on local pgLite and Cloud SQL Postgres Instance.`,
174+
);
161175
}
162176

163177
async function actuateWithInfo(
@@ -342,36 +356,6 @@ function schemasDeploySequence(
342356
];
343357
}
344358

345-
export async function postSetup(setup: Setup): Promise<void> {
346-
const info = setup.featureInfo?.dataconnect;
347-
if (!info) {
348-
throw new Error("Data Connect feature RequiredInfo is not provided");
349-
}
350-
351-
const instructions: string[] = [];
352-
if (info.appDescription) {
353-
instructions.push(
354-
`You can visualize the Data Connect Schema in Firebase Console:
355-
356-
https://console.firebase.google.com/project/${setup.projectId!}/dataconnect/locations/${info.locationId}/services/${info.serviceId}/schema`,
357-
);
358-
}
359-
360-
if (!setup.isBillingEnabled) {
361-
instructions.push(upgradeInstructions(setup.projectId || "your-firebase-project"));
362-
}
363-
instructions.push(
364-
`Install the Data Connect VS Code Extensions. You can explore Data Connect Query on local pgLite and Cloud SQL Postgres Instance.`,
365-
);
366-
367-
if (instructions.length) {
368-
logger.info(`\n${clc.bold("To get started with Firebase Data Connect:")}`);
369-
for (const i of instructions) {
370-
logBullet(i + "\n");
371-
}
372-
}
373-
}
374-
375359
async function writeFiles(
376360
config: Config,
377361
info: RequiredInfo,

src/init/features/firestore/index.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ describe("firestore feature init", () => {
2626
config: {},
2727
rcfile: { projects: {}, targets: {}, etags: {} },
2828
projectId: "test-project",
29+
instructions: [],
2930
};
3031
const cfg = new config.Config({}, { projectDir: "/", cwd: "/" });
3132
sandbox.stub(ensureApiEnabled, "ensure").resolves();
@@ -68,6 +69,7 @@ describe("firestore feature init", () => {
6869
locationId: "us-central",
6970
},
7071
},
72+
instructions: [],
7173
};
7274
const cfg = new config.Config({}, { projectDir: "/", cwd: "/" });
7375
const writeStub = sandbox.stub(cfg, "writeProjectFile");

src/init/features/firestore/indexes.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ describe("firestore indexes", () => {
2222
const setup: Setup = {
2323
config: {},
2424
rcfile: { projects: {}, targets: {}, etags: {} },
25+
instructions: [],
2526
};
2627
const cfg = new config.Config({}, { projectDir: "/", cwd: "/" });
2728
const inputStub = sandbox.stub(prompt, "input").resolves("firestore.indexes.json");
@@ -47,6 +48,7 @@ describe("firestore indexes", () => {
4748
config: {},
4849
rcfile: { projects: {}, targets: {}, etags: {} },
4950
projectId: "test-project",
51+
instructions: [],
5052
};
5153
const cfg = new config.Config({}, { projectDir: "/", cwd: "/" });
5254
const listIndexesStub = sandbox.stub(FirestoreApi.prototype, "listIndexes").resolves([]);

src/init/features/firestore/rules.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ describe("firestore rules", () => {
3434
const setup: Setup = {
3535
config: {},
3636
rcfile: { projects: {}, targets: {}, etags: {} },
37+
instructions: [],
3738
};
3839
const cfg = new config.Config({}, { projectDir: "/", cwd: "/" });
3940
sandbox.stub(prompt, "input").resolves("firestore.rules");
@@ -59,6 +60,7 @@ describe("firestore rules", () => {
5960
config: {},
6061
rcfile: { projects: {}, targets: {}, etags: {} },
6162
projectId: "test-project",
63+
instructions: [],
6264
};
6365
const cfg = new config.Config({}, { projectDir: "/", cwd: "/" });
6466
const getRulesetNameStub = sandbox

src/init/features/functions.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ function createExistingTestSetupAndConfig(): { setup: Setup; config: Config } {
2626
},
2727
rcfile: { projects: {}, targets: {}, etags: {} },
2828
featureArg: true,
29+
instructions: [],
2930
},
3031
config: new Config({ functions: [cbconfig] }, { projectDir: "test", cwd: "test" }),
3132
};

src/init/features/genkit/index.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ describe("genkit", () => {
7373
const setup: genkit.GenkitSetup = {
7474
config: {},
7575
rcfile: { projects: {}, targets: {}, etags: {} },
76+
instructions: [],
7677
};
7778
spawnStub.spawnWithOutput.resolves("1.0.0");
7879
promptStub.confirm.resolves(true);
@@ -120,6 +121,7 @@ describe("genkit", () => {
120121
const setup: genkit.GenkitSetup = {
121122
config: {},
122123
rcfile: { projects: {}, targets: {}, etags: {} },
124+
instructions: [],
123125
};
124126
spawnStub.spawnWithOutput.resolves("1.0.0");
125127
promptStub.confirm.resolves(true);
@@ -138,6 +140,7 @@ describe("genkit", () => {
138140
const setup: genkit.GenkitSetup = {
139141
config: {},
140142
rcfile: { projects: {}, targets: {}, etags: {} },
143+
instructions: [],
141144
};
142145
spawnStub.spawnWithOutput.resolves("1.0.0");
143146
promptStub.confirm.resolves(true);
@@ -163,6 +166,7 @@ describe("genkit", () => {
163166
const setup: genkit.GenkitSetup = {
164167
config: {},
165168
rcfile: { projects: {}, targets: {}, etags: {} },
169+
instructions: [],
166170
};
167171
spawnStub.spawnWithOutput.resolves("1.0.0");
168172
promptStub.confirm.onFirstCall().resolves(true).onSecondCall().resolves(false);
@@ -179,6 +183,7 @@ describe("genkit", () => {
179183
const setup: genkit.GenkitSetup = {
180184
config: {},
181185
rcfile: { projects: {}, targets: {}, etags: {} },
186+
instructions: [],
182187
};
183188
spawnStub.spawnWithOutput.resolves("1.0.0");
184189
promptStub.confirm.onFirstCall().resolves(true).onSecondCall().resolves(false);
@@ -203,6 +208,7 @@ describe("genkit", () => {
203208
const setup: genkit.GenkitSetup = {
204209
config: {},
205210
rcfile: { projects: {}, targets: {}, etags: {} },
211+
instructions: [],
206212
};
207213
spawnStub.spawnWithOutput.resolves("1.0.0");
208214
promptStub.confirm.resolves(false);

src/init/features/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ export {
2626
askQuestions as dataconnectAskQuestions,
2727
RequiredInfo as DataconnectInfo,
2828
actuate as dataconnectActuate,
29-
postSetup as dataconnectPostSetup,
3029
} from "./dataconnect";
3130
export {
3231
askQuestions as dataconnectSdkAskQuestions,

0 commit comments

Comments
 (0)