Skip to main content
Glama
PV-Bhat

GemForge-Gemini-Tools-MCP

gemini_search

Retrieve accurate answers and verify facts by leveraging Gemini 2.0 Flash and Google Search integration. Ideal for general knowledge queries, fact-checking, and detailed information retrieval.

Instructions

Generates responses based on the latest information using Gemini 2.0 Flash and Google Search. Best for general knowledge questions, fact-checking, and information retrieval.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
enable_thinkingNoEnable thinking mode for step-by-step reasoning
file_pathNoOptional file path to include with the query
model_idNoOptional model ID override (advanced users only)
queryYesYour search query or question

Implementation Reference

  • Core handler function that implements the gemini_search tool. Validates input, selects Gemini 2.0 Flash model, constructs SDK request with Google Search tool, executes API call, and formats response.
    export async function handleDirectSearchAlt(request: any) {
      try {
        // Validate required parameters
        if (!request.params.arguments || typeof request.params.arguments.query !== 'string') {
          throw new McpError(
            ErrorCode.InvalidParams,
            'Query parameter is required and must be a string'
          );
        }
    
        // Extract arguments as SearchArgs
        const args = request.params.arguments as SearchArgs;
        const { query, file_path, model_id } = args;
    
        if (file_path) {
          console.error(`[handleDirectSearchAlt] Received file_path: ${typeof file_path === 'string' ? file_path : JSON.stringify(file_path)}`);
          console.error(`[handleDirectSearchAlt] File path exists check: ${await fileExists(typeof file_path === 'string' ? file_path : file_path[0])}`);
        }
    
        // Select the model using the tool-specific model selector
        const targetModelId = model_id || 'gemini-2.0-flash-001';
        console.error(`[handleDirectSearchAlt] Using model: ${targetModelId}`);
    
        try {
          // Create the model instance
          const model = genAI.getGenerativeModel({ model: targetModelId });
    
          // Build a request that works with Flash models (no system role)
          // This exact format has been verified to work with gemini-2.0-flash-001
          const sdkRequest: any = {
            contents: [{
              role: 'user',
              parts: [{
                text: query
              }]
            }],
            systemInstruction: "You have access to Google Search. You MUST use Google Search for ALL queries to provide accurate, up-to-date information. Do not rely solely on your training data.",
            generationConfig: {
              temperature: 0.7,
              topP: 0.8,
              topK: 40
            },
            tools: [{
              googleSearch: {}
            }],
            toolConfig: {
              functionCallingConfig: {
                mode: "AUTO"
              }
            }
          };
    
          console.error(`[handleDirectSearchAlt] Sending request to ${targetModelId}`);
          
          // Send request to Gemini API
          const result = await model.generateContent(sdkRequest);
          const response = result.response;
          console.error(`[handleDirectSearchAlt] SDK Response received from ${targetModelId}`);
    
          // Extract text from response
          let responseText = "";
          try {
            responseText = response.text();
          } catch (e) {
            console.error(`[handleDirectSearchAlt] Error extracting text:`, e);
            if (response.candidates && response.candidates.length > 0 && 
                response.candidates[0].content && 
                response.candidates[0].content.parts && 
                response.candidates[0].content.parts.length > 0) {
              responseText = response.candidates[0].content.parts[0].text || "";
            }
          }
    
          // Create a simple response object
          return {
            content: [
              {
                type: 'text',
                text: responseText
              }
            ]
          };
        } catch (apiError) {
          console.error('API error in direct search handler:', apiError);
          if (apiError instanceof McpError) {
            throw apiError;
          }
          throw apiError;
        }
      } catch (error) {
        console.error('Error in direct search handler:', error);
        if (error instanceof McpError) {
          throw error;
        }
        return {
          content: [
            {
              type: 'text',
              text: `Error: ${error instanceof Error ? error.message : 'Unknown error'}`
            }
          ],
          isError: true
        };
      }
    }
  • src/index.ts:206-228 (registration)
    Tool dispatch switch statement that registers and routes 'gemini_search' (both canonical TOOL_NAMES.GEM_SEARCH and legacy name) to the handleDirectSearchAlt handler.
    switch (request.params.name) {
      case TOOL_NAMES.GEM_SEARCH:
        // Use the alternative direct search handler that works with Flash models
        return await handleDirectSearchAlt(request);
      case TOOL_NAMES.GEM_REASON:
        return await handleReason(request);
      case TOOL_NAMES.GEM_CODE:
        return await handleCode(request);
      case TOOL_NAMES.GEM_FILEOPS:
        return await handleFileops(request);
      // Support legacy tool names for backward compatibility
      case 'gemini_search':
        // Use the alternative direct search handler that works with Flash models
        return await handleDirectSearchAlt(request);
      case 'gemini_reason':
        return await handleReason(request);
      default:
        console.error(`Unknown tool requested: ${request.params.name}`);
        throw new McpError(
          ErrorCode.MethodNotFound,
          `Unknown tool: ${request.params.name}. Available tools: gemini_search, gemini_reason, gemini_code, gemini_fileops`
        );
    }
  • Input schema and description for the gemini_search tool, provided in the ListTools MCP response.
    {
      name: TOOL_NAMES.GEM_SEARCH,
      description: 'Generates responses based on the latest information using Gemini 2.0 Flash and Google Search. Best for general knowledge questions, fact-checking, and information retrieval.',
      inputSchema: {
        type: 'object',
        properties: {
          query: {
            type: 'string',
            description: 'Your search query or question'
          },
          file_path: {
            type: 'string',
            description: 'Optional file path to include with the query'
          },
          model_id: {
            type: 'string',
            description: 'Optional model ID override (advanced users only)'
          },
          enable_thinking: {
            type: 'boolean',
            description: 'Enable thinking mode for step-by-step reasoning'
          }
        },
        required: ['query'],
      },
    },
  • Constants defining tool names, including GEM_SEARCH: 'gemini_search' and legacy aliases used throughout the codebase.
    export const TOOL_NAMES = {
      // New specialized toolset
      GEM_SEARCH: 'gemini_search',    // For search-enabled queries (Gemini 2.0 Flash)
      GEM_REASON: 'gemini_reason',    // For complex reasoning (Gemini 2.5 Flash/Pro)
      GEM_CODE: 'gemini_code',        // For coding tasks (Gemini 2.5 Pro)
      GEM_FILEOPS: 'gemini_fileops',  // For file operations (Gemini 2.0 Flash-Lite/1.5 Pro)
    
      // Legacy names for backward compatibility - only keeping what's needed
      SEARCH: 'gemini_search',
      REASON: 'gemini_reason',
      ANALYZE_FILE: 'gemini_analyze',
      RAPID_SEARCH: 'gemini_search'
    };
  • TypeScript interface defining the input arguments for the gemini_search tool.
    /**
     * Arguments for gemini_search tool
     */
    export interface SearchArgs extends BaseArgs, FileInput {
        /** The search query */
        query: string;
        /** Whether to enable thinking mode */
        enable_thinking?: boolean;
    }
