Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions src/mcp/tools/dataconnect/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { z } from "zod";
import { tool } from "../../tool";
import { pickService } from "../../../dataconnect/load";
import { compileErrors } from "../../util/dataconnect/compile";
import { DataConnectEmulator } from "../../../emulator/dataconnectEmulator";
import { getProjectDefaultAccount } from "../../../auth";

export const compile = tool(
"dataconnect",
Expand All @@ -20,6 +22,10 @@ export const compile = tool(
.describe(
"The Firebase Data Connect service ID to look for. If omitted, builds all services defined in `firebase.json`.",
),
generate_sdk: z
.boolean()
.optional()
.describe("Whether to generate typed SDKs for your Data Connect connectors."),
}),
annotations: {
title: "Compile Data Connect",
Expand All @@ -30,8 +36,23 @@ export const compile = tool(
requiresAuth: false,
},
},
async ({ service_id, error_filter }, { projectId, config }) => {
const serviceInfo = await pickService(projectId, config, service_id || undefined);
async ({ service_id, error_filter, generate_sdk }, ctx) => {
const serviceInfo = await pickService(ctx.projectId, ctx.config, service_id || undefined);
if (generate_sdk) {
await DataConnectEmulator.generate({
configDir: serviceInfo.sourceDirectory,
watch: false,
account: getProjectDefaultAccount(ctx.config.projectDir),
});
return {
content: [
{
type: "text",
text: `Generated SDKs for service ${serviceInfo.dataConnectYaml.serviceId}`,
},
],
};
}
const errors = await compileErrors(serviceInfo.sourceDirectory, error_filter);
if (errors)
return {
Expand Down
Loading