Skip to content

Commit f03c104

Browse files
committed
impl
1 parent bff6986 commit f03c104

File tree

2 files changed

+44
-13
lines changed

2 files changed

+44
-13
lines changed

src/mcp/tools/core/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ import { get_project } from "./get_project.js";
55
import { use_project } from "./use_project.js";
66
import { get_sdk_config } from "./get_sdk_config.js";
77
import { list_apps } from "./list_apps.js";
8+
import { init } from "./init.js";
89

910
export const coreTools: ServerTool[] = [
1011
get_project,
1112
use_project,
1213
list_apps,
1314
get_sdk_config,
1415
consult_assistant,
16+
init,
1517
];

src/mcp/tools/core/init.ts

+42-13
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { z } from "zod";
22
import { tool } from "../../tool.js";
33
import { toContent } from "../../util.js";
4-
import { actuate, Setup } from "../../../init/index.js";
4+
import { actuate, Setup, SetupInfo } from "../../../init/index.js";
55

66
export const init = tool(
77
{
@@ -11,8 +11,24 @@ export const init = tool(
1111
features: z.object({
1212
// TODO: Add all the features here.
1313
dataconnect: z.object({
14-
serviceId: z.string().optional().describe("The Firebase Data Connect service ID to setup."),
15-
locationId: z.string().default("us-central1").describe("The GCP region ID to set up the Firebase Data Connect service. For example, us-central1."),
14+
serviceId: z
15+
.string()
16+
.optional()
17+
.describe(
18+
"Configure the Firebase Data Connect service ID to setup. Default to match the current folder name.",
19+
),
20+
locationId: z
21+
.string()
22+
.default("us-central1")
23+
.describe("The GCP region ID to set up the Firebase Data Connect service."),
24+
cloudSqlInstanceId: z
25+
.string()
26+
.optional()
27+
.describe("The GCP Cloud SQL instance ID to use in the Firebase Data Connect service."),
28+
cloudSqlDatabase: z
29+
.string()
30+
.optional()
31+
.describe("The Postgres database ID to use in the Firebase Data Connect service."),
1632
}),
1733
}),
1834
}),
@@ -21,25 +37,38 @@ export const init = tool(
2137
readOnlyHint: false,
2238
},
2339
_meta: {
24-
requiresProject: false, // Can start from stratch.
40+
requiresProject: false, // Can start from scratch.
2541
requiresAuth: false, // Will throw error if the specific feature needs it.
2642
},
2743
},
28-
async ({features}, { projectId, config, rc }) => {
44+
async ({ features }, { projectId, config, rc }) => {
45+
const featuresList: string[] = [];
46+
const featureInfo: SetupInfo = {};
47+
if (features.dataconnect) {
48+
featuresList.push("dataconnect");
49+
featureInfo.dataconnect = {
50+
serviceId: features.dataconnect.serviceId || "",
51+
locationId: features.dataconnect.locationId || "",
52+
cloudSqlInstanceId: features.dataconnect.cloudSqlInstanceId || "",
53+
cloudSqlDatabase: features.dataconnect.cloudSqlDatabase || "",
54+
connectors: [], // TODO populate with GiF,
55+
isNewInstance: false,
56+
isNewDatabase: false,
57+
schemaGql: [], // TODO populate with GiF
58+
shouldProvisionCSQL: false,
59+
};
60+
}
61+
2962
const setup: Setup = {
3063
config: config.src,
3164
rcfile: rc.data,
32-
projectId,
33-
features: [],
34-
featureInfo: {},
65+
projectId: projectId,
66+
features: featuresList,
67+
featureInfo: featureInfo,
3568
};
36-
if (features.dataconnect) {
37-
setup.features.push("dataconnect");
38-
setup.featureInfo.dataconnect = features.dataconnect;
39-
}
4069
await actuate(setup, config, {});
4170
return toContent(
42-
`The Firebase Data Connect Services has been initialized. You can now use the Firebase Data Connect Services.`,
71+
`Successfully setup the project ${projectId} with those features: ${featuresList.join(", ")}`,
4372
);
4473
},
4574
);

0 commit comments

Comments
 (0)