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"),
    });

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A3.5/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It merely says 'Configure your Gemini API token' without disclosing whether the token is stored persistently, overwrites existing configurations, or has any side effects. This is a significant gap for a mutation-like tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence with no unnecessary words. It is appropriately front-loaded with the verb and object.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool is simple (1 param, no output schema), and the description states its purpose and domain. However, it lacks behavioral context such as persistence or success/failure indications, which matters given the absence of annotations. It is adequate but has clear gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema already provides a description for apiKey ('Your Gemini API key from Google AI Studio'), and the description adds only the term 'token', which is synonymous. With 100% schema coverage, there is no additional meaning added.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses the specific verb 'configure' and identifies the resource 'Gemini API token', clearly distinguishing this from sibling tools like generate_image or get_configuration_status. It also connects to the domain of nano-banana image generation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The phrase 'for nano-banana image generation' implies this is a prerequisite for generation, but it does not explicitly state when to use it versus alternatives like get_configuration_status, nor does it mention exclusions. The usage is implied rather than explicit.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.