Skip to main content
Glama

configure_gemini_token

Set up your Gemini API key to enable image generation through the Nano-Banana-MCP server. This tool configures authentication for accessing Google AI Studio's image generation capabilities.

Instructions

Configure your Gemini API token for nano-banana image generation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
apiKeyYesYour Gemini API key from Google AI Studio

Implementation Reference

  • The main handler function `configureGeminiToken` that parses the API key using Zod, initializes the GoogleGenAI client, updates internal config state, saves the config to a file, and returns a success response.
    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; } }
  • Tool schema definition in the listTools response, specifying name, description, and inputSchema requiring 'apiKey' string.
    { 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)
    Registration and dispatch of the 'configure_gemini_token' tool in the CallToolRequest switch statement.
    case "configure_gemini_token": return await this.configureGeminiToken(request);
  • src/index.ts:55-150 (registration)
    Tool registration in the ListToolsRequest handler, where 'configure_gemini_token' is included in the list of available tools.
    return { tools: [ { 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"], }, }, { name: "generate_image", description: "Generate a NEW image from text prompt. Use this ONLY when creating a completely new image, not when modifying an existing one.", inputSchema: { type: "object", properties: { prompt: { type: "string", description: "Text prompt describing the NEW image to create from scratch", }, }, required: ["prompt"], }, }, { name: "edit_image", description: "Edit a SPECIFIC existing image file, optionally using additional reference images. Use this when you have the exact file path of an image to modify.", inputSchema: { type: "object", properties: { imagePath: { type: "string", description: "Full file path to the main image file to edit", }, prompt: { type: "string", description: "Text describing the modifications to make to the existing image", }, referenceImages: { type: "array", items: { type: "string" }, description: "Optional array of file paths to additional reference images to use during editing (e.g., for style transfer, adding elements, etc.)", }, }, required: ["imagePath", "prompt"], }, }, { name: "get_configuration_status", description: "Check if Gemini API token is configured", inputSchema: { type: "object", properties: {}, additionalProperties: false, }, }, { name: "continue_editing", description: "Continue editing the LAST image that was generated or edited in this session, optionally using additional reference images. Use this for iterative improvements, modifications, or changes to the most recent image. This automatically uses the previous image without needing a file path.", inputSchema: { type: "object", properties: { prompt: { type: "string", description: "Text describing the modifications/changes/improvements to make to the last image (e.g., 'change the hat color to red', 'remove the background', 'add flowers')", }, referenceImages: { type: "array", items: { type: "string" }, description: "Optional array of file paths to additional reference images to use during editing (e.g., for style transfer, adding elements from other images, etc.)", }, }, required: ["prompt"], }, }, { name: "get_last_image_info", description: "Get information about the last generated/edited image in this session (file path, size, etc.). Use this to check what image is currently available for continue_editing.", inputSchema: { type: "object", properties: {}, additionalProperties: false, }, }, ] as Tool[], };
  • Zod schema used for validating the Gemini API key in the configureGeminiToken handler.
    const ConfigSchema = z.object({ geminiApiKey: z.string().min(1, "Gemini API key is required"), });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ConechoAI/Nano-Banana-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server