Skip to main content
Glama
cuongpo

Rootstock MCP Server

by cuongpo

estimate_gas

Calculate the gas cost for transactions on the Rootstock blockchain by providing recipient address, optional value, and transaction data to optimize block space usage.

Instructions

Estimate gas cost for a transaction

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dataNoOptional transaction data
toYesRecipient address
valueNoOptional value to send (in ether)

Implementation Reference

  • Primary handler for the 'estimate_gas' MCP tool. Calls RootstockClient.estimateGas with parameters and returns formatted text response with gas limit, price, and estimated cost.
    private async handleEstimateGas(params: EstimateGasParams) {
      try {
        const estimate = await this.rootstockClient.estimateGas(
          params.to,
          params.value,
          params.data
        );
        return {
          content: [
            {
              type: 'text',
              text: `Gas Estimate:\n\nGas Limit: ${estimate.gasLimit}\nGas Price: ${estimate.gasPrice} wei\nEstimated Cost: ${estimate.estimatedCost} ${this.rootstockClient.getCurrencySymbol()}`,
            },
          ],
        };
      } catch (error) {
        throw new Error(`Failed to estimate gas: ${error}`);
      }
    }
  • src/index.ts:294-314 (registration)
    Tool registration in getAvailableTools(), including name, description, and input schema for 'estimate_gas'.
    {
      name: 'estimate_gas',
      description: 'Estimate gas cost for a transaction',
      inputSchema: {
        type: 'object',
        properties: {
          to: {
            type: 'string',
            description: 'Recipient address',
          },
          value: {
            type: 'string',
            description: 'Optional value to send (in ether)',
          },
          data: {
            type: 'string',
            description: 'Optional transaction data',
          },
        },
        required: ['to'],
      },
  • TypeScript interface defining input parameters for the estimate_gas tool.
    export interface EstimateGasParams {
      to: string;
      value?: string;
      data?: string;
    }
  • Core implementation in RootstockClient that performs the actual gas estimation using ethers.js provider. Computes gas limit, price, and total estimated cost.
    async estimateGas(to: string, value?: string, data?: string): Promise<GasEstimate> {
      try {
        const tx: ethers.TransactionRequest = {
          to,
          value: value ? ethers.parseEther(value) : 0,
          data: data || '0x',
        };
    
        const [gasLimit, feeData] = await Promise.all([
          this.getProvider().estimateGas(tx),
          this.getProvider().getFeeData(),
        ]);
    
        const gasPrice = feeData.gasPrice || BigInt(0);
        const estimatedCost = gasLimit * gasPrice;
    
        return {
          gasLimit: gasLimit.toString(),
          gasPrice: gasPrice.toString(),
          estimatedCost: ethers.formatEther(estimatedCost),
        };
      } catch (error) {
        throw new Error(`Failed to estimate gas: ${error}`);
      }
    }
  • Alternative handler and registration for 'estimate_gas' in the Smithery server variant.
    server.tool(
      "estimate_gas",
      "Estimate gas cost for a transaction",
      {
        to: z.string().describe("Recipient address"),
        value: z.string().optional().describe("Optional value to send (in ether)"),
        data: z.string().optional().describe("Optional transaction data"),
      },
      async ({ to, value, data }) => {
        try {
          const gasEstimate = await rootstockClient.estimateGas(to, value, data);
          return {
            content: [
              {
                type: "text",
                text: `Gas Estimation:\n\nEstimated Gas: ${gasEstimate.gasLimit}\nGas Price: ${gasEstimate.gasPrice}\nEstimated Cost: ${gasEstimate.estimatedCost} ${rootstockClient.getCurrencySymbol()}`,
              },
            ],
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error estimating gas: ${error instanceof Error ? error.message : String(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 for behavioral disclosure. It states what the tool does but doesn't describe how it works: whether it's a simulation, requires network access, has rate limits, returns specific units (e.g., wei/gwei), or handles errors. For a tool that likely interacts with a blockchain, this leaves significant gaps in understanding its behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise—a single, direct sentence that states the core purpose without any fluff. It's front-loaded and wastes no words, making it easy for an agent to parse quickly while communicating the essential function.

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 complexity of blockchain transactions and the lack of annotations or output schema, the description is insufficiently complete. It doesn't explain what the estimate represents (e.g., gas units, cost in ETH), whether it's for the current network state, or how it should be used in practice. For a tool with no structured output documentation, more context 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 description adds no parameter semantics beyond what's already in the schema, which has 100% coverage with clear descriptions for all three parameters. The baseline score of 3 reflects adequate parameter documentation through the schema alone, with the description providing no additional value in this dimension.

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

Purpose4/5

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

The description clearly states the tool's purpose: estimating gas cost for a transaction. It specifies the verb ('estimate') and resource ('gas cost'), making it immediately understandable. However, it doesn't differentiate from sibling tools like 'send_transaction' or 'send_contract_transaction' that might also involve gas considerations, preventing a perfect score.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention whether this should be used before sending transactions, how it relates to tools like 'send_transaction' or 'call_contract', or any prerequisites. The agent must infer usage from context alone.

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

Related 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/cuongpo/rootstock-mcp'

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