Skip to main content
Glama

get_mempool_ancestors

Retrieve all unconfirmed ancestor transactions for a given mempool transaction to analyze CPFP (Child Pays For Parent) scenarios and understand transaction dependencies.

Instructions

Get all unconfirmed ancestor transactions of a mempool transaction. Useful for CPFP analysis.

Args: txid: Transaction hash (64 hex characters)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
txidYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The `get_mempool_ancestors` tool is implemented in `src/bitcoin_mcp/server.py` as a function decorated with `@mcp.tool()`. It uses the `get_rpc()` helper to call `getmempoolancestors` on the Bitcoin RPC interface and formats the results for MCP.
    def get_mempool_ancestors(txid: str) -> str:
        """Get all unconfirmed ancestor transactions of a mempool transaction. Useful for CPFP analysis.
    
        Args:
            txid: Transaction hash (64 hex characters)
        """
        try:
            ancestors = get_rpc().getmempoolancestors(txid, True)
        except Exception as e:
            return json.dumps({"error": str(e)})
        summary = []
        for anc_txid, info in ancestors.items():
            summary.append({
                "txid": anc_txid,
                "fee_sats": info.get("fees", {}).get("base", 0) * 1e8,
                "vsize": info.get("vsize"),
                "fee_rate_sat_vb": round(info.get("fees", {}).get("base", 0) * 1e8 / info.get("vsize", 1), 2) if info.get("vsize") else None,
                "depends": info.get("depends", []),
            })
        return json.dumps({
            "txid": txid,
            "ancestor_count": len(ancestors),
            "ancestors": summary,
        })

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

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