Skip to main content
Glama

Read from Contract

read_contract
Read-only
    Calls a smart contract function (view/pure, or non-view/pure simulated via eth_call) and returns the
    decoded result.

    This tool provides a direct way to query the state of a smart contract.

    Example:
    To check the USDT balance of an address on Ethereum Mainnet, you would use the following arguments:
{
  "tool_name": "read_contract",
  "params": {
    "chain_id": "1",
    "address": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
    "abi": {
      "constant": true,
      "inputs": [{"name": "_owner", "type": "address"}],
      "name": "balanceOf",
      "outputs": [{"name": "balance", "type": "uint256"}],
      "payable": false,
      "stateMutability": "view",
      "type": "function"
    },
    "function_name": "balanceOf",
    "args": "["0xF977814e90dA44bFA03b6295A0616a897441aceC"]"
  }
}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
abiYesThe JSON ABI for the specific function being called. This should be a dictionary that defines the function's name, inputs, and outputs. The function ABI can be obtained using the `get_contract_abi` tool.
argsNoA JSON string containing an array of arguments. Example: "["0xabc..."]" for a single address argument, or "[]" for no arguments. Order and types must match ABI inputs. Addresses: use 0x-prefixed strings; Numbers: prefer integers (not quoted); numeric strings like "1" are also accepted and coerced to integers. Bytes: keep as 0x-hex strings.[]
blockNoThe block identifier to read the contract state from. Can be a block number (e.g., 19000000) or a string tag (e.g., 'latest'). Defaults to 'latest'.latest
addressYesSmart contract address
chain_idYesThe ID of the blockchain
session_idNoOpaque session identifier.
function_nameYesThe symbolic name of the function to be called. This must match the `name` field in the provided ABI.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
dataYesThe main data payload of the tool's response.
notesNoA list of important contextual notes, such as warnings about data truncation or data quality issues.
paginationNoPagination information, present only if the 'data' is a single page of a larger result set.
content_textNoOptional human-readable summary used for MCP content responses.
instructionsNoA list of suggested follow-up actions or instructions for the LLM to plan its next steps.
data_descriptionNoA list of notes explaining the structure, fields, or conventions of the 'data' payload.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • addedInput schema / properties / session_id
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "description": "Opaque session identifier.",
      +  "title": "Session Id"
      +}
  2. Changed19 schema fields changed
    • removedInput schema / $schema
      Removed value: -"http://json-schema.org/draft-07/schema#"
    • removedInput schema / additionalProperties
      Removed value: -false
    • addedInput schema / properties / abi / additionalProperties
      Added value: +true
    • changedInput schema / properties / abi / description
      Previous value: -"JSON ABI for the function being called"New value: +"The JSON ABI for the specific function being called. This should be a dictionary that defines the function's name, inputs, and outputs. The function ABI can be obtained using the `get_contract_abi` tool."
    • addedInput schema / properties / abi / title
      Added value: +"Abi"
    • addedInput schema / properties / abi / type
      Added value: +"object"
    • addedInput schema / properties / address / title
      Added value: +"Address"
    • changedInput schema / properties / args / description
      Previous value: -"JSON array of arguments"New value: +"A JSON string containing an array of arguments. Example: \"[\"0xabc...\"]\" for a single address argument, or \"[]\" for no arguments. Order and types must match ABI inputs. Addresses: use 0x-prefixed strings; Numbers: prefer integers (not quoted); numeric strings like \"1\" are also accepted and coerced to integers. Bytes: keep as 0x-hex strings."
    • addedInput schema / properties / args / title
      Added value: +"Args"
    • addedInput schema / properties / block / anyOf
      Added value: +[
      +  {
      +    "type": "string"
      +  },
      +  {
      +    "type": "integer"
      +  }
      +]
    • changedInput schema / properties / block / description
      Previous value: -"Block number or 'latest'"New value: +"The block identifier to read the contract state from. Can be a block number (e.g., 19000000) or a string tag (e.g., 'latest'). Defaults to 'latest'."
    • addedInput schema / properties / block / title
      Added value: +"Block"
    • removedInput schema / properties / block / type
      Removed value: -"string"
    • addedInput schema / properties / chain_id / title
      Added value: +"Chain Id"
    • changedInput schema / properties / function_name / description
      Previous value: -"Function name matching the ABI"New value: +"The symbolic name of the function to be called. This must match the `name` field in the provided ABI."
    • addedInput schema / properties / function_name / title
      Added value: +"Function Name"
    • changedInput schema / required
      Previous value: -[
      -  "chain_id",
      -  "address",
      -  "function_name"
      -]New value: +[
      +  "chain_id",
      +  "address",
      +  "abi",
      +  "function_name"
      +]
    • addedInput schema / title
      Added value: +"read_contractArguments"
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "$defs": {
      +    "ContractReadData": {
      +      "description": "Result of a read-only smart contract function call.",
      +      "properties": {
      +        "result": {
      +          "description": "Return value from the contract function call.",
      +          "title": "Result"
      +        }
      +      },
      +      "required": [
      +        "result"
      +      ],
      +      "title": "ContractReadData",
      +      "type": "object"
      +    },
      +    "NextCallInfo": {
      +      "description": "A structured representation of the tool call required to get the next page.",
      +      "properties": {
      +        "params": {
      +          "additionalProperties": true,
      +          "description": "A complete dictionary of parameters for the next tool call, including the new cursor.",
      +          "title": "Params",
      +          "type": "object"
      +        },
      +        "tool_name": {
      +          "description": "The name of the tool to call for the next page.",
      +          "title": "Tool Name",
      +          "type": "string"
      +        }
      +      },
      +      "required": [
      +        "tool_name",
      +        "params"
      +      ],
      +      "title": "NextCallInfo",
      +      "type": "object"
      +    },
      +    "PaginationInfo": {
      +      "description": "Contains the structured information needed to retrieve the next page of results.",
      +      "properties": {
      +        "next_call": {
      +          "$ref": "#/$defs/NextCallInfo",
      +          "description": "The structured tool call required to fetch the subsequent page."
      +        }
      +      },
      +      "required": [
      +        "next_call"
      +      ],
      +      "title": "PaginationInfo",
      +      "type": "object"
      +    }
      +  },
      +  "properties": {
      +    "content_text": {
      +      "anyOf": [
      +        {
      +          "type": "string"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "default": null,
      +      "description": "Optional human-readable summary used for MCP content responses.",
      +      "title": "Content Text"
      +    },
      +    "data": {
      +      "$ref": "#/$defs/ContractReadData",
      +      "description": "The main data payload of the tool's response."
      +    },
      +    "data_description": {
      +      "anyOf": [
      +        {
      +          "items": {
      +            "type": "string"
      +          },
      +          "type": "array"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "default": null,
      +      "description": "A list of notes explaining the structure, fields, or conventions of the 'data' payload.",
      +      "title": "Data Description"
      +    },
      +    "instructions": {
      +      "anyOf": [
      +        {
      +          "items": {
      +            "type": "string"
      +          },
      +          "type": "array"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "default": null,
      +      "description": "A list of suggested follow-up actions or instructions for the LLM to plan its next steps.",
      +      "title": "Instructions"
      +    },
      +    "notes": {
      +      "anyOf": [
      +        {
      +          "items": {
      +            "type": "string"
      +          },
      +          "type": "array"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "default": null,
      +      "description": "A list of important contextual notes, such as warnings about data truncation or data quality issues.",
      +      "title": "Notes"
      +    },
      +    "pagination": {
      +      "anyOf": [
      +        {
      +          "$ref": "#/$defs/PaginationInfo"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "default": null,
      +      "description": "Pagination information, present only if the 'data' is a single page of a larger result set."
      +    }
      +  },
      +  "required": [
      +    "data"
      +  ],
      +  "title": "ToolResponse[ContractReadData]",
      +  "type": "object"
      +}
  3. Changed18 schema fields changed
    • addedInput schema / $schema
      Added value: +"http://json-schema.org/draft-07/schema#"
    • addedInput schema / additionalProperties
      Added value: +false
    • removedInput schema / properties / abi / additionalProperties
      Removed value: -true
    • changedInput schema / properties / abi / description
      Previous value: -"The JSON ABI for the specific function being called. This should be a dictionary that defines the function's name, inputs, and outputs. The function ABI can be obtained using the `get_contract_abi` tool."New value: +"JSON ABI for the function being called"
    • removedInput schema / properties / abi / title
      Removed value: -"Abi"
    • removedInput schema / properties / abi / type
      Removed value: -"object"
    • removedInput schema / properties / address / title
      Removed value: -"Address"
    • changedInput schema / properties / args / description
      Previous value: -"A JSON string containing an array of arguments. Example: \"[\"0xabc...\"]\" for a single address argument, or \"[]\" for no arguments. Order and types must match ABI inputs. Addresses: use 0x-prefixed strings; Numbers: prefer integers (not quoted); numeric strings like \"1\" are also accepted and coerced to integers. Bytes: keep as 0x-hex strings."New value: +"JSON array of arguments"
    • removedInput schema / properties / args / title
      Removed value: -"Args"
    • removedInput schema / properties / block / anyOf
      Removed value: -[
      -  {
      -    "type": "string"
      -  },
      -  {
      -    "type": "integer"
      -  }
      -]
    • changedInput schema / properties / block / description
      Previous value: -"The block identifier to read the contract state from. Can be a block number (e.g., 19000000) or a string tag (e.g., 'latest'). Defaults to 'latest'."New value: +"Block number or 'latest'"
    • removedInput schema / properties / block / title
      Removed value: -"Block"
    • addedInput schema / properties / block / type
      Added value: +"string"
    • removedInput schema / properties / chain_id / title
      Removed value: -"Chain Id"
    • changedInput schema / properties / function_name / description
      Previous value: -"The symbolic name of the function to be called. This must match the `name` field in the provided ABI."New value: +"Function name matching the ABI"
    • removedInput schema / properties / function_name / title
      Removed value: -"Function Name"
    • changedInput schema / required
      Previous value: -[
      -  "chain_id",
      -  "address",
      -  "abi",
      -  "function_name"
      -]New value: +[
      +  "chain_id",
      +  "address",
      +  "function_name"
      +]
    • removedInput schema / title
      Removed value: -"read_contractArguments"
  4. First observed

TDQS

A4.3/5.0
Behavior4/5

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

Annotations already mark this as read-only and non-destructive. The description adds that non-view/pure functions are simulated via eth_call, making it clear there is no state change. It also notes the result is decoded, which is useful behavioral information.

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

Conciseness4/5

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

The core description is two sentences, though the second is somewhat redundant with the first. The included example is large but provides valuable, concrete parameter formatting guidance, justifying its inclusion.

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

Completeness4/5

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

Given the complexity of seven parameters and the presence of an output schema, the description covers the essential behavior and a full example. It does not explain every parameter, but the schema handles that, and the example fills in practical usage gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema covers all parameters with descriptions, and the example demonstrates how to format args, ABI, and addresses. It clarifies JSON string formatting for args and address conventions, exceeding basic schema descriptions.

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 clearly states it calls a smart contract function (view/pure, or non-view/pure simulated via eth_call) and returns the decoded result. This specifies the exact action and resource, distinguishing it from generic API calls or ABI inspection tools. The example reinforces the use case of querying token balances.

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

Usage Guidelines4/5

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

The description identifies this as 'a direct way to query the state of a smart contract,' giving clear context for when to use it. It does not explicitly name alternatives or exclusions, but the context and sibling set make the appropriate use case evident. The example provides a concrete scenario.

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.