getTokenPools
Identify liquidity pools for a specific token on supported networks. Filter and sort results by metrics like trading volume, price changes, or transactions to analyze token trading activity.
Instructions
Get liquidity pools containing a specific token on a network. Great for finding where a token is traded.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| address | No | Filter pools that contain this additional token address | |
| limit | No | Number of items per page (max 100) | |
| network | Yes | Network ID from getNetworks (e.g., "ethereum", "solana") | |
| orderBy | No | Field to order by | volume_usd |
| page | No | Page number for pagination | |
| reorder | No | If true, reorders the pool so that the specified token becomes the primary token for all metrics | |
| sort | No | Sort order | desc |
| tokenAddress | Yes | Token address or identifier |
Implementation Reference
- src/index.js:181-191 (handler)The asynchronous handler function that implements the core logic of the getTokenPools tool. It constructs the DexPaprika API endpoint based on input parameters and fetches/formats the data.async ({ network, tokenAddress, page, limit, sort, orderBy, reorder, address }) => { let endpoint = `/networks/${network}/tokens/${tokenAddress}/pools?page=${page}&limit=${limit}&sort=${sort}&order_by=${orderBy}`; if (reorder !== undefined) { endpoint += `&reorder=${reorder}`; } if (address) { endpoint += `&address=${encodeURIComponent(address)}`; } const data = await fetchFromAPI(endpoint); return formatMcpResponse(data); }
- src/index.js:171-180 (schema)Zod schema defining the input parameters and validation for the getTokenPools tool.{ network: z.string().describe('Network ID from getNetworks (e.g., "ethereum", "solana")'), tokenAddress: z.string().describe('Token address or identifier'), page: z.number().optional().default(0).describe('Page number for pagination'), limit: z.number().optional().default(10).describe('Number of items per page (max 100)'), sort: z.enum(['asc', 'desc']).optional().default('desc').describe('Sort order'), orderBy: z.enum(['volume_usd', 'price_usd', 'transactions', 'last_price_change_usd_24h', 'created_at']).optional().default('volume_usd').describe('Field to order by'), reorder: z.boolean().optional().describe('If true, reorders the pool so that the specified token becomes the primary token for all metrics'), address: z.string().optional().describe('Filter pools that contain this additional token address') },
- src/index.js:168-192 (registration)The server.tool() call that registers the getTokenPools tool with the MCP server, including name, description, input schema, and handler function.server.tool( 'getTokenPools', 'Get liquidity pools containing a specific token on a network. Great for finding where a token is traded.', { network: z.string().describe('Network ID from getNetworks (e.g., "ethereum", "solana")'), tokenAddress: z.string().describe('Token address or identifier'), page: z.number().optional().default(0).describe('Page number for pagination'), limit: z.number().optional().default(10).describe('Number of items per page (max 100)'), sort: z.enum(['asc', 'desc']).optional().default('desc').describe('Sort order'), orderBy: z.enum(['volume_usd', 'price_usd', 'transactions', 'last_price_change_usd_24h', 'created_at']).optional().default('volume_usd').describe('Field to order by'), reorder: z.boolean().optional().describe('If true, reorders the pool so that the specified token becomes the primary token for all metrics'), address: z.string().optional().describe('Filter pools that contain this additional token address') }, async ({ network, tokenAddress, page, limit, sort, orderBy, reorder, address }) => { let endpoint = `/networks/${network}/tokens/${tokenAddress}/pools?page=${page}&limit=${limit}&sort=${sort}&order_by=${orderBy}`; if (reorder !== undefined) { endpoint += `&reorder=${reorder}`; } if (address) { endpoint += `&address=${encodeURIComponent(address)}`; } const data = await fetchFromAPI(endpoint); return formatMcpResponse(data); } );
- src/index.js:10-34 (helper)Helper function to fetch data from the DexPaprika API, handling errors like rate limits and deprecated endpoints. Used by getTokenPools 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; } }
- src/index.js:37-46 (helper)Helper function to format API responses in MCP-compatible structure (text content with JSON). Used by getTokenPools handler.function formatMcpResponse(data) { return { content: [ { type: "text", text: JSON.stringify(data) } ] }; }