Skip to content
Open
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
7 changes: 7 additions & 0 deletions src/mcp/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* Converts data to a CallToolResult.
*/
export function toContent(
data: any,

Check warning on line 23 in src/mcp/util.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
options?: { format?: "json" | "yaml"; contentPrefix?: string; contentSuffix?: string },
): CallToolResult {
if (typeof data === "string") return { content: [{ type: "text", text: data }] };
Expand Down Expand Up @@ -77,6 +77,9 @@
database: realtimeOrigin(),
};

// List of features for which we want to skip the integration check
const featureSkipServerCheck = new Set<ServerFeature>(["crashlytics"]);

/**
* Detects whether an MCP feature is active in the current project root. Relies first on
* `firebase.json` configuration, but falls back to API checks.
Expand All @@ -84,10 +87,14 @@
export async function checkFeatureActive(
feature: ServerFeature,
projectId?: string,
options?: any,

Check warning on line 90 in src/mcp/util.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
): Promise<boolean> {
// TODO(visum) Replace this short term hack with a public API to verify integration
// before showing tools.
// If the feature is a part of skip check, feature is active always!
if (featureSkipServerCheck.has(feature)) return true;
// if the feature is configured in firebase.json, it's active
if (feature in (options?.config?.data || {})) return true;

Check warning on line 97 in src/mcp/util.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .config on an `any` value
// if the feature's api is active in the project, it's active
try {
if (projectId)
Expand All @@ -106,16 +113,16 @@
// Helper function to process a single schema node (could be a property schema, items schema, etc.)
// Returns the cleaned schema, or null if the schema becomes invalid and should be removed according to the rules.
// The isRoot parameter is true only for the top-level schema object.
function deepClean(obj: any, isRootLevel: boolean = false): any {

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

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type

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

View workflow job for this annotation

GitHub Actions / lint (20)

Type boolean trivially inferred from a boolean literal, remove type annotation

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

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
if (typeof obj !== "object" || obj === null) {
return obj; // Not a schema object or null, return as is
}

// Create a shallow copy to modify
const cleanedObj = { ...obj };

Check warning on line 122 in src/mcp/util.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value

// Rule 1: Remove $schema (applies to any level, but typically at root)
if (cleanedObj.hasOwnProperty("$schema")) {

Check warning on line 125 in src/mcp/util.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Do not access Object.prototype method 'hasOwnProperty' from target object

Check warning on line 125 in src/mcp/util.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe call of an `any` typed value

Check warning on line 125 in src/mcp/util.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .hasOwnProperty on an `any` value
delete cleanedObj.$schema;
}

Expand Down
Loading