Skip to content

Commit 1a76904

Browse files
committed
Create list_projects tool + slight modifications to list_apps
1 parent c6042a7 commit 1a76904

File tree

3 files changed

+33
-22
lines changed

3 files changed

+33
-22
lines changed

src/mcp/tools/core/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import { create_android_sha } from "./create_android_sha.js";
1010
import { init } from "./init.js";
1111
import { get_environment } from "./get_environment.js";
1212
import { update_environment } from "./update_environment.js";
13-
// import { consult_assistant } from "./consult_assistant.js";
1413
import { list_projects } from "./list_projects.js";
14+
// import { consult_assistant } from "./consult_assistant.js";
1515

1616
export const coreTools: ServerTool[] = [
1717
get_project,

src/mcp/tools/core/list_apps.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ export const list_apps = tool(
99
description: "Retrieves apps registered in the current Firebase project.",
1010
inputSchema: z.object({
1111
platform: z
12-
.enum(["ios", "android", "web"])
13-
.nullish()
12+
.enum(["ios", "android", "web", "all"])
13+
.default("all")
1414
.describe("the specific platform to list (omit to list all platforms)"),
1515
}),
1616
annotations: {
@@ -23,10 +23,15 @@ export const list_apps = tool(
2323
},
2424
},
2525
async ({ platform }, { projectId }) => {
26-
const apps = await listFirebaseApps(
27-
projectId!,
28-
(platform?.toUpperCase() as AppPlatform) ?? AppPlatform.ANY,
29-
);
30-
return toContent(apps);
26+
try {
27+
const apps = await listFirebaseApps(
28+
projectId!,
29+
platform === "all" ? AppPlatform.ANY : (platform.toUpperCase() as AppPlatform),
30+
);
31+
return toContent(apps);
32+
} catch (err: any) {
33+
const originalMessage = err.original ? `: ${err.original.message}` : "";
34+
throw new Error(`Failed to list Firebase apps${originalMessage}`);
35+
}
3136
},
3237
);

src/mcp/tools/core/list_projects.ts

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { toContent } from "../../util.js";
44
import { getFirebaseProjectPage } from "../../../management/projects.js";
55
import { FirebaseProjectMetadata } from "../../../types/project/index.d.js";
66

7-
const PROJECT_LIST_PAGE_SIZE = 10;
7+
const PROJECT_LIST_PAGE_SIZE = 20;
88

99
export const list_projects = tool(
1010
{
@@ -15,7 +15,7 @@ export const list_projects = tool(
1515
.number()
1616
.min(1)
1717
.default(PROJECT_LIST_PAGE_SIZE)
18-
.describe("the number of projects to list per page (defaults to 10)"),
18+
.describe("the number of projects to list per page (defaults to 1000)"),
1919
page_token: z
2020
.string()
2121
.optional()
@@ -31,18 +31,24 @@ export const list_projects = tool(
3131
},
3232
},
3333
async ({ page_size, page_token }) => {
34-
const projectPage = await getFirebaseProjectPage(page_size, page_token);
35-
36-
let message = "";
37-
if (projectPage.nextPageToken) {
38-
message = `Here are ${projectPage.projects.length} Firebase projects.\n\n` +
39-
`To list more projects, call this tool again with page_token: "${projectPage.nextPageToken}"`;
40-
}
34+
try {
35+
const projectPage = await getFirebaseProjectPage(page_size, page_token);
4136

42-
return toContent({
43-
message,
44-
projects: projectPage.projects,
45-
next_page_token: projectPage.nextPageToken,
46-
});
37+
return toContent(
38+
{
39+
projects: projectPage.projects,
40+
next_page_token: projectPage.nextPageToken,
41+
},
42+
{
43+
contentPrefix: `Here are ${projectPage.projects.length} Firebase projects${page_token ? " (continued)" : ""}:\n\n`,
44+
contentSuffix: projectPage.nextPageToken
45+
? "\nThere are more projects available. To see the next page, call this tool again with the next_page_token shown above."
46+
: "",
47+
},
48+
);
49+
} catch (err: any) {
50+
const originalMessage = err.original ? `: ${err.original.message}` : "";
51+
throw new Error(`Failed to list Firebase projects${originalMessage}`);
52+
}
4753
},
4854
);

0 commit comments

Comments
 (0)