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
6 changes: 6 additions & 0 deletions src/bin/mcp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import { SERVER_FEATURES, ServerFeature } from "../mcp/types";
import { markdownDocsOfTools } from "../mcp/tools/index.js";
import { markdownDocsOfPrompts } from "../mcp/prompts/index.js";
import { markdownDocsOfResources } from "../mcp/resources/index.js";
import { resolve } from "path";

const STARTUP_MESSAGE = `
Expand All @@ -21,13 +22,14 @@
}
`;

export async function mcp(): Promise<void> {

Check warning on line 25 in src/bin/mcp.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing JSDoc comment
const { values } = parseArgs({
options: {
only: { type: "string", default: "" },
dir: { type: "string" },
"generate-tool-list": { type: "boolean", default: false },
"generate-prompt-list": { type: "boolean", default: false },
"generate-resource-list": { type: "boolean", default: false },
},
allowPositionals: true,
});
Expand All @@ -41,6 +43,10 @@
console.log(markdownDocsOfPrompts());
earlyExit = true;
}
if (values["generate-resource-list"]) {
console.log(markdownDocsOfResources());
earlyExit = true;
}
if (earlyExit) return;

process.env.IS_FIREBASE_MCP = "true";
Expand Down
14 changes: 13 additions & 1 deletion src/mcp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@
| Prompt Name | Feature Group | Description |
| ------------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| 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 |
| firebase:init | core | Use this command to setup Firebase for the current workspace. |
| firebase:init | core | Use this command to set up Firebase services, like backend and AI features. |
| 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 |
| crashlytics:connect | crashlytics | Access a Firebase application's Crashlytics data. |

| Resource Name | Description |
| -------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| backend_init_guide | Firebase Backend Init Guide: guides the coding agent through configuring Firebase backend services in the current project |
| ai_init_guide | Firebase GenAI Init Guide: guides the coding agent through configuring GenAI capabilities in the current project utilizing Firebase |
| data_connect_init_guide | Firebase Data Connect Init Guide: guides the coding agent through configuring Data Connect for PostgreSQL access in the current project |
| firestore_init_guide | Firestore Init Guide: guides the coding agent through configuring Firestore in the current project |
| firestore_rules_init_guide | Firestore Rules Init Guide: guides the coding agent through setting up Firestore security rules in the project |
| rtdb_init_guide | Firebase Realtime Database Init Guide: guides the coding agent through configuring Realtime Database in the current project |
| auth_init_guide | Firebase Authentication Init Guide: guides the coding agent through configuring Firebase Authentication in the current project |
| hosting_init_guide | Firebase Hosting Deployment Guide: guides the coding agent through deploying to Firebase Hosting in the current project |
| docs | Firebase Docs: loads plain text content from Firebase documentation, e.g. `https://firebase.google.com/docs/functions` becomes `firebase://docs/functions` |
19 changes: 19 additions & 0 deletions src/mcp/resources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@

export const resourceTemplates = [docs];

export async function resolveResource(

Check warning on line 28 in src/mcp/resources/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing JSDoc comment
uri: string,
ctx: McpContext,
track: boolean = true,

Check warning on line 31 in src/mcp/resources/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Type boolean trivially inferred from a boolean literal, remove type annotation
): Promise<
| ({
result: ReadResourceResult;
Expand Down Expand Up @@ -56,3 +56,22 @@
if (track) void trackGA4("mcp_read_resource", { resource_name: uri, not_found: "true" });
return null;
}

/**
* Generates a markdown table of all available resources and their descriptions.
* This is used for generating documentation.
*/
export function markdownDocsOfResources(): string {
const allResources = [...resources, ...resourceTemplates];
const headings = `
| Resource Name | Description |
| ------------- | ----------- |`;
const resourceRows = allResources.map((res) => {
let desc = res.mcp.title ? `${res.mcp.title}: ` : "";
desc += res.mcp.description || "";
desc = desc.replaceAll("\n", "<br>");
return `
| ${res.mcp.name} | ${desc} |`;
});
return headings + resourceRows.join("");
}
Comment on lines +64 to +77
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This function can be written more clearly to build the markdown table. Using an array of lines and then joining them with a newline character is a more common and readable pattern than concatenating strings with embedded newlines.

export function markdownDocsOfResources(): string {
  const allResources = [...resources, ...resourceTemplates];
  const header = [
    "| Resource Name | Description |".
    "| ------------- | ----------- |",
  ];
  const resourceRows = allResources.map((res) => {
    let desc = res.mcp.title ? `${res.mcp.title}: ` : "";
    desc += res.mcp.description || "";
    desc = desc.replaceAll("\n", "<br>");
    return `| ${res.mcp.name} | ${desc} |`;
  });
  return [...header, ...resourceRows].join("\n");
}

Loading