track_api_event
Record API usage events for analytics, tracking endpoints, status codes, and latency to monitor performance and usage patterns.
Instructions
Track an API usage event for analytics. Cost: $0.0001 USDC. Service: heatmap.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| api_key | Yes | ||
| endpoint | Yes | ||
| status_code | No | ||
| latency_ms | No |
Implementation Reference
- src/index.ts:166-223 (handler)The tool 'track_api_event' is dynamically resolved at runtime from a registry. The CallToolRequestSchema handler dynamically fetches the tool details and executes them using the callTool function.
server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; let registry: Registry; try { registry = await fetchRegistry(); } catch (error) { return { content: [ { type: "text", text: JSON.stringify({ error: "Failed to fetch tool registry", detail: String(error) }), }, ], }; } const tool = registry.tools.find((t) => t.name === name); if (!tool) { return { content: [ { type: "text", text: JSON.stringify({ error: `Tool '${name}' not found`, available_tools: registry.tools.map((t) => t.name), }), }, ], }; } try { const result = await callTool(tool, args as Record<string, unknown>); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: JSON.stringify({ error: "Tool call failed", tool: name, service: tool.service, detail: String(error), }), }, ], }; } });