get_usage
Retrieve current month's usage statistics including operations count, tier information, remaining quota, and fees for AI agent wallet infrastructure.
Instructions
Get the current month's usage statistics. Returns operations count, tier info, remaining quota, and fees.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:1138-1141 (handler)Handler function for get_usage tool that makes an API call to /usage endpoint and returns usage statistics (operations count, tier info, remaining quota, and fees)
async () => { const data = await api('/usage'); return jsonResponse(data); }, - src/index.ts:1137-1137 (schema)Input schema for get_usage tool - empty object indicating no parameters required
{}, - src/index.ts:1133-1142 (registration)Registration of get_usage tool with the MCP server, including tool name, description, schema, and handler
server.tool( 'get_usage', 'Get the current month\'s usage statistics. ' + 'Returns operations count, tier info, remaining quota, and fees.', {}, async () => { const data = await api('/usage'); return jsonResponse(data); }, ); - src/index.ts:45-75 (helper)API helper function used by get_usage to make authenticated HTTP requests to the AgentWallet REST API
async function api(path: string, method = 'GET', body?: Record<string, unknown>, extraHeaders?: Record<string, string>): Promise<unknown> { const url = `${API_BASE}${path}`; const headers: Record<string, string> = { 'Content-Type': 'application/json', ...extraHeaders, }; if (API_USER && API_PASS) { headers['Authorization'] = 'Basic ' + Buffer.from(`${API_USER}:${API_PASS}`).toString('base64'); } const options: RequestInit = { method, headers }; if (body && method !== 'GET') { options.body = JSON.stringify(body); } const res = await fetch(url, options); const data = await res.json(); // Handle 402 Payment Required — auto-pay if wallet configured if (res.status === 402 && X402_WALLET_ID && !extraHeaders?.['X-PAYMENT']) { return handleX402Payment(data as X402Response, path, method, body); } if (!res.ok) { const error = (data as { error?: string }).error || `HTTP ${res.status}`; throw new Error(error); } return data; } - src/index.ts:164-166 (helper)Helper function used by get_usage to format API responses as MCP tool responses
function jsonResponse(data: unknown) { return { content: [{ type: 'text' as const, text: JSON.stringify(data, null, 2) }] }; }