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
2 changes: 2 additions & 0 deletions src/mcp/tools/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ import { create_android_sha } from "./create_android_sha.js";
import { init } from "./init.js";
import { get_environment } from "./get_environment.js";
import { update_environment } from "./update_environment.js";
import { list_projects } from "./list_projects.js";
// import { consult_assistant } from "./consult_assistant.js";

export const coreTools: ServerTool[] = [
get_project,
list_apps,
get_admin_sdk_config,
list_projects,
get_sdk_config,
create_project,
create_app,
Expand Down
19 changes: 12 additions & 7 deletions src/mcp/tools/core/list_apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
description: "Retrieves apps registered in the current Firebase project.",
inputSchema: z.object({
platform: z
.enum(["ios", "android", "web"])
.optional()
.enum(["ios", "android", "web", "all"])
.default("all")
.describe("the specific platform to list (omit to list all platforms)"),
}),
annotations: {
Expand All @@ -23,10 +23,15 @@
},
},
async ({ platform }, { projectId }) => {
const apps = await listFirebaseApps(
projectId,
(platform?.toUpperCase() as AppPlatform) ?? AppPlatform.ANY,
);
return toContent(apps);
try {
const apps = await listFirebaseApps(
projectId!,

Check warning on line 28 in src/mcp/tools/core/list_apps.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Forbidden non-null assertion

Check warning on line 28 in src/mcp/tools/core/list_apps.ts

View workflow job for this annotation

GitHub Actions / lint (20)

This assertion is unnecessary since it does not change the type of the expression
platform === "all" ? AppPlatform.ANY : (platform.toUpperCase() as AppPlatform),
);
return toContent(apps);
} catch (err: any) {

Check warning on line 32 in src/mcp/tools/core/list_apps.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
const originalMessage = err.original ? `: ${err.original.message}` : "";

Check warning on line 33 in src/mcp/tools/core/list_apps.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .original on an `any` value

Check warning on line 33 in src/mcp/tools/core/list_apps.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Invalid type "any" of template literal expression

Check warning on line 33 in src/mcp/tools/core/list_apps.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .original on an `any` value
Copy link
Contributor

Choose a reason for hiding this comment

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

Wonder if this logic is worth porting to the upstream exception handler.

It feels like a generic enough improvement.

https://github.com/firebase/firebase-tools/blob/master/src/mcp/index.ts#L223

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that would require some refactoring that I'd like to work on a separate PR

throw new Error(`Failed to list Firebase apps${originalMessage}`);
}
},
);
50 changes: 50 additions & 0 deletions src/mcp/tools/core/list_projects.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { z } from "zod";
import { tool } from "../../tool.js";
import { toContent } from "../../util.js";
import { getFirebaseProjectPage } from "../../../management/projects.js";

const PROJECT_LIST_PAGE_SIZE = 20;

export const list_projects = tool(
{
name: "list_projects",
description: "Retrieves a list of Firebase projects up to the specified total count.",
inputSchema: z.object({
page_size: z
.number()
.min(1)
.default(PROJECT_LIST_PAGE_SIZE)
.describe("the number of projects to list per page (defaults to 1000)"),
page_token: z.string().optional().describe("the page token to start listing from"),
}),
annotations: {
title: "List Firebase Projects",
readOnlyHint: true,
idempotentHint: true,
},
_meta: {
requiresAuth: true,
},
},
async ({ page_size, page_token }) => {
try {
const projectPage = await getFirebaseProjectPage(page_size, page_token);

return toContent(
{
projects: projectPage.projects,
next_page_token: projectPage.nextPageToken,
},
{
contentPrefix: `Here are ${projectPage.projects.length} Firebase projects${page_token ? " (continued)" : ""}:\n\n`,
contentSuffix: projectPage.nextPageToken
? "\nThere are more projects available. To see the next page, call this tool again with the next_page_token shown above."
: "",
},
);
} catch (err: any) {

Check warning on line 45 in src/mcp/tools/core/list_projects.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
const originalMessage = err.original ? `: ${err.original.message}` : "";

Check warning on line 46 in src/mcp/tools/core/list_projects.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .original on an `any` value

Check warning on line 46 in src/mcp/tools/core/list_projects.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Invalid type "any" of template literal expression

Check warning on line 46 in src/mcp/tools/core/list_projects.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .original on an `any` value
throw new Error(`Failed to list Firebase projects${originalMessage}`);
}
},
);
Loading