usage
Check your SearchClaw API credit balance to monitor usage and manage costs for web search, extraction, and crawling operations.
Instructions
Check your SearchClaw API credit balance. Costs 0 credits.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:224-229 (registration)Registration of the 'usage' tool with MCP server. The tool takes no parameters and calls the /usage API endpoint to check credit balance.
server.tool( "usage", "Check your SearchClaw API credit balance. Costs 0 credits.", {}, async () => jsonResult(await apiGet("/usage")) ); - src/index.ts:20-39 (handler)Handler function that makes HTTP GET requests to the SearchClaw API. This is called by the usage tool to fetch credit balance data from /usage endpoint.
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 that formats API response data into MCP tool result format with JSON stringification.
function jsonResult(data: unknown) { return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] }; }