Skip to main content
Glama

get-token-transfers

Retrieve ERC20 token transfer history for any Ethereum address to track transactions and monitor token movements on the blockchain.

Instructions

Get ERC20 token transfers for an Ethereum address

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYesEthereum address (0x format)
limitNoNumber of transfers to return (max 100)

Implementation Reference

  • Core implementation of getTokenTransfers that fetches and formats ERC20 token transfer data from the Etherscan API.
    async getTokenTransfers(address: string, limit: number = 10): Promise<TokenTransfer[]> {
      try {
        const validAddress = ethers.getAddress(address);
        
        // Get ERC20 token transfers
        const result = await fetch(
          `https://api.etherscan.io/api?module=account&action=tokentx&address=${validAddress}&page=1&offset=${limit}&sort=desc&apikey=${this.provider.apiKey}`
        );
        
        const data = await result.json();
        
        if (data.status !== "1" || !data.result) {
          throw new Error(data.message || "Failed to fetch token transfers");
        }
    
        // Format the results
        return data.result.slice(0, limit).map((tx: any) => ({
          token: tx.contractAddress,
          tokenName: tx.tokenName,
          tokenSymbol: tx.tokenSymbol,
          from: tx.from,
          to: tx.to,
          value: ethers.formatUnits(tx.value, parseInt(tx.tokenDecimal)),
          timestamp: parseInt(tx.timeStamp) || 0,
          blockNumber: parseInt(tx.blockNumber) || 0
        }));
      } catch (error) {
        if (error instanceof Error) {
          throw new Error(`Failed to get token transfers: ${error.message}`);
        }
        throw error;
      }
    }
  • MCP tool dispatch handler for 'get-token-transfers' that validates input, calls the service, formats output, and returns MCP response.
    if (name === "get-token-transfers") {
      try {
        const { address, limit } = TokenTransferSchema.parse(args);
        const transfers = await etherscanService.getTokenTransfers(address, limit);
        const formattedTransfers = transfers.map(tx => {
          const date = new Date(tx.timestamp * 1000).toLocaleString();
          return `Block ${tx.blockNumber} (${date}):\n` +
                 `Token: ${tx.tokenName} (${tx.tokenSymbol})\n` +
                 `From: ${tx.from}\n` +
                 `To: ${tx.to}\n` +
                 `Value: ${tx.value}\n` +
                 `Contract: ${tx.token}\n` +
                 `---`;
        }).join('\n');
    
        const response = transfers.length > 0
          ? `Recent token transfers for ${address}:\n\n${formattedTransfers}`
          : `No token transfers found for ${address}`;
    
        return {
          content: [{ type: "text", text: response }],
        };
      } catch (error) {
        if (error instanceof z.ZodError) {
          throw new Error(`Invalid input: ${error.errors.map(e => e.message).join(", ")}`);
        }
        throw error;
      }
    }
  • src/server.ts:91-111 (registration)
    Registers the 'get-token-transfers' tool in the MCP server's tool list with description and input schema.
    {
      name: "get-token-transfers",
      description: "Get ERC20 token transfers for an Ethereum address",
      inputSchema: {
        type: "object",
        properties: {
          address: {
            type: "string",
            description: "Ethereum address (0x format)",
            pattern: "^0x[a-fA-F0-9]{40}$"
          },
          limit: {
            type: "number",
            description: "Number of transfers to return (max 100)",
            minimum: 1,
            maximum: 100
          },
        },
        required: ["address"],
      },
    },
  • Zod schema for validating input parameters (address and optional limit) for the get-token-transfers tool.
    const TokenTransferSchema = z.object({
      address: z.string().regex(/^0x[a-fA-F0-9]{40}$/, 'Invalid Ethereum address format'),
      limit: z.number().min(1).max(100).optional(),
    });
  • TypeScript interface defining the structure of token transfer data returned by the service.
    export interface TokenTransfer {
      token: string;
      tokenName: string;
      tokenSymbol: string;
      from: string;
      to: string;
      value: string;
      timestamp: number;
      blockNumber: number;
    }
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 of behavioral disclosure. It states what the tool does but lacks critical details such as whether it's read-only, potential rate limits, authentication needs, or what the return format looks like (e.g., JSON structure, pagination). This is a significant gap for a data retrieval tool.

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, clear sentence with zero waste, front-loading the core functionality. It's appropriately sized and efficiently communicates the purpose without unnecessary details.

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 the complexity of Ethereum data retrieval, lack of annotations, and no output schema, the description is incomplete. It doesn't explain behavioral traits, return values, or usage context, making it inadequate for an agent to fully understand how to invoke and interpret results from this tool.

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 description implies parameters (an Ethereum address) but doesn't add meaning beyond the input schema, which has 100% coverage and fully documents both parameters. Since the schema does the heavy lifting, the baseline score of 3 is appropriate, as the description doesn't compensate or provide extra context.

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 verb 'Get' and resource 'ERC20 token transfers for an Ethereum address', making the purpose specific and understandable. However, it doesn't explicitly differentiate from sibling tools like 'get-transactions' or 'check-balance', which might also involve Ethereum address data retrieval, so it falls short of a perfect score.

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 no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'get-transactions' or 'check-balance', nor does it specify use cases or exclusions, leaving the agent without context for tool selection.

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/otc-ai/mcp-otc'

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