Skip to main content
Glama
georgejeffers

Gemini MCP Server

Generate Text

generate_text
Read-only

Generate text using Google Gemini AI models with configurable parameters like temperature, model selection, and system instructions for tailored responses.

Instructions

Generate text using Google Gemini models with configurable model, temperature, and system instructions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptYesThe text prompt to send to Gemini
modelNoGemini model to usegemini-2.5-flash
temperatureNoSampling temperature (0-2)
maxOutputTokensNoMaximum number of output tokens
systemInstructionNoSystem instruction to guide model behavior

Implementation Reference

  • The main handler function that executes the generate_text tool. It takes the prompt, model, temperature, maxOutputTokens, and systemInstruction parameters, calls Google Gemini's generateContent API, and returns the text response or a formatted error.
    async ({ prompt, model, temperature, maxOutputTokens, systemInstruction }) => {
      try {
        const response = await ai.models.generateContent({
          model,
          contents: prompt,
          config: { temperature, maxOutputTokens, systemInstruction },
        });
        return { content: [{ type: 'text' as const, text: response.text ?? '' }] };
      } catch (error) {
        return formatToolError(error);
      }
    },
  • Input schema definition using zod for the generate_text tool. Defines required fields (prompt, model) and optional fields (temperature, maxOutputTokens, systemInstruction) with their validation rules and descriptions.
    inputSchema: {
      prompt: z.string().min(1).describe('The text prompt to send to Gemini'),
      model: TextModel.default('gemini-2.5-flash').describe('Gemini model to use'),
      temperature: z.number().min(0).max(2).optional().describe('Sampling temperature (0-2)'),
      maxOutputTokens: z.number().min(1).optional().describe('Maximum number of output tokens'),
      systemInstruction: z.string().optional().describe('System instruction to guide model behavior'),
    },
  • src/index.ts:25-25 (registration)
    Registration of the generate_text tool with the MCP server. Calls the register function from generate-text.ts passing the server and AI client instances.
    registerGenerateText(server, ai);
  • Helper utility function used by generate_text handler to format errors. Converts errors to the standard MCP response format with isError flag.
    export function formatToolError(error: unknown) {
      const text = error instanceof Error ? error.message : String(error);
      return {
        content: [{ type: 'text' as const, text }],
        isError: true,
      };
    }
  • Type definition for TextModel enum used by generate_text schema. Defines valid Gemini model names including 'gemini-2.5-flash', 'gemini-2.5-pro', and various preview models.
    export const TextModel = z.enum([
      'gemini-2.5-flash',
      'gemini-2.5-pro',
      'gemini-3-flash-preview',
      'gemini-3-pro-preview',
      'gemini-3.1-pro-preview',
    ]);
    export type TextModel = z.infer<typeof TextModel>;
Behavior3/5

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

Annotations already declare readOnlyHint=true, openWorldHint=true, and destructiveHint=false, covering safety and scope. The description adds minimal behavioral context beyond annotations - it mentions 'configurable model, temperature, and system instructions' which hints at customization options, but doesn't describe rate limits, authentication needs, response format, or error behavior.

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, efficient sentence that front-loads the core purpose. Every word earns its place - 'Generate text' establishes the action, 'using Google Gemini models' specifies the technology, and 'with configurable model, temperature, and system instructions' highlights key customization options without unnecessary elaboration.

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?

For a text generation tool with comprehensive annotations and 100% schema coverage but no output schema, the description is minimally adequate. It covers the basic purpose and hints at configurability, but doesn't address when to use it versus siblings, expected response format, or practical considerations for using Gemini models effectively.

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?

With 100% schema description coverage, all parameters are well-documented in the schema itself. The description mentions 'configurable model, temperature, and system instructions' which maps to three of the five parameters, but doesn't add meaningful semantic context beyond what the schema already provides. The baseline of 3 is appropriate given the comprehensive schema coverage.

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

Purpose4/5

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

The description clearly states the verb ('Generate text') and resource ('using Google Gemini models'), specifying the core functionality. It distinguishes from some siblings like 'generate_image' or 'edit_image' by focusing on text generation, but doesn't explicitly differentiate from 'chat' which might also involve text generation with similar models.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like 'chat' or 'generate_with_search'. It mentions configurable parameters but doesn't indicate appropriate contexts, prerequisites, or exclusions for using this text generation tool.

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

Install Server

Other Tools

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/georgejeffers/gemini-mcp-server'

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