search
Perform web searches to find relevant information using SearchClaw's API. This tool retrieves organic search results for any query to support research and data gathering tasks.
Instructions
Search the web using SearchClaw. Returns organic web results. Costs 1 credit.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| q | Yes | Search query |
Implementation Reference
- src/index.ts:72-77 (handler)The 'search' tool handler that takes a query parameter 'q' and returns organic web search results from the SearchClaw API via GET request to /search endpoint
server.tool( "search", "Search the web using SearchClaw. Returns organic web results. Costs 1 credit.", { q: z.string().describe("Search query") }, async ({ q }) => jsonResult(await apiGet("/search", { q })) ); - src/index.ts:75-75 (schema)Input schema for the 'search' tool - accepts a single string parameter 'q' representing the search query
{ q: z.string().describe("Search query") }, - src/index.ts:72-77 (registration)Registration of the 'search' tool with the MCP server using server.tool() method
server.tool( "search", "Search the web using SearchClaw. Returns organic web results. Costs 1 credit.", { q: z.string().describe("Search query") }, async ({ q }) => jsonResult(await apiGet("/search", { q })) ); - src/index.ts:20-39 (helper)Helper function for making GET requests to the SearchClaw API with query parameters, timeout handling, and error management
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); } } - src/index.ts:61-63 (helper)Helper function to format API response data as MCP tool result with JSON formatting
function jsonResult(data: unknown) { return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] }; }