Skip to main content
Glama

DeFi Trading Agent MCP Server

by edkdev

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

NameRequiredDescriptionDefault
chainIdYesBlockchain 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

  • 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;
  • 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`, }; }
  • 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}`); } }
  • 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",

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/edkdev/defi-trading-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server