-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[MCP] Create list_projects tool + slight modifications to list_apps #2 #8610
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+64
−7
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { | ||
const originalMessage = err.original ? `: ${err.original.message}` : ""; | ||
Check warning on line 46 in src/mcp/tools/core/list_projects.ts
|
||
throw new Error(`Failed to list Firebase projects${originalMessage}`); | ||
} | ||
}, | ||
); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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