Skip to main content
Glama

send_raw_transaction

Broadcast signed Bitcoin transactions to the network. Use this tool to submit finalized transactions after verifying signatures and fee rates.

Instructions

Broadcast a signed raw transaction to the Bitcoin network.

WARNING: This sends a REAL transaction. Once broadcast, it cannot be reversed. Ensure the transaction is correctly signed and you understand the fee implications. In hosted API mode, the transaction is broadcast through the Satoshi API's node.

Args: hex_string: Signed raw transaction in hex format max_fee_rate: Maximum fee rate in BTC/kvB to prevent accidental overpayment (default 0.10)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
hex_stringYes
max_fee_rateNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The 'send_raw_transaction' tool is implemented as a function in src/bitcoin_mcp/server.py. It takes a hex_string and an optional max_fee_rate, validates the input, and then uses the 'get_rpc().sendrawtransaction' method to broadcast the transaction.
    def send_raw_transaction(hex_string: str, max_fee_rate: float = 0.10) -> str:
        """Broadcast a signed raw transaction to the Bitcoin network.
    
        WARNING: This sends a REAL transaction. Once broadcast, it cannot be reversed.
        Ensure the transaction is correctly signed and you understand the fee implications.
        In hosted API mode, the transaction is broadcast through the Satoshi API's node.
    
        Args:
            hex_string: Signed raw transaction in hex format
            max_fee_rate: Maximum fee rate in BTC/kvB to prevent accidental overpayment (default 0.10)
        """
        if not re.fullmatch(r"[a-fA-F0-9]+", hex_string):
            return json.dumps({"error": "Invalid hex string: must contain only hex characters [0-9a-fA-F]", "broadcast": False})
        if len(hex_string) > 2_000_000:
            return json.dumps({"error": "Hex string too long: maximum 2,000,000 characters (1MB transaction)", "broadcast": False})
        try:
            txid = get_rpc().sendrawtransaction(hex_string, max_fee_rate)
            return json.dumps({"txid": txid, "broadcast": True})
        except Exception as e:
            return json.dumps({"error": str(e), "broadcast": False})

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