Skip to main content
Glama

suggest

Generate autocomplete suggestions for search queries to improve search accuracy and discover related terms.

Instructions

Get autocomplete suggestions for a search query using SearchClaw. Costs 1 credit.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
qYesPartial query for autocomplete suggestions

Implementation Reference

  • The 'suggest' tool handler is an async function that takes a 'q' parameter (partial query) and calls the SearchClaw API's /suggest endpoint via apiGet, then wraps the result with jsonResult.
    server.tool(
      "suggest",
      "Get autocomplete suggestions for a search query using SearchClaw. Costs 1 credit.",
      { q: z.string().describe("Partial query for autocomplete suggestions") },
      async ({ q }) => jsonResult(await apiGet("/suggest", { q }))
    );
  • Input schema for the 'suggest' tool - validates that 'q' is a required string parameter representing the partial query for autocomplete suggestions.
    { q: z.string().describe("Partial query for autocomplete suggestions") },
  • src/index.ts:100-105 (registration)
    The 'suggest' tool is registered with the MCP server using server.tool(), providing the tool name, description, input schema, and handler function.
    server.tool(
      "suggest",
      "Get autocomplete suggestions for a search query using SearchClaw. Costs 1 credit.",
      { q: z.string().describe("Partial query for autocomplete suggestions") },
      async ({ q }) => jsonResult(await apiGet("/suggest", { q }))
    );
  • Helper function that makes GET requests to the SearchClaw API. Used by the 'suggest' tool to call the /suggest endpoint with query parameters.
    async function apiGet(path: string, params?: Record<string, string>) {
      const url = new URL(`${API_BASE}${path}`);
      if (params) {
        for (const [key, value] of Object.entries(params)) {
          url.searchParams.set(key, value);
        }
      }
      const controller = new AbortController();
      const timeout = setTimeout(() => controller.abort(), 30000);
      try {
        const response = await fetch(url.toString(), { headers, signal: controller.signal });
        if (!response.ok) {
          const text = await response.text();
          throw new Error(`SearchClaw API error ${response.status}: ${text}`);
        }
        return response.json();
      } finally {
        clearTimeout(timeout);
      }
    }
  • Helper function that formats API response data into the MCP tool result format with JSON stringification.
    function jsonResult(data: unknown) {
      return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] };
    }

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/CSteenkamp/searchclaw-mcp'

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