Skip to main content
Glama
aliargun

Gemini MCP Server

by aliargun

embed_text

Generate text embeddings using Gemini models to convert text into numerical vectors for AI applications like semantic search and similarity analysis.

Instructions

Generate embeddings for text using Gemini embedding models

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYesText to generate embeddings for
modelNoEmbedding model to usetext-embedding-004

Implementation Reference

  • The core handler function that executes the embed_text tool by calling Google Gemini's embedContent API to generate text embeddings.
    private async embedText(id: any, args: any): Promise<MCPResponse> {
      try {
        const model = args.model || 'text-embedding-004';
        
        const result = await this.genAI.models.embedContent({
          model,
          contents: args.text
        });
    
        return {
          jsonrpc: '2.0',
          id,
          result: {
            content: [{
              type: 'text',
              text: JSON.stringify({
                embedding: result.embeddings?.[0]?.values || [],
                model
              })
            }],
            metadata: {
              model,
              dimensions: result.embeddings?.[0]?.values?.length || 0
            }
          }
        };
      } catch (error) {
        return {
          jsonrpc: '2.0',
          id,
          error: {
            code: -32603,
            message: error instanceof Error ? error.message : 'Internal error'
          }
        };
      }
    }
  • Tool registration in the getAvailableTools() method, defining the tool name, description, and input schema.
    {
      name: 'embed_text',
      description: 'Generate embeddings for text using Gemini embedding models',
      inputSchema: {
        type: 'object',
        properties: {
          text: {
            type: 'string',
            description: 'Text to generate embeddings for'
          },
          model: {
            type: 'string',
            description: 'Embedding model to use',
            enum: ['text-embedding-004', 'text-multilingual-embedding-002'],
            default: 'text-embedding-004'
          }
        },
        required: ['text']
      }
    },
  • Input schema definition for the embed_text tool, specifying required 'text' parameter and optional embedding model.
      inputSchema: {
        type: 'object',
        properties: {
          text: {
            type: 'string',
            description: 'Text to generate embeddings for'
          },
          model: {
            type: 'string',
            description: 'Embedding model to use',
            enum: ['text-embedding-004', 'text-multilingual-embedding-002'],
            default: 'text-embedding-004'
          }
        },
        required: ['text']
      }
    },
  • Dispatch logic in handleToolCall() switch statement that routes embed_text calls to the handler.
    case 'embed_text':
      return await this.embedText(request.id, args);
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states what the tool does but doesn't mention important behavioral aspects like rate limits, authentication requirements, response format, or potential costs. The description is minimal and lacks operational context.

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 extremely concise - a single sentence that directly states the tool's function without any fluff. It's front-loaded with the core purpose and wastes no words, making it efficient for an agent to parse.

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 tool with no annotations and no output schema, the description is insufficient. It doesn't explain what embeddings are, what format they're returned in, typical use cases, or any operational constraints. Given the complexity of embedding generation and lack of structured metadata, more descriptive context would be helpful.

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, the schema already documents both parameters thoroughly. The description doesn't add any meaningful parameter semantics beyond what's in the schema - it mentions 'text' and 'Gemini embedding models' but provides no additional context about parameter usage or constraints.

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 action ('Generate embeddings') and resource ('text using Gemini embedding models'), making the tool's purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'generate_text' or 'analyze_image' beyond mentioning embeddings specifically, which is why it doesn't reach the highest score.

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 'generate_text' or 'count_tokens'. There's no mention of typical use cases for embeddings (e.g., semantic search, clustering) or when other tools might be more appropriate.

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

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