Skip to main content
Glama
gurveeer

MCP Server Gemini

by gurveeer

embed_text

Generate text embeddings using Gemini models to convert text into numerical vectors for analysis and processing.

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 main handler function for the embed_text tool. It calls the Gemini API to generate text embeddings and returns the embedding vector as JSON.
    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'
          }
        };
      }
    }
  • Zod schema defining the input parameters for the embed_text tool: required 'text' string and optional 'model' enum.
    embedText: z.object({
      text: z.string().min(1, 'Text is required'),
      model: z.enum(['text-embedding-004', 'text-multilingual-embedding-002']).optional()
    }),
  • Tool registration entry in the getAvailableTools() method, defining the tool's name, description, and input schema for MCP protocol.
    {
      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']
      }
    },
  • Dispatch case in handleToolCall switch statement that routes embed_text calls to the handler method.
    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?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the basic function but lacks details on rate limits, authentication needs, output format (e.g., vector dimensions), error handling, or performance characteristics. For a tool with no annotations, this leaves significant gaps in understanding its 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 directly states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded, making it easy to grasp quickly. Every part of the sentence earns its place by specifying the action, resource, and technology.

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?

Given the complexity (embedding generation with model selection), lack of annotations, and no output schema, the description is incomplete. It doesn't explain what embeddings are, their format, or practical applications, leaving the agent with insufficient context to use the tool effectively beyond basic invocation.

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%, so the schema already documents both parameters ('text' and 'model') with descriptions and enum values. The description adds no additional meaning beyond what the schema provides, such as explaining embedding use cases or model differences. Baseline 3 is appropriate when the schema does the heavy lifting.

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 ('for text using Gemini embedding models'), making the purpose immediately understandable. It distinguishes from siblings like 'analyze_image' or 'generate_text' by focusing on embeddings. However, it doesn't explicitly differentiate from 'count_tokens' which might be related, keeping it at 4 rather than 5.

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. It doesn't mention use cases for embeddings (e.g., semantic search, clustering) or when to choose it over other tools like 'generate_text' for similar text processing tasks. There's no explicit when/when-not or alternative tool references.

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

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