Skip to content

Commit a71f2d3

Browse files
MCP: Add --generate-prompt-list option (#9249)
1 parent 581b9bf commit a71f2d3

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

src/bin/mcp.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { FirebaseMcpServer } from "../mcp/index";
55
import { parseArgs } from "util";
66
import { SERVER_FEATURES, ServerFeature } from "../mcp/types";
77
import { markdownDocsOfTools } from "../mcp/tools/index.js";
8+
import { markdownDocsOfPrompts } from "../mcp/prompts/index.js";
89
import { resolve } from "path";
910

1011
const STARTUP_MESSAGE = `
@@ -26,13 +27,22 @@ export async function mcp(): Promise<void> {
2627
only: { type: "string", default: "" },
2728
dir: { type: "string" },
2829
"generate-tool-list": { type: "boolean", default: false },
30+
"generate-prompt-list": { type: "boolean", default: false },
2931
},
3032
allowPositionals: true,
3133
});
34+
35+
let earlyExit = false;
3236
if (values["generate-tool-list"]) {
3337
console.log(markdownDocsOfTools());
34-
return;
38+
earlyExit = true;
39+
}
40+
if (values["generate-prompt-list"]) {
41+
console.log(markdownDocsOfPrompts());
42+
earlyExit = true;
3543
}
44+
if (earlyExit) return;
45+
3646
process.env.IS_FIREBASE_MCP = "true";
3747
useFileLogger();
3848
const activeFeatures = (values.only || "")

src/mcp/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,10 @@ Only counts events matching the given filters. |
6969
| apphosting_list_backends | apphosting | Use this to retrieve a list of App Hosting backends in the current project. An empty list means that there are no backends. The `uri` is the public URL of the backend. A working backend will have a `managed_resources` array that will contain a `run_service` entry. That `run_service.service` is the resource name of the Cloud Run service serving the App Hosting backend. The last segment of that name is the service ID. `domains` is the list of domains that are associated with the backend. They either have type `CUSTOM` or `DEFAULT`. Every backend should have a `DEFAULT` domain. The actual domain that a user would use to conenct to the backend is the last parameter of the domain resource name. If a custom domain is correctly set up, it will have statuses ending in `ACTIVE`. |
7070
| realtimedatabase_get_data | realtimedatabase | Use this to retrieve data from the specified location in a Firebase Realtime Database. |
7171
| realtimedatabase_set_data | realtimedatabase | Use this to write data to the specified location in a Firebase Realtime Database. |
72+
73+
| Prompt Name | Feature Group | Description |
74+
| ------------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
75+
| firebase:deploy | core | Use this command to deploy resources to Firebase. <br><br>Arguments: <br>&lt;prompt&gt; (optional): any specific instructions you wish to provide about deploying |
76+
| firebase:init | core | Use this command to setup Firebase for the current workspace. |
77+
| firebase:consult | core | Use this command to consult the Firebase Assistant with access to detailed up-to-date documentation for the Firebase platform. <br><br>Arguments: <br>&lt;prompt&gt;: a question to pass to the Gemini in Firebase model |
78+
| crashlytics:connect | crashlytics | Access a Firebase application's Crashlytics data. |

src/mcp/prompts/index.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,28 @@ export function availablePrompts(features?: ServerFeature[]): ServerPrompt[] {
5454
}
5555
return allPrompts;
5656
}
57+
58+
/**
59+
* Generates a markdown table of all available prompts and their descriptions.
60+
* This is used for generating documentation.
61+
*/
62+
export function markdownDocsOfPrompts(): string {
63+
const allPrompts = availablePrompts();
64+
let doc = `
65+
| Prompt Name | Feature Group | Description |
66+
| ----------- | ------------- | ----------- |`;
67+
for (const prompt of allPrompts) {
68+
const feature = prompt.mcp._meta?.feature || "";
69+
let description = prompt.mcp.description || "";
70+
if (prompt.mcp.arguments?.length) {
71+
const argsList = prompt.mcp.arguments.map(
72+
(arg) =>
73+
` <br>&lt;${arg.name}&gt;${arg.required ? "" : " (optional)"}: ${arg.description || ""}`,
74+
);
75+
description += ` <br><br>Arguments:${argsList.join("")}`;
76+
}
77+
doc += `
78+
| ${prompt.mcp.name} | ${feature} | ${description} |`;
79+
}
80+
return doc;
81+
}

0 commit comments

Comments
 (0)