Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions src/mcp/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
import { cloudAiCompanionOrigin } from "../api";

export const NO_PROJECT_ERROR = mcpError(
"This tool requires an active project. Use the `firebase_update_environment` tool to set a project ID",
"To proceed requires an active project. Use the `firebase_update_environment` tool to set a project ID",
"PRECONDITION_FAILED",
);

const GEMINI_TOS_ERROR = mcpError(
"This tool requires features from Gemini in Firebase. You can enable the usage of this service and accept its associated terms of service using `firebase_update_environment`.\n" +
"To proceed requires features from Gemini in Firebase. You can enable the usage of this service and accept its associated terms of service using `firebase_update_environment`.\n" +
"Learn more about Gemini in Firebase and how it uses your data: https://firebase.google.com/docs/gemini-in-firebase#how-gemini-in-firebase-uses-your-data",
"PRECONDITION_FAILED",
);
Expand All @@ -30,7 +30,7 @@
return undefined;
}

export function noProjectDirectory(projectRoot: string | undefined): CallToolResult {

Check warning on line 33 in src/mcp/errors.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing JSDoc comment
return mcpError(
`The current project directory '${
projectRoot || "<NO PROJECT DIRECTORY FOUND>"
Expand All @@ -38,7 +38,7 @@
);
}

export function mcpAuthError(skipADC: boolean): CallToolResult {

Check warning on line 41 in src/mcp/errors.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing JSDoc comment
if (skipADC) {
return mcpError(
`The user is not currently logged into the Firebase CLI, which is required to use this tool. Please run the 'firebase_login' tool to log in.`,
Expand Down
58 changes: 58 additions & 0 deletions src/mcp/prompts/core/consult.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { detectApps } from "../../../dataconnect/appFinder";
import { chatWithFirebase } from "../../../gemini/fdcExperience";
import { requireGeminiToS } from "../../errors";
import { prompt } from "../../prompt";

export const consult = prompt(
{
name: "consult",
description:
"Use this command to consult the Firebase Assistant with access to detailed up-to-date documentation for the Firebase platform.",
arguments: [
{
name: "prompt",
description: "a question to pass to the Gemini in Firebase model",
required: true,
},
],
annotations: {
title: "Consult Firebase Assistant",
},
},
async ({ prompt }, { config, projectId }) => {
const gifTosError = await requireGeminiToS(projectId);
if (gifTosError) {
return [
{
role: "user",
content: {
type: "text",
text: `Missing required conditions to run this prompt:\n\n${gifTosError.content[0]?.text}`,

Check warning on line 30 in src/mcp/prompts/core/consult.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Invalid type "unknown" of template literal expression
},
},
];
}

const apps = await detectApps(config.projectDir);
const platforms = apps.map((a) => a.platform);

const gifPrompt = `I am using a coding agent to build with Firebase and I have a specific question that I would like answered. Provide a robust and detailed response that will help the coding agent act on my behalf in a local workspace.

App Platform(s): ${platforms.join(", ")}

Question: ${prompt}`;

const result = await chatWithFirebase(gifPrompt, projectId);
const outputString = result.output.messages?.[0].content ?? "";

return [
{
role: "user",
content: {
type: "text",
text: `I have consulted a Firebase Assistant agent with the following question: "${prompt}". Its response was as follows:\n\n${outputString}\n\nPlease use the information above to respond to my question. I have not seen the response from the Firebase Assistant, so please include all necessary information in your response. Inform the user that they must run the \`firebase:consult\` prompt again if they have followup questions for the Firebase Assistant.`,
},
},
];
},
);
3 changes: 2 additions & 1 deletion src/mcp/prompts/core/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { init } from "./init";
import { deploy } from "./deploy";
import { consult } from "./consult";

const corePrompts = [deploy, init];
const corePrompts = [deploy, init, consult];

export { corePrompts };
37 changes: 0 additions & 37 deletions src/mcp/tools/core/consult_assistant.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/mcp/tools/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { init } from "./init";
import { get_environment } from "./get_environment";
import { update_environment } from "./update_environment";
import { list_projects } from "./list_projects";
import { consult_assistant } from "./consult_assistant";
import { login } from "./login";
import { logout } from "./logout";
import { read_resources } from "./read_resources";
Expand All @@ -27,7 +26,6 @@ export const coreTools: ServerTool[] = [
create_project,
create_app,
create_android_sha,
consult_assistant,
get_environment,
update_environment,
init,
Expand Down
Loading