Skip to content

Commit 8b8b9ca

Browse files
authored
Allow MCP to use ADC (#8735)
* Allow MCP to use ADC * Refactor * PR fixes
1 parent 01456b5 commit 8b8b9ca

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
- Add validation during `firebase init` feature selection. (#5232)
44
- Fixed an issue where the extensions emulator did not work with `demo-` projects. (#8720)
55
- Fixed issue where `--export-on-exit` fails if the target directory does not exist. (#4688)
6+
- Fixed issue where the Firebase MCP server could not use application default credentials. (#8671)

src/mcp/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,8 @@ export class FirebaseMcpServer {
174174

175175
async getAuthenticatedUser(): Promise<string | null> {
176176
try {
177-
return await requireAuth(await this.resolveOptions());
177+
const email = await requireAuth(await this.resolveOptions());
178+
return email ?? "Application Default Credentials";
178179
} catch (e) {
179180
return null;
180181
}

src/requireAuth.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ export async function refreshAuth(): Promise<Tokens> {
7777
}
7878

7979
/**
80-
* Ensures that there is an authenticated user.
80+
* Ensures that the user can make authenticated calls. Returns the email if the user is logged in,
81+
* returns null if the user has Applciation Default Credentials set up, and errors out
82+
* if the user is not authenticated
8183
* @param options CLI options.
8284
*/
8385
export async function requireAuth(options: any): Promise<string | null> {

0 commit comments

Comments
 (0)