get_fee_for_message
Calculate the transaction fee for a message transfer on Solana by providing sender and recipient public keys along with the lamports amount. Returns fee details.
Instructions
Returns the fee for a message.
Args: from_pubkey (str): Sender's public key to_pubkey (str): Recipient's public key lamports (int): Amount of lamports to transfer
Returns: str: Fee information
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| from_pubkey | Yes | ||
| lamports | Yes | ||
| to_pubkey | Yes |
Implementation Reference
- src/server.py:442-467 (handler)The handler function for the 'get_fee_for_message' MCP tool. It constructs a Solana transfer message from the input parameters and uses the AsyncClient to retrieve the required fee via get_fee_for_message RPC method. The @mcp.tool() decorator handles registration and schema inference from the signature and docstring.@mcp.tool() async def get_fee_for_message(from_pubkey: str, to_pubkey: str, lamports: int) -> str: """Returns the fee for a message. Args: from_pubkey (str): Sender's public key to_pubkey (str): Recipient's public key lamports (int): Amount of lamports to transfer Returns: str: Fee information """ async with AsyncClient(rpc_url) as client: msg = Message( [ transfer( TransferParams( from_pubkey=Pubkey.from_string(from_pubkey), to_pubkey=Pubkey.from_string(to_pubkey), lamports=lamports, ) ) ] ) fee = await client.get_fee_for_message(msg) return f"Message fee: {fee}"