Skip to content

Commit a1dd703

Browse files
mbleighTrCaM
authored andcommitted
fix(mcp): Make tool schemas more Gemini-compatible. (firebase#8637)
1 parent 6239d2d commit a1dd703

File tree

13 files changed

+2319
-14
lines changed

13 files changed

+2319
-14
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
2+
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
3+
4+
if (!process.env.GEMINI_API_KEY) {
5+
console.error("Must set GEMINI_API_KEY to run this smoke test.");
6+
process.exit(1);
7+
}
8+
9+
const client = new Client({
10+
name: "firebase-mcp-smoke-tester",
11+
version: "0.0.1",
12+
});
13+
14+
await client.connect(
15+
new StdioClientTransport({
16+
command: "../../lib/bin/firebase.js",
17+
args: [
18+
"experimental:mcp",
19+
"--only",
20+
"firestore,dataconnect,messaging,remoteconfig,crashlytics,auth,storage",
21+
],
22+
}),
23+
);
24+
25+
const { tools } = await client.listTools();
26+
27+
const geminiTools = tools.map((tool) => {
28+
return {
29+
name: tool.name,
30+
description: tool.description,
31+
parameters: tool.inputSchema,
32+
};
33+
});
34+
35+
const response = await fetch(
36+
`https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=${process.env.GEMINI_API_KEY}`,
37+
{
38+
method: "POST",
39+
headers: {
40+
"content-type": "application/json",
41+
},
42+
body: JSON.stringify({
43+
toolConfig: {
44+
functionCallingConfig: { mode: "auto" },
45+
},
46+
tools: [{ functionDeclarations: geminiTools }],
47+
contents: [
48+
{
49+
parts: [{ text: "Call the firebase_list_apps tool." }],
50+
},
51+
],
52+
}),
53+
},
54+
);
55+
56+
if (response.status === 200) {
57+
console.dir(await response.json(), { depth: null });
58+
59+
console.log("✅ Passed smoke test!");
60+
process.exit(0);
61+
} else {
62+
const rtext = await response.text();
63+
try {
64+
console.dir(JSON.parse(rtext), { depth: null });
65+
} catch (e) {
66+
console.log(rtext);
67+
}
68+
console.error("ERROR: Got non-200 response from smoke test.");
69+
process.exit(1);
70+
}

0 commit comments

Comments
 (0)