Skip to main content
Glama
ac3xx
by ac3xx

kagi_search

Execute web searches via Kagi’s API, enabling precise results retrieval using query parameters and customizable limits for efficient data access.

Instructions

Perform web search using Kagi

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNo
queryYes

Implementation Reference

  • The MCP tool handler for 'kagi_search' that validates arguments (query string required, limit 1-100 optional), constructs SearchParams, calls KagiAPI.search, and returns results or handles KagiError.
    if (request.params.name === "kagi_search") { if (!request.params.arguments || typeof request.params.arguments !== 'object') { throw new McpError(ErrorCode.InvalidParams, "Invalid arguments for kagi_search"); } const { query, limit } = request.params.arguments as { query?: unknown; limit?: unknown }; if (typeof query !== 'string') { throw new McpError(ErrorCode.InvalidParams, "Query must be a string"); } const searchParams: SearchParams = { q: query, }; if (limit !== undefined) { if (typeof limit !== 'number' || limit < 1 || limit > 100) { throw new McpError(ErrorCode.InvalidParams, "Limit must be a number between 1 and 100"); } searchParams.limit = limit; } try { const results = await this.kagiApi.search(searchParams); return { toolResult: results }; } catch (error) { if (error instanceof KagiError) { return { content: [{ type: "text", text: `Kagi API error: ${error.message}` }], isError: true, }; } throw error; } }
  • Tool metadata and input schema definition for 'kagi_search', used in tool listing and validation.
    const searchTool = { name: "kagi_search", description: "Perform web search using Kagi", inputSchema: { type: "object", properties: { query: { type: "string" }, limit: { type: "number", default: 10, minimum: 1, maximum: 100 } }, required: ["query"] } };
  • src/index.ts:79-83 (registration)
    Registers the 'kagi_search' tool by returning it in the MCP ListToolsRequest handler.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [searchTool] }; });
  • Core implementation of the search functionality in KagiAPI, making HTTP GET to Kagi's /search endpoint with query and limit parameters.
    async search(params: SearchParams): Promise<SearchResponse> { const response = await this.client.get<SearchResponse>('/search', { params: { q: params.q, limit: params.limit || 10 } }); return response.data; }
  • TypeScript interface defining the SearchParams used by the kagi_search tool and API.
    export interface SearchParams { /** Search query string */ q: string; /** Maximum number of results to return */ limit?: number; }

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/ac3xx/mcp-servers-kagi'

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