Skip to main content
Glama

serpex_search

Search the web using multiple search engines through Serpex API. Get structured results from Google, Bing, DuckDuckGo, Brave, Yahoo, and Yandex with time filtering options.

Instructions

Search the web using Serpex API. Returns structured search results from multiple engines (Google, Bing, DuckDuckGo, Brave, Yahoo, Yandex).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
qYesSearch query (max 500 characters)
engineNoSearch engine (default: auto)
time_rangeNoFilter by time range

Implementation Reference

  • The primary handler function that executes the serpex_search tool logic. It constructs the API request to Serpex, fetches search results, formats them into JSON, and returns as MCP tool content. Handles errors gracefully.
    private async handleSearch(params: SearchParams) {
      try {
        if (!params.q || params.q.trim().length === 0) {
          throw new Error('Query is required');
        }
    
        const response = await this.axiosInstance.get<SerpexResponse>('/api/search', {
          params: {
            q: params.q,
            engine: params.engine || 'auto',
            category: 'web',
            time_range: params.time_range || 'all',
            format: 'json',
          },
        });
    
        const data = response.data;
        
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify({
                query: data.query,
                engines: data.engines,
                total_results: data.metadata.number_of_results,
                results: data.results.map(r => ({
                  title: r.title,
                  url: r.url,
                  snippet: r.snippet,
                  position: r.position,
                  engine: r.engine,
                })),
                suggestions: data.suggestions,
              }, null, 2),
            },
          ],
        };
      } catch (error) {
        if (axios.isAxiosError(error)) {
          const msg = error.response?.data?.error || error.message;
          return {
            content: [{ type: 'text', text: `Search failed: ${msg}` }],
            isError: true,
          };
        }
        throw error;
      }
    }
  • src/index.ts:90-113 (registration)
    Registration of the serpex_search tool in the ListTools handler, including name, description, and input schema.
        name: 'serpex_search',
        description: 'Search the web using Serpex API. Returns structured search results from multiple engines (Google, Bing, DuckDuckGo, Brave, Yahoo, Yandex).',
        inputSchema: {
          type: 'object',
          properties: {
            q: {
              type: 'string',
              description: 'Search query (max 500 characters)',
            },
            engine: {
              type: 'string',
              description: 'Search engine (default: auto)',
              enum: ['auto', 'google', 'bing', 'duckduckgo', 'brave', 'yahoo', 'yandex'],
            },
            time_range: {
              type: 'string',
              description: 'Filter by time range',
              enum: ['all', 'day', 'week', 'month', 'year'],
            },
          },
          required: ['q'],
        },
      },
    ],
  • Input schema definition for the serpex_search tool, specifying parameters q (required), engine, and time_range.
    inputSchema: {
      type: 'object',
      properties: {
        q: {
          type: 'string',
          description: 'Search query (max 500 characters)',
        },
        engine: {
          type: 'string',
          description: 'Search engine (default: auto)',
          enum: ['auto', 'google', 'bing', 'duckduckgo', 'brave', 'yahoo', 'yandex'],
        },
        time_range: {
          type: 'string',
          description: 'Filter by time range',
          enum: ['all', 'day', 'week', 'month', 'year'],
        },
      },
      required: ['q'],
    },
  • src/index.ts:116-147 (registration)
    Dispatch logic in the CallToolRequestSchema handler that validates arguments for serpex_search and invokes the handleSearch function.
      this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
        if (request.params.name !== 'serpex_search') {
          throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${request.params.name}`);
        }
    
        if (!request.params.arguments) {
          throw new McpError(ErrorCode.InvalidParams, 'Arguments are required');
        }
    
        const args = request.params.arguments as Record<string, unknown>;
        
        // Validate required parameter
        if (!args.q || typeof args.q !== 'string') {
          throw new McpError(ErrorCode.InvalidParams, 'Query parameter "q" is required and must be a string');
        }
    
        // Build typed params
        const searchParams: SearchParams = {
          q: args.q as string,
        };
    
        if (args.engine && typeof args.engine === 'string') {
          searchParams.engine = args.engine as SearchParams['engine'];
        }
    
        if (args.time_range && typeof args.time_range === 'string') {
          searchParams.time_range = args.time_range as SearchParams['time_range'];
        }
    
        return await this.handleSearch(searchParams);
      });
    }
  • TypeScript interfaces defining the structure for search parameters, results, metadata, and Serpex API response, used for type safety in the handler.
    interface SearchParams {
      q: string;
      engine?: 'auto' | 'google' | 'bing' | 'duckduckgo' | 'brave' | 'yahoo' | 'yandex';
      category?: 'web';
      time_range?: 'all' | 'day' | 'week' | 'month' | 'year';
      format?: 'json';
    }
    
    interface SearchResult {
      title: string;
      url: string;
      snippet: string;
      position: number;
      engine: string;
      published_date: string | null;
    }
    
    interface SearchMetadata {
      number_of_results: number;
      response_time: number;
      timestamp: string;
      credits_used: number;
    }
    
    interface SerpexResponse {
      metadata: SearchMetadata;
      id: string;
      query: string;
      engines: string[];
      results: SearchResult[];
      answers: any[];
      suggestions: string[];
    }
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 mentions the API and return type (structured results from multiple engines), but fails to disclose critical traits such as rate limits, authentication needs, error handling, or pagination. For a search tool with no annotation coverage, 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 front-loads the core purpose ('Search the web using Serpex API') and adds necessary detail ('Returns structured search results from multiple engines'). Every word earns its place with no redundancy or waste.

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 of a search API tool with no annotations and no output schema, the description is incomplete. It lacks information on response format, error cases, rate limits, and authentication requirements. While the input schema is well-covered, the overall context for effective tool use is insufficient.

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?

The schema description coverage is 100%, with all parameters well-documented in the input schema (e.g., query max length, engine options, time range enums). The description adds no additional parameter semantics beyond what the schema provides, so it meets the baseline of 3 for high schema coverage without compensating value.

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 ('Search the web') and resource ('using Serpex API'), specifying it returns structured results from multiple engines. It's specific about the verb and resource, but since there are no sibling tools, it doesn't need to distinguish from alternatives, making it clear but not requiring sibling differentiation.

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

Usage Guidelines3/5

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

The description implies usage for web searching with structured results from multiple engines, but provides no explicit guidance on when to use this tool versus alternatives (e.g., other search methods or APIs). Since there are no sibling tools, it doesn't need to differentiate, but it lacks context on optimal use cases 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

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/divyeshradadiya/serpex-mcp'

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