consume_quota
Track and manage API rate limit usage by recording consumed quota for specific agents and API calls with micropayment integration.
Instructions
Consume rate limit quota after making an API call. Cost: $0.0005 USDC. Service: ratelord.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| agent_id | Yes | ||
| api_name | Yes | ||
| calls_used | No |
Implementation Reference
- src/index.ts:166-223 (handler)The tool "consume_quota" is not hardcoded, but dynamically registered and handled via a registry fetch in this handler. Any tool name, including "consume_quota", is handled here by looking it up in the fetched registry and calling the corresponding endpoint defined in the registry.
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), }), }, ], }; } });