npm install @google/genai @doconda/sdk
doconda.tools() es JSON Schema, que Gemini acepta en parametersJsonSchema:
import { type Content, GoogleGenAI } from "@google/genai"
import { Doconda } from "@doconda/sdk"
const ai = new GoogleGenAI({})
const tools = new Doconda().tools()
const contents: Content[] = [{ role: "user", parts: [{ text: "Hazme un Excel con el presupuesto del evento" }] }]
while (true) {
const res = await ai.models.generateContent({
model: "gemini-3.5-flash",
contents,
config: { tools: [{ functionDeclarations: tools.map((t) => ({ name: t.name, description: t.description, parametersJsonSchema: t.inputSchema })) }] },
})
if (!res.functionCalls?.length) break
contents.push(res.candidates![0].content!)
const parts = await Promise.all(
res.functionCalls.map(async (call) => ({
functionResponse: { name: call.name, response: { result: await tools.find((t) => t.name === call.name)!.run(call.args ?? {}) } },
})),
)
contents.push({ role: "user", parts })
}
Con MCP (experimental en @google/genai)
Con MCP (experimental en @google/genai)
import { GoogleGenAI, mcpToTool } from "@google/genai"
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
const doconda = new Client({ name: "my-app", version: "1.0.0" })
await doconda.connect(
new StreamableHTTPClientTransport(new URL("https://api.eu.doconda.com/mcp"), {
requestInit: { headers: { Authorization: `Bearer ${process.env.DOCONDA_API_KEY}` } },
}),
)
await new GoogleGenAI({}).models.generateContent({
model: "gemini-3.5-flash",
contents: "Hazme un Excel con el presupuesto del evento",
config: { tools: [mcpToTool(doconda)] }, // Gemini llama a las herramientas solo
})