Skip to main content
Glama

get_transaction

Read-onlyIdempotent

Retrieve transaction details from EVM-compatible blockchains using a transaction hash, with network specification for accurate data access.

Instructions

Get transaction details by transaction hash

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
txHashYesTransaction hash (0x...)
networkNoNetwork name or chain ID. Defaults to Ethereum mainnet.

Implementation Reference

  • Registration of the MCP 'get_transaction' tool, including description, Zod input schema (txHash required, network optional), and the complete handler function that fetches and formats the transaction data.
      'get_transaction',
      'Get detailed information about a specific transaction by its hash. Includes sender, recipient, value, data, and more.',
      {
        txHash: z
          .string()
          .describe("The transaction hash to look up (e.g., '0x1234...')"),
        network: z
          .string()
          .optional()
          .describe(
            "Network name (e.g., 'ethereum', 'optimism', 'arbitrum', 'base', 'polygon') or chain ID. Defaults to Ethereum mainnet."
          )
      },
      async ({ txHash, network = 'ethereum' }) => {
        try {
          const tx = await services.getTransaction(txHash as Hash, network);
    
          return {
            content: [
              {
                type: 'text',
                text: services.helpers.formatJson(tx)
              }
            ]
          };
        } catch (error) {
          return {
            content: [
              {
                type: 'text',
                text: `Error fetching transaction ${txHash}: ${error instanceof Error ? error.message : String(error)}`
              }
            ],
            isError: true
          };
        }
      }
    );
  • Core helper function implementing the blockchain query for transaction details using viem's PublicClient. Called by the tool handler.
    export async function getTransaction(hash: Hash, network = 'ethereum') {
      const client = getPublicClient(network);
      return await client.getTransaction({ hash });
    }
  • Full helper function block with documentation for getTransaction, the underlying service used by the get_transaction tool.
    /**
     * Get a transaction by hash for a specific network
     */
    export async function getTransaction(hash: Hash, network = 'ethereum') {
      const client = getPublicClient(network);
      return await client.getTransaction({ hash });
    }
Behavior3/5

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

Annotations already cover key behavioral traits (readOnlyHint=true, destructiveHint=false, idempotentHint=true, openWorldHint=true), so the description doesn't need to repeat these. It adds minimal context by specifying the lookup mechanism ('by transaction hash'), but doesn't elaborate on rate limits, error handling, or response format, which could be helpful given 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.

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. Every part of the sentence ('Get transaction details by transaction hash') contributes directly to understanding the tool's function, making it optimally concise.

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 annotations provide safety and idempotency info, and the schema fully covers parameters, the description is adequate for a read-only lookup tool. However, with no output schema and multiple similar sibling tools (e.g., get_transaction_receipt), it could benefit from more context about return values or differentiation to be fully complete.

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?

With 100% schema description coverage, the input schema fully documents both parameters (txHash and network). The description mentions 'by transaction hash' which aligns with the txHash parameter but adds no additional semantic meaning beyond what the schema provides, meeting the baseline for 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 transaction details') and resource ('by transaction hash'), making the purpose immediately understandable. However, it doesn't explicitly differentiate this from sibling tools like 'get_transaction_receipt' or 'get_block', which would require a more specific distinction to earn a 5.

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 like 'get_transaction_receipt' or 'get_block' from the sibling list. It lacks context about prerequisites, typical use cases, or exclusions, leaving the agent to infer usage based on the name alone.

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/chulanpro5/evm-mcp-server'

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