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
8 changes: 7 additions & 1 deletion src/mcp/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@
"PRECONDITION_FAILED",
);

export function mcpAuthError(): CallToolResult {
export function mcpAuthError(skipADC: boolean): CallToolResult {

Check warning on line 9 in src/mcp/errors.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing JSDoc comment
const cmd = commandExistsSync("firebase") ? "firebase" : "npx -y firebase-tools";
if (skipADC) {
return mcpError(`The user is not currently logged into the Firebase CLI, which is required to use this tool. Please instruct the user to execute this shell command to sign in.
\`\`\`sh
${cmd} login
\`\`\``);
}
return mcpError(`The user is not currently logged into the Firebase CLI, which is required to use this tool. Please instruct the user to execute this shell command to sign in or to configure [Application Default Credentials][ADC] on their machine.
\`\`\`sh
${cmd} login
Expand All @@ -16,7 +22,7 @@
[ADC]: https://cloud.google.com/docs/authentication/application-default-credentials`);
}

export function mcpGeminiError(projectId: string) {

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

View workflow job for this annotation

GitHub Actions / lint (20)

Missing JSDoc comment

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

View workflow job for this annotation

GitHub Actions / lint (20)

Missing return type on function
const consoleUrl = `https://firebase.corp.google.com/project/${projectId}/overview`;
return mcpError(
`This tool uses the Gemini in Firebase API. Visit Firebase Console to enable the Gemini in Firebase API ${consoleUrl} and try again.`,
Expand Down
5 changes: 3 additions & 2 deletions src/mcp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
] as const;

export class FirebaseMcpServer {
private _ready: boolean = false;

Check warning on line 50 in src/mcp/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Type boolean trivially inferred from a boolean literal, remove type annotation
private _readyPromises: { resolve: () => void; reject: (err: unknown) => void }[] = [];
startupRoot?: string;
cachedProjectRoot?: string;
Expand Down Expand Up @@ -79,7 +79,7 @@
mcp_client_name: this.clientInfo?.name || "<unknown-client>",
mcp_client_version: this.clientInfo?.version || "<unknown-version>",
};
trackGA4(event, { ...params, ...clientInfoParams });

Check warning on line 82 in src/mcp/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
}

constructor(options: { activeFeatures?: ServerFeature[]; projectRoot?: string }) {
Expand All @@ -89,11 +89,11 @@
this.server.registerCapabilities({ tools: { listChanged: true }, logging: {} });
this.server.setRequestHandler(ListToolsRequestSchema, this.mcpListTools.bind(this));
this.server.setRequestHandler(CallToolRequestSchema, this.mcpCallTool.bind(this));
this.server.oninitialized = async () => {

Check warning on line 92 in src/mcp/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Promise-returning function provided to variable where a void return was expected
const clientInfo = this.server.getClientVersion();
this.clientInfo = clientInfo;
if (clientInfo?.name) {
this.trackGA4("mcp_client_connected");

Check warning on line 96 in src/mcp/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
}
if (!this.clientInfo?.name) this.clientInfo = { name: "<unknown-client>" };

Expand All @@ -108,12 +108,12 @@
return {};
});

this.detectProjectRoot();

Check warning on line 111 in src/mcp/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
this.detectActiveFeatures();

Check warning on line 112 in src/mcp/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
}

/** Wait until initialization has finished. */
ready() {

Check warning on line 116 in src/mcp/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing return type on function
if (this._ready) return Promise.resolve();
return new Promise((resolve, reject) => {
this._readyPromises.push({ resolve: resolve as () => void, reject });
Expand Down Expand Up @@ -283,9 +283,10 @@
projectId = projectId || "";

// Check if the user is logged in.
const accountEmail = await this.getAuthenticatedUser();
const skipAutoAuthForStudio = isFirebaseStudio();
const accountEmail = await this.getAuthenticatedUser(skipAutoAuthForStudio);
if (tool.mcp._meta?.requiresAuth && !accountEmail) {
return mcpAuthError();
return mcpAuthError(skipAutoAuthForStudio);
}

// Check if the tool requires Gemini in Firebase API.
Expand Down
Loading