Skip to main content
Glama

Read Contract

read_contract
Read-only

Call any view/pure function on a smart contract and return the decoded result, using a supplied ABI fragment. Supports historical reads via block_identifier and caller_address context for msg.sender-dependent views. Read-only: state-changing functions are rejected.

Use when: Use when a protocol question needs a contract read that no higher-level tool covers — e.g. a niche view function or a protocol outside the standard tool set. Prefer purpose-built tools (get_defi_positions, get_lending_rates) for supported protocols.

Limitations: Requires a valid ABI fragment; payable/nonpayable functions are rejected. Ethereum mainnet and Base only, with bounded RPC timeout and retry.

Alternatives: get_defi_positions, get_lending_rates, get_token_approvals

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
argsNoDEPRECATED: Positional arguments for the function call. Use 'args_json' for complex objects or Gemini compatibility.
chain_idNoChain ID (1=Ethereum, 8453=Base)
args_jsonNoOptional JSON array string of positional arguments for the function call. Use this instead of 'args' for complex types or when calling via Google/Gemini.
abi_fragmentYesJSON array containing the ABI for the function to call. Supports both modern (stateMutability: view/pure) and legacy (constant: true) formats. Only read-only functions are allowed.
function_nameYesName of the function to call
caller_addressNoOptional EVM address to supply as msg.sender for caller-dependent view functions. This does not sign or submit a transaction.
block_identifierNoBlock number, block hash, or 'latest'/'earliest'/'pending'latest
contract_addressYesContract address (0x…)

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
chain_idYes
function_nameYes
caller_addressNo
block_identifierYes
contract_addressYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed10 schema fields changed
    • removedInput schema / additionalProperties
      Removed value: -false
    • addedInput schema / properties / abi_fragment / title
      Added value: +"Abi Fragment"
    • addedInput schema / properties / args / title
      Added value: +"Args"
    • addedInput schema / properties / args_json / title
      Added value: +"Args Json"
    • addedInput schema / properties / block_identifier / title
      Added value: +"Block Identifier"
    • addedInput schema / properties / caller_address / title
      Added value: +"Caller Address"
    • addedInput schema / properties / chain_id / title
      Added value: +"Chain Id"
    • addedInput schema / properties / contract_address / title
      Added value: +"Contract Address"
    • addedInput schema / properties / function_name / title
      Added value: +"Function Name"
    • addedInput schema / title
      Added value: +"mcp_read_contractArguments"
  2. Changed2 schema fields changed
    • addedInput schema / properties / caller_address
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "description": "Optional EVM address to supply as msg.sender for caller-dependent view functions. This does not sign or submit a transaction."
      +}
    • addedOutput schema / properties / caller_address
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "title": "Caller Address"
      +}
  3. First observed

TDQS

A4.7/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description discloses behavior beyond the readOnlyHint annotation: it explicitly rejects state-changing functions, supports historical reads via block_identifier, and explains caller_address supplies msg.sender without signing. It also states network constraints (Ethereum mainnet and Base) and bounded RPC timeout/retry, giving a full safety and operational picture.

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 well-structured with distinct sections (functionality, usage, limitations, alternatives) and is front-loaded with the core action. Every sentence earns its place; there is no fluff or redundancy. It is appropriately sized for an 8-parameter tool.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity and the presence of an output schema and annotations, the description covers purpose, usage, limitations, and alternatives comprehensively. It specifies supported networks, rejected function types, and the non-transactional nature of caller_address. Nothing essential for correct invocation is missing.

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 all parameters are already documented. The description adds context about using block_identifier for historical reads and caller_address for msg.sender-dependent views, which mirrors schema descriptions. It does not introduce new semantics beyond the schema, so the baseline of 3 is appropriate.

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

Purpose5/5

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

The description opens with a specific verb ('Call'), a clear resource ('any view/pure function on a smart contract'), and the output ('decoded result'). It explicitly distinguishes itself from higher-level tools by naming purpose-built alternatives, so an agent can immediately tell when this low-level tool is appropriate.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides an explicit 'Use when' condition (protocol questions not covered by higher-level tools) and instructs to prefer purpose-built tools (get_defi_positions, get_lending_rates) for supported protocols. It also lists limitations (network, ABI requirement, rejected function types) and names alternatives, leaving no ambiguity about when to invoke this tool.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources