getNetworks
Retrieve all supported blockchain networks to identify available options before using network-specific cryptocurrency 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:76-79 (handler)Handler function for the getNetworks tool. Fetches network data from the DexPaprika API endpoint '/networks' and formats it using formatMcpResponse.async () => { const data = await fetchFromAPI('/networks'); return formatMcpResponse(data); }
- src/index.js:75-75 (schema)Input schema for getNetworks tool: empty object indicating no input parameters are required.{},
- src/index.js:72-80 (registration)Registration of the getNetworks tool using McpServer's tool() method, including name, description, schema, and handler function.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:37-46 (helper)Helper function that formats the raw API response data into the MCP protocol response format, used by getNetworks and other tools.function formatMcpResponse(data) { return { content: [ { type: "text", text: JSON.stringify(data) } ] }; }
- src/index.js:10-34 (helper)Helper function to perform HTTP fetches to the DexPaprika API base URL, with error handling for rate limits and other issues, called by getNetworks handler.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; } }