configure_gemini_token
Set up your Gemini API token from Google AI Studio to enable image generation capabilities in the Nano-Banana MCP server.
Instructions
Configure your Gemini API token for nano-banana image generation
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| apiKey | Yes | Your Gemini API key from Google AI Studio |
Implementation Reference
- src/index.ts:186-212 (handler)The main handler function for the configure_gemini_token tool. It extracts the apiKey from the request, validates it using ConfigSchema, initializes the GoogleGenAI instance, sets configuration flags, saves the config to a file, and returns a success message.private async configureGeminiToken(request: CallToolRequest): Promise<CallToolResult> { const { apiKey } = request.params.arguments as { apiKey: string }; try { ConfigSchema.parse({ geminiApiKey: apiKey }); this.config = { geminiApiKey: apiKey }; this.genAI = new GoogleGenAI({ apiKey }); this.configSource = 'config_file'; // Manual configuration via tool await this.saveConfig(); return { content: [ { type: "text", text: "✅ Gemini API token configured successfully! You can now use nano-banana image generation features.", }, ], }; } catch (error) { if (error instanceof z.ZodError) { throw new McpError(ErrorCode.InvalidParams, `Invalid API key: ${error.errors[0]?.message}`); } throw error; } }
- src/index.ts:60-69 (schema)The input schema for the configure_gemini_token tool, defining a required 'apiKey' string property.inputSchema: { type: "object", properties: { apiKey: { type: "string", description: "Your Gemini API key from Google AI Studio", }, }, required: ["apiKey"], },
- src/index.ts:57-70 (registration)Registration of the configure_gemini_token tool in the ListTools response, including name, description, and input schema.{ name: "configure_gemini_token", description: "Configure your Gemini API token for nano-banana image generation", inputSchema: { type: "object", properties: { apiKey: { type: "string", description: "Your Gemini API key from Google AI Studio", }, }, required: ["apiKey"], }, },
- src/index.ts:156-157 (registration)Dispatch case in the CallToolRequest handler that routes execution to the configureGeminiToken method.case "configure_gemini_token": return await this.configureGeminiToken(request);
- src/index.ts:24-26 (schema)Internal Zod schema used for validating the Gemini API key in the handler.const ConfigSchema = z.object({ geminiApiKey: z.string().min(1, "Gemini API key is required"), });