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. Supports pagination and defaults to env USER_ADDRESS if no address is provided.

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
afterNoCursor for pagination - get results after this cursor (optional)
beforeNoCursor for pagination - get results before this cursor (optional)
limitNoNumber of transactions to return (optional, default: 25, max: 50)
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']

Implementation Reference

  • Main handler function for the get_portfolio_transactions tool. Processes input parameters, determines target addresses (using USER_ADDRESS if not provided), validates BETA limitations, calls the agService helper, and formats the 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", }, }; }
  • Input schema definition and tool metadata (name, description) for get_portfolio_transactions in the ListToolsRequestHandler response.
    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 of the tool handler in the CallToolRequestSchema switch statement, dispatching calls to toolService.getPortfolioTransactions.
    case TOOL_NAMES.GET_PORTFOLIO_TRANSACTIONS: result = await toolService.getPortfolioTransactions(args); break;
  • Helper function in AgService that makes the actual API call to the backend /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}`); } }
  • src/constants.js:41-41 (registration)
    Constant definition for the tool name used in registration.
    GET_PORTFOLIO_TRANSACTIONS: "get_portfolio_transactions",

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