Skip to main content
Glama
tywenk

Model Context Protocol Server for Solana Client

by tywenk

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
NameRequiredDescriptionDefault
from_pubkeyYes
lamportsYes
to_pubkeyYes

Implementation Reference

  • 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}"

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/tywenk/mcp-sol'

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