Skip to main content
Glama
edkdev

DeFi Trading Agent MCP Server

by edkdev

get_liquidity_sources

Retrieve available liquidity sources for a specific blockchain to identify trading opportunities and execute DeFi transactions.

Instructions

Get list of liquidity sources available on a specific chain

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chainIdYesBlockchain ID to get sources for

Implementation Reference

  • MCP tool schema definition including name, description, and input schema requiring chainId.
    {
      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)
    Registration and dispatch in the MCP CallToolRequestHandler switch statement.
    case TOOL_NAMES.GET_LIQUIDITY_SOURCES:
      result = await toolService.getLiquiditySources(args.chainId);
      break;
  • ToolService handler that validates chainId, delegates to AgService.getLiquiditySources, and wraps the response with metadata.
    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 AgService handler implementing the HTTP fetch to the aggregator API endpoint /api/swap/sources.
    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 of the tool name used throughout the codebase.
    GET_LIQUIDITY_SOURCES: "get_liquidity_sources",
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It states the tool retrieves a list but lacks details on behavioral traits such as rate limits, authentication needs, pagination, error handling, or what 'liquidity sources' entails (e.g., types, formats, or freshness). This is a significant gap for a tool with no annotation coverage, making it inadequate for informed agent use.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose without unnecessary words. It directly states what the tool does and its scope, with zero waste or redundancy, making it highly concise and well-structured for quick understanding.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations, no output schema, and a simple input schema, the description is incomplete. It lacks crucial context like what the output includes (e.g., list format, data fields), behavioral constraints, or how it fits among siblings. For a tool in a complex DeFi context with many related tools, this minimal description fails to provide sufficient guidance for effective agent use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with the single parameter 'chainId' documented as 'Blockchain ID to get sources for'. The description adds no additional meaning beyond this, such as valid chain IDs or examples. Since the schema fully covers the parameter, the baseline score of 3 is appropriate, as the description doesn't compensate but also doesn't need to given high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Get list') and resource ('liquidity sources'), specifying the scope ('available on a specific chain'). It distinguishes from siblings like get_supported_chains or get_gasless_chains by focusing on liquidity sources rather than chain metadata or gasless features. However, it doesn't explicitly differentiate from tools like get_multiple_pools_data or get_top_pools_by_dex, which might overlap in purpose.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides minimal guidance, only indicating to use it for getting liquidity sources on a specific chain. It offers no explicit when-to-use vs. alternatives, prerequisites, or exclusions. For example, it doesn't clarify when to prefer this over get_supported_dexes or get_top_pools_by_token, leaving usage context implied rather than stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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