Skip to main content
Glama

search

Search the web and retrieve AI-synthesized answers, raw SERP results, or a combination of both. Choose from three modes to control output type and cost.

Instructions

Search the web. Returns AI-synthesized answers, raw SERP results, or both. Cost: serp 1 credit, ai 2 credits, deep 3 credits.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query
modeNoai (2 credits, synthesized answer), serp (1 credit, raw links), or deep (3 credits, both)ai
num_resultsNoMax results for serp/deep mode

Implementation Reference

  • Input schema definition for the 'search' tool, defining query (string), mode (optional string with default 'ai'), and num_results (optional number with default 10).
    const CAPABILITIES: CapabilityDef[] = [
      {
        name: "search",
        description: "Search the web. Returns AI-synthesized answers, raw SERP results, or both. Cost: serp 1 credit, ai 2 credits, deep 3 credits.",
        inputSchema: {
          query: z.string().describe("Search query"),
          mode: z.string().optional().default("ai").describe("ai (2 credits, synthesized answer), serp (1 credit, raw links), or deep (3 credits, both)"),
          num_results: z.number().optional().default(10).describe("Max results for serp/deep mode"),
        },
      },
      {
  • src/index.ts:247-259 (registration)
    Registration of the 'search' tool (and all other capabilities) via server.registerTool(). The loop iterates over CAPABILITIES and registers each with its name, description, inputSchema, and an async handler that delegates to callSuprsonic.
    for (const cap of CAPABILITIES) {
      // Cast inputSchema to avoid TS2589 (excessively deep type instantiation from Zod chains)
      server.registerTool(
        cap.name,
        {
          description: cap.description,
          inputSchema: cap.inputSchema as any,
        },
        async (args: any): Promise<CallToolResult> => {
          return callSuprsonic(cap.name, args as Record<string, unknown>);
        },
      );
    }
  • The callSuprsonic function is the actual handler for all tools including 'search'. It sends a POST request to the Suprsonic API with the capability name and params, then formats the response.
    async function callSuprsonic(capability: string, params: Record<string, unknown>): Promise<CallToolResult> {
      if (!API_KEY) {
        return {
          content: [{ type: "text", text: "Error: SUPRSONIC_API_KEY environment variable is not set. Get your key at https://suprsonic.ai/app/apis" }],
          isError: true,
        };
      }
    
      try {
        const resp = await fetch(`${BASE_URL}/v1/agent`, {
          method: "POST",
          headers: {
            "Authorization": `Bearer ${API_KEY}`,
            "Content-Type": "application/json",
          },
          body: JSON.stringify({ capability, params }),
        });
    
        const result = await resp.json() as any;
    
        // Handle non-envelope responses (401, 429, etc. return {"detail": ...})
        if (result.detail && result.success === undefined) {
          const msg = typeof result.detail === "object" ? (result.detail.title || result.detail.detail || JSON.stringify(result.detail)) : String(result.detail);
          return {
            content: [{ type: "text", text: `Error (HTTP ${resp.status}): ${msg}` }],
            isError: true,
          };
        }
    
        if (!result.success) {
          const errMsg = result.error?.detail || result.error?.title || "Request failed";
          return {
            content: [{ type: "text", text: `Error: ${errMsg}` }],
            isError: true,
          };
        }
    
        const text = JSON.stringify(result.data, null, 2);
        const meta = result.metadata
          ? `\n\n[Provider: ${(result.metadata as any).provider_used || "unknown"}, ${(result.metadata as any).response_time_ms || 0}ms, ${result.credits_used || 0} credits]`
          : "";
    
        return {
          content: [{ type: "text", text: text + meta }],
        };
      } catch (err) {
        return {
          content: [{ type: "text", text: `Network error: ${err instanceof Error ? err.message : String(err)}` }],
          isError: true,
        };
      }
    }
Behavior3/5

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

With no annotations, the description carries full burden. It discloses the return types (AI answer, SERP, both) and cost credits per mode, but lacks details on rate limits, caching, or permissions. Moderate transparency.

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?

Two sentences, front-loaded with key purpose. Each sentence provides essential info: first defines action and output types, second adds cost context. No wasted words.

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 no output schema and 3 parameters, the description covers modes, costs, and output types adequately. It could clarify 'AI-synthesized answers' but overall is complete for a search tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline is 3. The description adds value by explaining cost credits per mode and clarifying that num_results applies only to serp/deep modes. This goes beyond schema descriptions.

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 searches the web and returns AI-synthesized answers, raw SERP results, or both. The verb 'Search' and resource 'web' are specific, and the three modes are distinguished. This purpose is distinct from sibling tools like 'scrape' or 'images'.

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 (e.g., scrape, profiles). It explains mode selection but not use cases or prerequisites. Given many siblings, this is a significant gap.

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/O-mega-Enterprise/suprsonic-mcp'

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