getNetworks
Retrieve all supported blockchain networks to identify available options before using network-specific cryptocurrency and DEX data functions.
Instructions
REQUIRED FIRST STEP: Get all supported blockchain networks. Always call this first to see available networks before using any network-specific functions. Returns network IDs like "ethereum", "solana", etc.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.js:72-80 (registration)Registration of the getNetworks tool with the MCP server. Includes tool name, description, empty input schema (no parameters), and inline handler function that fetches network data from the DexPaprika API and formats it for MCP response.server.tool( 'getNetworks', 'REQUIRED FIRST STEP: Get all supported blockchain networks. Always call this first to see available networks before using any network-specific functions. Returns network IDs like "ethereum", "solana", etc.', {}, async () => { const data = await fetchFromAPI('/networks'); return formatMcpResponse(data); } );
- src/index.js:76-79 (handler)The core handler function for the getNetworks tool. It calls the fetchFromAPI helper to retrieve the list of supported networks from '/networks' endpoint and uses formatMcpResponse to structure the output for the MCP protocol.async () => { const data = await fetchFromAPI('/networks'); return formatMcpResponse(data); }
- src/index.js:10-34 (helper)Shared helper function used by getNetworks (and other tools) to make HTTP requests to the DexPaprika API, with error handling for common issues like rate limits and deprecated endpoints.async function fetchFromAPI(endpoint) { try { const response = await fetch(`${API_BASE_URL}${endpoint}`); if (!response.ok) { if (response.status === 410) { throw new Error( 'This endpoint has been permanently removed. Please use network-specific endpoints instead. ' + 'For example, use /networks/{network}/pools instead of /pools. ' + 'Get available networks first using the getNetworks function.' ); } if (response.status === 429) { throw new Error( 'Rate limit exceeded. You have reached the maximum number of requests allowed for the free tier. ' + 'To increase your rate limits and access additional features, please consider upgrading to a paid plan at https://docs.dexpaprika.com/' ); } throw new Error(`API request failed with status ${response.status}`); } return await response.json(); } catch (error) { console.error(`Error fetching from API: ${error.message}`); throw error; } }
- src/index.js:37-46 (helper)Shared helper function used by getNetworks (and other tools) to format the API response data into the MCP protocol expected structure (text content with JSON string).function formatMcpResponse(data) { return { content: [ { type: "text", text: JSON.stringify(data) } ] }; }