Skip to main content
Glama
cuongpo

Rootstock MCP Server

by cuongpo

call_contract

Execute read-only smart contract methods on the Rootstock blockchain by specifying the contract address, method name, and parameters using the standardized Model Context Protocol APIs.

Instructions

Call a smart contract method (read-only)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
abiNoOptional contract ABI
contractAddressYesSmart contract address
methodNameYesMethod name to call
parametersNoMethod parameters

Implementation Reference

  • MCP server handler for 'call_contract' tool: calls rootstockClient.callContract and returns formatted result or error.
    private async handleCallContract(params: CallContractParams) {
      try {
        const result = await this.rootstockClient.callContract(
          params.contractAddress,
          params.methodName,
          params.parameters || [],
          params.abi
        );
        return {
          content: [
            {
              type: 'text',
              text: `Contract Call Result:\n\nContract: ${params.contractAddress}\nMethod: ${params.methodName}\nResult: ${JSON.stringify(result.result, null, 2)}`,
            },
          ],
        };
      } catch (error) {
        throw new Error(`Failed to call contract: ${error}`);
      }
    }
  • TypeScript interface defining input parameters for call_contract: contract address, method, params, optional ABI.
    export interface CallContractParams {
      contractAddress: string;
      methodName: string;
      parameters?: any[];
      abi?: any[];
    }
  • src/index.ts:316-343 (registration)
    Tool registration in MCP server's getAvailableTools(): defines name, description, and inputSchema for 'call_contract'.
    {
      name: 'call_contract',
      description: 'Call a smart contract method (read-only)',
      inputSchema: {
        type: 'object',
        properties: {
          contractAddress: {
            type: 'string',
            description: 'Smart contract address',
          },
          methodName: {
            type: 'string',
            description: 'Method name to call',
          },
          parameters: {
            type: 'array',
            description: 'Method parameters',
            items: {},
          },
          abi: {
            type: 'array',
            description: 'Optional contract ABI',
            items: {},
          },
        },
        required: ['contractAddress', 'methodName'],
      },
    },
  • Low-level implementation in RootstockClient: creates ethers.Contract and performs read-only method call using provided or generated ABI.
    async callContract(
      contractAddress: string,
      methodName: string,
      parameters: any[] = [],
      abi?: any[]
    ): Promise<ContractCallResponse> {
      try {
        // Use a basic ABI if none provided
        const contractAbi = abi || [
          `function ${methodName}(${parameters.map((_, i) => `uint256 param${i}`).join(', ')}) view returns (uint256)`,
        ];
    
        const contract = new ethers.Contract(contractAddress, contractAbi, this.getProvider());
        const result = await contract[methodName](...parameters);
    
        return {
          result: result.toString(),
        };
      } catch (error) {
        throw new Error(`Failed to call contract: ${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 but only states 'read-only' without disclosing other behavioral traits like network requirements, error handling, rate limits, or what happens with invalid inputs. This is inadequate for a contract interaction tool.

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 a single, efficient sentence that front-loads the core purpose ('call a smart contract method') with a key constraint ('read-only'). There's zero wasted text, making it appropriately sized and well-structured.

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 smart contract interactions, no annotations, and no output schema, the description is insufficient. It lacks details on return values, error cases, network dependencies, or prerequisites, leaving significant gaps for agent understanding.

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?

Schema description coverage is 100%, so the schema already documents all parameters. The description adds no additional meaning about parameters beyond implying they're for calling methods, meeting the baseline for high schema coverage.

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 verb ('call') and resource ('smart contract method'), specifying it's read-only. However, it doesn't differentiate from sibling tools like 'send_contract_transaction' which likely performs write operations, missing explicit sibling distinction.

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?

No guidance on when to use this tool versus alternatives is provided. The description mentions 'read-only' but doesn't specify when to choose this over other contract interaction tools like 'send_contract_transaction' or 'estimate_gas', leaving usage context unclear.

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