Skip to main content
Glama
AbdelStark
by AbdelStark

get_transaction

Retrieve Bitcoin transaction details by providing a transaction ID to access blockchain data and verify transaction information.

Instructions

Get transaction details

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
txidYesTransaction ID

Implementation Reference

  • Handler function that validates input using GetTransactionSchema, fetches transaction via bitcoinService, and formats the response as MCP TextContent.
    export async function handleGetTransaction(
      bitcoinService: BitcoinService,
      args: unknown
    ) {
      const result = GetTransactionSchema.safeParse(args);
      if (!result.success) {
        throw new McpError(
          ErrorCode.InvalidParams,
          `Invalid parameters: ${result.error.message}`
        );
      }
    
      const tx = await bitcoinService.getTransaction(result.data.txid);
      return {
        content: [
          {
            type: "text",
            text: `Transaction details:\nTXID: ${tx.txid}\nStatus: ${
              tx.status.confirmed ? "Confirmed" : "Unconfirmed"
            }\nBlock Height: ${tx.status.blockHeight || "Pending"}\nFee: ${
              tx.fee
            } sats`,
          },
        ] as TextContent[],
      };
    }
  • Zod schema defining the input for get_transaction: txid as 64-char string.
    export const GetTransactionSchema = z.object({
      txid: z.string().length(64, "Invalid transaction ID"),
    });
  • Tool registration in listTools handler: defines name, description, and inputSchema for 'get_transaction'.
      name: "get_transaction",
      description: "Get transaction details",
      inputSchema: {
        type: "object",
        properties: {
          txid: { type: "string", description: "Transaction ID" },
        },
        required: ["txid"],
      },
    } as Tool,
  • Dispatch in CallToolRequestSchema handler: routes 'get_transaction' calls to handleGetTransaction.
    case "get_transaction": {
      return handleGetTransaction(this.bitcoinService, args);
    }
  • BitcoinService method that fetches transaction details from Blockstream API and maps to TransactionInfo type.
    async getTransaction(txid: string): Promise<TransactionInfo> {
      try {
        const response = await fetch(`${this.apiBase}/tx/${txid}`);
        if (!response.ok) {
          throw new Error(`HTTP error! status: ${response.status}`);
        }
        const tx = (await response.json()) as any;
        return {
          txid: tx.txid,
          version: tx.version,
          locktime: tx.locktime,
          size: tx.size,
          weight: tx.weight,
          fee: tx.fee,
          status: {
            confirmed: tx.status.confirmed,
            blockHeight: tx.status.block_height,
            blockHash: tx.status.block_hash,
            blockTime: tx.status.block_time,
          },
          inputs: tx.vin.map((input: any) => ({
            txid: input.txid,
            vout: input.vout,
            sequence: input.sequence,
            prevout: input.prevout
              ? {
                  value: input.prevout.value,
                  scriptPubKey: input.prevout.scriptpubkey,
                  address: input.prevout.scriptpubkey_address,
                }
              : undefined,
          })),
          outputs: tx.vout.map((output: any) => ({
            value: output.value,
            scriptPubKey: output.scriptpubkey,
            address: output.scriptpubkey_address,
          })),
        };
      } catch (error) {
        logger.error({ error, txid }, "Failed to get transaction");
        throw new BitcoinError(
          "Failed to get transaction",
          BitcoinErrorCode.BLOCKCHAIN_ERROR
        );
      }
    }
Behavior2/5

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

With no annotations provided, the description carries full burden but only states the basic action without disclosing behavioral traits such as whether this is a read-only operation, error handling, rate limits, or authentication needs. It mentions 'details' but doesn't specify what those include.

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 extremely concise with 'Get transaction details'—a single, front-loaded sentence that efficiently conveys the core purpose without unnecessary words. However, it may be overly terse for a tool with no annotations or output schema.

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 lack of annotations and output schema, the description is incomplete. It doesn't explain what transaction details are returned, error conditions, or how it differs from sibling tools. For a tool with one parameter but no structured context, more information is needed.

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 input schema has 100% description coverage, clearly documenting the 'txid' parameter. The description adds no additional meaning beyond the schema, so it meets the baseline of 3 for adequate but not enhanced parameter semantics.

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

Purpose3/5

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

The description 'Get transaction details' states the basic action (get) and resource (transaction details), but it's vague about what specific details are retrieved and doesn't differentiate from sibling tools like 'decode_tx' or 'get_latest_block'. It provides minimal but adequate purpose information.

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?

No guidance is provided on when to use this tool versus alternatives like 'decode_tx' (which might decode transaction data) or 'get_latest_block' (which retrieves block information). The description lacks context about prerequisites or typical use cases.

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/AbdelStark/bitcoin-mcp'

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