Skip to main content
Glama
edkdev

DeFi Trading Agent MCP Server

by edkdev

get_portfolio_transactions

Retrieve transaction history for a wallet address on Ethereum and Base networks to analyze trading activity and portfolio changes.

Instructions

Get transaction history for a wallet address (BETA: 1 address, ETH/BASE only, uses USER_ADDRESS from env if addresses not provided)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressesNoArray with single address and networks (BETA limitation: 1 address, max 2 networks). Optional - uses USER_ADDRESS from env if not provided
networksNoNetwork identifiers to use with USER_ADDRESS (BETA: only eth-mainnet and base-mainnet supported). Only used when addresses not provided. Defaults to ['eth-mainnet', 'base-mainnet']
beforeNoCursor for pagination - get results before this cursor (optional)
afterNoCursor for pagination - get results after this cursor (optional)
limitNoNumber of transactions to return (optional, default: 25, max: 50)

Implementation Reference

  • Main handler function for get_portfolio_transactions tool. Processes input parameters, handles default user address and networks, validates BETA limitations, calls AgService, and returns formatted response with pagination info.
    async getPortfolioTransactions(params) {
      const { addresses, before, after, limit, networks } = params;
    
      // Use provided addresses or default to USER_ADDRESS with specified networks
      let targetAddresses;
      if (addresses && Array.isArray(addresses)) {
        targetAddresses = addresses;
      } else if (this.userAddress) {
        // Default to USER_ADDRESS with provided networks or BETA supported networks
        const defaultNetworks = networks || ["eth-mainnet", "base-mainnet"];
        targetAddresses = [
          {
            address: this.userAddress,
            networks: defaultNetworks,
          },
        ];
      } else {
        throw new Error(
          "Either addresses parameter or USER_ADDRESS environment variable is required"
        );
      }
    
      if (targetAddresses.length !== 1) {
        throw new Error(
          "Transactions API currently supports only 1 address (BETA limitation)"
        );
      }
    
      const result = await this.agg.getPortfolioTransactions(targetAddresses, {
        before,
        after,
        limit,
      });
    
      return {
        message: "Portfolio transactions retrieved successfully",
        data: result,
        summary: `Retrieved ${
          result.transactions?.length || 0
        } transactions for address ${targetAddresses[0].address}`,
        addressUsed: targetAddresses[0].address,
        pagination: {
          limit: limit || 25,
          before: result.before,
          after: result.after,
          totalCount: result.totalCount,
        },
        beta: {
          limitations:
            "Currently supports 1 address and max 2 networks (eth-mainnet, base-mainnet)",
          note: "This endpoint is in BETA with limited functionality",
        },
      };
    }
  • MCP tool schema definition including inputSchema with validation for addresses, networks (BETA limits), pagination parameters. Part of the tools list returned by listTools.
    name: TOOL_NAMES.GET_PORTFOLIO_TRANSACTIONS,
    description:
      "Get transaction history for a wallet address (BETA: 1 address, ETH/BASE only, uses USER_ADDRESS from env if addresses not provided)",
    inputSchema: {
      type: "object",
      properties: {
        addresses: {
          type: "array",
          description:
            "Array with single address and networks (BETA limitation: 1 address, max 2 networks). Optional - uses USER_ADDRESS from env if not provided",
          items: {
            type: "object",
            properties: {
              address: {
                type: "string",
                description: "Wallet address",
              },
              networks: {
                type: "array",
                items: {
                  type: "string",
                  enum: ["eth-mainnet", "base-mainnet"],
                },
                description:
                  "Network identifiers (BETA: only eth-mainnet and base-mainnet supported)",
              },
            },
            required: ["address", "networks"],
          },
          maxItems: 1,
        },
        networks: {
          type: "array",
          items: {
            type: "string",
            enum: ["eth-mainnet", "base-mainnet"],
          },
          description:
            "Network identifiers to use with USER_ADDRESS (BETA: only eth-mainnet and base-mainnet supported). Only used when addresses not provided. Defaults to ['eth-mainnet', 'base-mainnet']",
        },
        before: {
          type: "string",
          description:
            "Cursor for pagination - get results before this cursor (optional)",
        },
        after: {
          type: "string",
          description:
            "Cursor for pagination - get results after this cursor (optional)",
        },
        limit: {
          type: "integer",
          description:
            "Number of transactions to return (optional, default: 25, max: 50)",
          minimum: 1,
          maximum: 50,
        },
      },
      required: [],
    },
  • src/index.js:1170-1172 (registration)
    Registration/dispatch handler in the main switch statement that routes calls to get_portfolio_transactions to the toolService method.
    case TOOL_NAMES.GET_PORTFOLIO_TRANSACTIONS:
      result = await toolService.getPortfolioTransactions(args);
      break;
  • Helper function in AgService that makes the actual API POST request to the aggregator's /api/portfolio/transactions endpoint.
    async getPortfolioTransactions(addresses, options = {}) {
      try {
        const requestBody = {
          addresses,
          before: options.before,
          after: options.after,
          limit: options.limit
        };
    
        // Remove undefined values
        Object.keys(requestBody).forEach(key => {
          if (requestBody[key] === undefined) {
            delete requestBody[key];
          }
        });
    
        const response = await fetch(`${this.baseUrl}/api/portfolio/transactions`, {
          method: 'POST',
          headers: {
            'Content-Type': 'application/json'
          },
          body: JSON.stringify(requestBody)
        });
        
        if (!response.ok) {
          throw new Error(`HTTP ${response.status}: ${response.statusText}`);
        }
        
        const data = await response.json();
        
        if (!data.success) {
          throw new Error(data.error || 'Portfolio transactions request failed');
        }
        
        return data.data;
      } catch (error) {
        throw new Error(`Failed to get portfolio transactions: ${error.message}`);
      }
    }
  • Constant definition mapping the tool name constant to the string 'get_portfolio_transactions' used throughout the codebase.
    GET_PORTFOLIO_TRANSACTIONS: "get_portfolio_transactions",
Behavior3/5

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

With no annotations provided, the description carries the full burden. It discloses BETA limitations (single address, specific networks) and the fallback to environment variables, which are useful behavioral traits. However, it doesn't cover other important aspects like rate limits, authentication needs, error handling, or what the return format looks like (since there's no output schema).

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

Conciseness4/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 and includes key constraints. Every part earns its place, though it could be slightly more structured (e.g., separating purpose from limitations).

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

Completeness3/5

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

Given the complexity (5 parameters, no annotations, no output schema), the description is moderately complete. It covers the core purpose and key constraints but lacks details on return values, error cases, or deeper behavioral context. The schema handles parameter documentation well, but the description doesn't fully compensate for the absence of annotations and output schema.

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?

The schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds minimal value beyond the schema by mentioning the BETA limitation and USER_ADDRESS fallback, which are partially covered in the schema descriptions. It doesn't provide additional syntax, format details, or usage examples beyond what's in the schema.

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

Purpose5/5

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

The description clearly states the verb ('Get') and resource ('transaction history for a wallet address'), making the purpose specific. It distinguishes from sibling tools like get_portfolio_balances or get_portfolio_tokens by focusing on transactions rather than balances or token holdings.

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

Usage Guidelines4/5

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

The description provides clear context about BETA limitations (1 address, ETH/BASE only) and fallback behavior (uses USER_ADDRESS from env if addresses not provided). However, it doesn't explicitly state when to use this tool versus alternatives like get_portfolio_balances or other transaction-related tools, nor does it mention exclusions.

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