get_liquidity_sources
Retrieve a list of liquidity sources for a specific blockchain chain ID to enable informed DeFi trading decisions and optimize asset allocation.
Instructions
Get list of liquidity sources available on a specific chain
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chainId | Yes | Blockchain ID to get sources for |
Input Schema (JSON Schema)
{
"properties": {
"chainId": {
"description": "Blockchain ID to get sources for",
"type": "integer"
}
},
"required": [
"chainId"
],
"type": "object"
}
Implementation Reference
- src/index.js:181-195 (schema)MCP tool schema definition for 'get_liquidity_sources' including input validation requiring chainId (integer). Part of tools array registered with server.setTools(){ name: TOOL_NAMES.GET_LIQUIDITY_SOURCES, description: "Get list of liquidity sources available on a specific chain", inputSchema: { type: "object", properties: { chainId: { type: "integer", description: "Blockchain ID to get sources for", }, }, required: ["chainId"], }, },
- src/index.js:1000-1002 (registration)Tool dispatch/registration in MCP request handler switch statement that routes 'get_liquidity_sources' calls to toolService.getLiquiditySources(chainId).case TOOL_NAMES.GET_LIQUIDITY_SOURCES: result = await toolService.getLiquiditySources(args.chainId); break;
- src/toolService.js:121-133 (handler)Primary handler function for 'get_liquidity_sources' tool. Validates input, delegates to agService, and formats the response with message, data, and summary.async getLiquiditySources(chainId) { if (!chainId) { throw new Error("chainId is required"); } const result = await this.agg.getLiquiditySources(chainId); return { message: `Liquidity sources for chain ${chainId} retrieved successfully`, data: result, summary: `Found ${result.sources?.length || 0} liquidity sources`, }; }
- src/services/agService.js:97-115 (helper)Core helper/utility function that performs HTTP fetch to aggregator API endpoint /api/swap/sources?chainId={chainId} to retrieve liquidity sources data.async getLiquiditySources(chainId) { try { const response = await fetch(`${this.baseUrl}/api/swap/sources?chainId=${chainId}`); if (!response.ok) { throw new Error(`HTTP ${response.status}: ${response.statusText}`); } const data = await response.json(); if (!data.success) { throw new Error(data.error || 'API request failed'); } return data.data; } catch (error) { throw new Error(`Failed to get liquidity sources: ${error.message}`); } }
- src/constants.js:8-8 (helper)Constant definition mapping symbolic name TOOL_NAMES.GET_LIQUIDITY_SOURCES to tool name string 'get_liquidity_sources' used in registration and dispatch.GET_LIQUIDITY_SOURCES: "get_liquidity_sources",