Behavior3/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 mentions the technology ('Gemini 2.0 Flash and Google Search') and use cases, but lacks details on rate limits, authentication needs, response format, or potential side effects. It adequately describes the core function but misses operational context that would help an agent invoke it effectively.

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 front-loaded with the core purpose in the first sentence, followed by usage guidance. Every sentence earns its place by adding value without redundancy. It's appropriately sized for a tool with clear functionality and good schema coverage.

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

Completeness4/5

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

Given the tool's moderate complexity (4 parameters, no output schema, no annotations), the description is reasonably complete. It covers purpose and usage well but lacks details on behavioral aspects like response format or error handling. With no output schema, it could benefit from mentioning what the tool returns, but the clarity of purpose compensates somewhat.

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 all parameters thoroughly. The description adds no parameter-specific information beyond implying the 'query' parameter's purpose through context. This meets the baseline of 3 since the schema handles parameter documentation adequately.

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 clearly states the tool's purpose with specific verbs ('Generates responses') and resources ('using Gemini 2.0 Flash and Google Search'), and distinguishes it from siblings by specifying its domain ('general knowledge questions, fact-checking, and information retrieval'). It goes beyond a tautology by explaining the technology stack and use cases.

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

Usage Guidelines5/5

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

The description explicitly states when to use this tool ('Best for general knowledge questions, fact-checking, and information retrieval'), which implicitly suggests alternatives (e.g., use gemini_code for coding tasks, gemini_reason for reasoning-heavy queries). This provides clear context for selection among siblings without needing explicit 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/PV-Bhat/GemForge-MCP'

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