Skip to main content
Glama

get-transaction

Retrieve blockchain transaction details using hash and chain ID with a MetaMask-integrated tool, enabling secure and direct interaction with blockchain data.

Instructions

Fetch transaction given hash or block identifiers.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chainIdNoID of chain to use when fetching data.
hashYesHash to get transaction.

Implementation Reference

  • The execute handler for the get-transaction tool. Fetches the transaction using wagmi's getTransaction with the wagmi config and args, stringifies the result using JSONStringify, and returns it as text content in the MCP format.
    execute: async (args) => { const result = await getTransaction(wagmiConfig, args); return { content: [ { type: "text", text: JSONStringify(result), }, ], }; },
  • Zod schema for input parameters: 'hash' (TransactionHash type) and optional 'chainId' (coerced number).
    parameters: z.object({ hash: TransactionHash.describe("Hash to get transaction."), chainId: z.coerce.number().optional().describe("ID of chain to use when fetching data."), }),
  • Direct registration of the 'get-transaction' tool on the FastMCP server instance using server.addTool, specifying name, description, input schema, and execute handler.
    server.addTool({ name: "get-transaction", description: "Fetch transaction given hash or block identifiers.", parameters: z.object({ hash: TransactionHash.describe("Hash to get transaction."), chainId: z.coerce.number().optional().describe("ID of chain to use when fetching data."), }), execute: async (args) => { const result = await getTransaction(wagmiConfig, args); return { content: [ { type: "text", text: JSONStringify(result), }, ], }; }, });
  • Invocation of the registerGetTransactionTools function within the central registerTools function, which registers multiple tools.
    registerGetTransactionTools(server, wagmiConfig);
  • src/index.ts:15-15 (registration)
    Top-level call to registerTools in the main index file, which chains to registering the get-transaction tool.
    registerTools(server, wagmiConfig);

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/Xiawpohr/metamask-mcp'

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