Skip to main content
Glama

mcp_gemini_generate_text

Generate text using the Gemini AI model by defining prompt, model ID, and parameters like temperature, max tokens, topK, and topP for tailored outputs.

Instructions

Gemini AI 모델을 사용하여 텍스트를 생성합니다.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
max_tokensNo생성할 최대 토큰 수
modelYes사용할 Gemini 모델 ID (예: gemini-pro, gemini-1.5-pro 등)
promptYes텍스트 생성을 위한 프롬프트
temperatureNo생성 랜덤성 정도 (0.0 - 2.0)
topKNo각 위치에서 고려할 최상위 토큰 수
topPNo확률 질량의 상위 비율을 선택하는 임계값

Implementation Reference

  • The MCP tool handler function that receives arguments, calls the underlying Gemini service's generateText method, formats the response as ToolResponse, and handles errors.
    async handler(args: any): Promise<ToolResponse> {
      try {
        const result = await geminiService.generateText(args);
        return {
          content: [{
            type: 'text',
            text: result.text
          }]
        };
      } catch (error) {
        return {
          content: [{
            type: 'text',
            text: `Gemini 텍스트 생성 오류: ${error instanceof Error ? error.message : String(error)}`
          }]
        };
      }
    }
  • Core helper function implementing the actual API call to Gemini's generateContent endpoint, handling parameters, sending POST request via axios, extracting generated text, and returning structured response with usage info.
    async generateText({
      model,
      prompt,
      temperature = 0.7,
      max_tokens = 1024,
      topK = 40,
      topP = 0.95,
    }: {
      model: string;
      prompt: string;
      temperature?: number;
      max_tokens?: number;
      topK?: number;
      topP?: number;
    }) {
      try {
        const config = this.getRequestConfig();
        const url = `${this.baseUrl}/models/${model}:generateContent`;
    
        const response = await axios.post(
          url,
          {
            contents: [
              {
                parts: [
                  {
                    text: prompt,
                  },
                ],
              },
            ],
            generationConfig: {
              temperature,
              maxOutputTokens: max_tokens,
              topK,
              topP,
            },
          },
          config
        );
    
        // 응답에서 생성된 텍스트 추출
        const generatedText = response.data.candidates?.[0]?.content?.parts?.[0]?.text || '';
        
        return {
          text: generatedText,
          model: model,
          usage: {
            completion_tokens: response.data.usageMetadata?.candidatesTokenCount || 0,
            prompt_tokens: response.data.usageMetadata?.promptTokenCount || 0,
            total_tokens: 
              (response.data.usageMetadata?.promptTokenCount || 0) + 
              (response.data.usageMetadata?.candidatesTokenCount || 0),
          },
        };
      } catch (error) {
        throw this.formatError(error);
      }
    }
  • JSON Schema defining the input parameters, types, descriptions, defaults, and required fields for the mcp_gemini_generate_text tool.
    inputSchema: {
      type: 'object',
      required: ['model', 'prompt'],
      properties: {
        model: {
          type: 'string',
          description: '사용할 Gemini 모델 ID (예: gemini-pro, gemini-1.5-pro 등)',
        },
        prompt: {
          type: 'string',
          description: '텍스트 생성을 위한 프롬프트',
        },
        temperature: {
          type: 'number',
          description: '생성 랜덤성 정도 (0.0 - 2.0)',
          default: 0.7,
        },
        max_tokens: {
          type: 'number',
          description: '생성할 최대 토큰 수',
          default: 1024,
        },
        topK: {
          type: 'number',
          description: '각 위치에서 고려할 최상위 토큰 수',
          default: 40,
        },
        topP: {
          type: 'number',
          description: '확률 질량의 상위 비율을 선택하는 임계값',
          default: 0.95,
        },
      },
    },
  • src/index.ts:44-44 (registration)
    MCP server capabilities registration enabling the mcp_gemini_generate_text tool.
    mcp_gemini_generate_text: true,
Behavior2/5

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

No annotations are provided, so the description carries full burden for behavioral disclosure. While '텍스트를 생성합니다' (generates text) implies a non-destructive operation, it lacks critical details: required authentication, rate limits, cost implications, output format, error handling, or whether it's synchronous/asynchronous. For a generative AI tool with no annotation coverage, this is a significant gap.

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 in Korean that directly states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded with the core functionality.

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

Completeness2/5

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

For a generative AI tool with 6 parameters, no annotations, and no output schema, the description is incomplete. It lacks context about the tool's behavior (e.g., response format, limitations), usage scenarios, and differentiation from sibling tools, leaving significant gaps for an AI agent to understand when and how to invoke it correctly.

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?

Schema description coverage is 100%, providing clear documentation for all 6 parameters (model, prompt, max_tokens, temperature, topK, topP). The description adds no parameter-specific information beyond what's in the schema, so it meets the baseline of 3 where the schema does the heavy lifting.

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

Purpose3/5

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

The description states 'Gemini AI 모델을 사용하여 텍스트를 생성합니다' (Generates text using Gemini AI model), which clearly identifies the verb (generate) and resource (text) with the specific technology (Gemini). However, it doesn't distinguish this from sibling tools like 'mcp_gemini_chat_completion' or 'mcp_gemini_generate_multimodal_content', leaving ambiguity about when to use this versus other text generation options.

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. With multiple sibling tools for text generation (e.g., mcp_gemini_chat_completion, mcp_gemini_generate_multimodal_content) and other AI services (e.g., mcp_openai_chat), there's no indication of this tool's specific use case, prerequisites, or exclusions.

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

Related 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/bigdata-coss/agent_mcp'

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