get_chains
Retrieve comprehensive blockchain network details including chain IDs, native tokens, stablecoins, and RPC configurations for EVM and Solana chains.
Instructions
List all supported chains (EVM + Solana) with their chain IDs, native tokens, stablecoins, and RPC configuration status.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:1192-1201 (handler)The complete get_chains tool implementation including registration, schema, and handler. The handler calls the API endpoint '/chains' and returns the JSON response containing supported chains with their IDs, native tokens, stablecoins, and RPC configuration status.
server.tool( 'get_chains', 'List all supported chains (EVM + Solana) with their chain IDs, native tokens, ' + 'stablecoins, and RPC configuration status.', {}, async () => { const data = await api('/chains'); return jsonResponse(data); }, ); - src/index.ts:164-166 (helper)Helper function used by the get_chains handler to format the API response as MCP tool output with proper content structure.
function jsonResponse(data: unknown) { return { content: [{ type: 'text' as const, text: JSON.stringify(data, null, 2) }] }; } - src/index.ts:45-75 (helper)Core API helper function used by the get_chains handler to make HTTP requests to the AgentWallet REST API. Handles authentication, error handling, and automatic x402 payment processing when needed.
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; }