Skip to content

Commit 376dc89

Browse files
MCP: Add --generate-resource-list option (#9255)
1 parent e122ec3 commit 376dc89

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

src/bin/mcp.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { parseArgs } from "util";
66
import { SERVER_FEATURES, ServerFeature } from "../mcp/types";
77
import { markdownDocsOfTools } from "../mcp/tools/index.js";
88
import { markdownDocsOfPrompts } from "../mcp/prompts/index.js";
9+
import { markdownDocsOfResources } from "../mcp/resources/index.js";
910
import { resolve } from "path";
1011

1112
const STARTUP_MESSAGE = `
@@ -28,6 +29,7 @@ export async function mcp(): Promise<void> {
2829
dir: { type: "string" },
2930
"generate-tool-list": { type: "boolean", default: false },
3031
"generate-prompt-list": { type: "boolean", default: false },
32+
"generate-resource-list": { type: "boolean", default: false },
3133
},
3234
allowPositionals: true,
3335
});
@@ -41,6 +43,10 @@ export async function mcp(): Promise<void> {
4143
console.log(markdownDocsOfPrompts());
4244
earlyExit = true;
4345
}
46+
if (values["generate-resource-list"]) {
47+
console.log(markdownDocsOfResources());
48+
earlyExit = true;
49+
}
4450
if (earlyExit) return;
4551

4652
process.env.IS_FIREBASE_MCP = "true";

src/mcp/README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,18 @@
5353
| Prompt Name | Feature Group | Description |
5454
| ------------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
5555
| 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 |
56-
| firebase:init | core | Use this command to setup Firebase for the current workspace. |
56+
| firebase:init | core | Use this command to set up Firebase services, like backend and AI features. |
5757
| 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 |
5858
| crashlytics:connect | crashlytics | Access a Firebase application's Crashlytics data. |
59+
60+
| Resource Name | Description |
61+
| -------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
62+
| backend_init_guide | Firebase Backend Init Guide: guides the coding agent through configuring Firebase backend services in the current project |
63+
| ai_init_guide | Firebase GenAI Init Guide: guides the coding agent through configuring GenAI capabilities in the current project utilizing Firebase |
64+
| data_connect_init_guide | Firebase Data Connect Init Guide: guides the coding agent through configuring Data Connect for PostgreSQL access in the current project |
65+
| firestore_init_guide | Firestore Init Guide: guides the coding agent through configuring Firestore in the current project |
66+
| firestore_rules_init_guide | Firestore Rules Init Guide: guides the coding agent through setting up Firestore security rules in the project |
67+
| rtdb_init_guide | Firebase Realtime Database Init Guide: guides the coding agent through configuring Realtime Database in the current project |
68+
| auth_init_guide | Firebase Authentication Init Guide: guides the coding agent through configuring Firebase Authentication in the current project |
69+
| hosting_init_guide | Firebase Hosting Deployment Guide: guides the coding agent through deploying to Firebase Hosting in the current project |
70+
| docs | Firebase Docs: loads plain text content from Firebase documentation, e.g. `https://firebase.google.com/docs/functions` becomes `firebase://docs/functions` |

src/mcp/resources/index.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,22 @@ export async function resolveResource(
5656
if (track) void trackGA4("mcp_read_resource", { resource_name: uri, not_found: "true" });
5757
return null;
5858
}
59+
60+
/**
61+
* Generates a markdown table of all available resources and their descriptions.
62+
* This is used for generating documentation.
63+
*/
64+
export function markdownDocsOfResources(): string {
65+
const allResources = [...resources, ...resourceTemplates];
66+
const headings = `
67+
| Resource Name | Description |
68+
| ------------- | ----------- |`;
69+
const resourceRows = allResources.map((res) => {
70+
let desc = res.mcp.title ? `${res.mcp.title}: ` : "";
71+
desc += res.mcp.description || "";
72+
desc = desc.replaceAll("\n", "<br>");
73+
return `
74+
| ${res.mcp.name} | ${desc} |`;
75+
});
76+
return headings + resourceRows.join("");
77+
}

0 commit comments

Comments
 (0)