Skip to content
Merged
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
13 changes: 7 additions & 6 deletions src/mcp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import { isFirebaseStudio } from "../env";
import { timeoutFallback } from "../timeout";
import { resolveResource, resources, resourceTemplates } from "./resources";
import * as crossSpawn from "cross-spawn";

const SERVER_VERSION = "0.3.0";

Expand All @@ -71,6 +72,7 @@
detectedFeatures?: ServerFeature[];
clientInfo?: { name?: string; version?: string };
emulatorHubClient?: EmulatorHubClient;
private cliCommand?: string;

// logging spec:
// https://modelcontextprotocol.io/specification/2025-03-26/server/utilities/logging
Expand Down Expand Up @@ -146,12 +148,12 @@
return {};
});

this.detectProjectRoot();

Check warning on line 151 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 152 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 156 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 All @@ -162,19 +164,19 @@
return this.clientInfo?.name ?? (isFirebaseStudio() ? "Firebase Studio" : "<unknown-client>");
}

private get clientConfigKey() {

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

View workflow job for this annotation

GitHub Actions / lint (20)

Missing return type on function
return `mcp.clientConfigs.${this.clientName}:${this.startupRoot || process.cwd()}`;
}

getStoredClientConfig(): ClientConfig {
return configstore.get(this.clientConfigKey) || {};

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

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe return of an `any` typed value
}

updateStoredClientConfig(update: Partial<ClientConfig>) {

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

View workflow job for this annotation

GitHub Actions / lint (20)

Missing return type on function
const config = configstore.get(this.clientConfigKey) || {};

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

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value
const newConfig = { ...config, ...update };

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

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value
configstore.set(this.clientConfigKey, newConfig);
return newConfig;

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

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe return of an `any` typed value
}

async detectProjectRoot(): Promise<string> {
Expand Down Expand Up @@ -299,12 +301,11 @@
}

private _getFirebaseCliCommand(): string {
// TODO(samedson) In the future, we'd like to detect how you ran the MCP
// server, and use that so that the CLI doesn't run commands that result in
// an install. The reason we can't just use `firebase` is some users may
// have run the MCP server via npx, and don't have firebase installed
// globally
return "npx firebase-tools@latest";
if (!this.cliCommand) {
const testCommand = crossSpawn.sync("firebase --version");
this.cliCommand = testCommand.error ? "npx firebase-tools@latest" : "firebase";
}
return this.cliCommand;
}

async mcpListTools(): Promise<ListToolsResult> {
Expand Down
Loading