Skip to main content
Glama

call

Execute blockchain contract calls without submitting transactions to the network. Use this tool to interact with smart contracts while keeping private keys secure in MetaMask.

Instructions

Executing a new message call immediately without submitting a transaction to the network.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
toYesThe contract address or recipient.
dataYesA contract hashed method call with encoded args.
valueNoValue (in wei) sent with this transaction.

Implementation Reference

  • The execute handler for the 'call' MCP tool. It invokes wagmi's `call` function with the provided args, returns the result hash as JSON stringified text content, or error messages on failure.
    execute: async (args) => {
      try {
        const result = await call(wagmiConfig, args);
        return {
          content: [
            {
              type: "text",
              text: JSONStringify({
                hash: result,
              }),
            },
          ],
        };
      }
      catch (error) {
        if (error instanceof TransactionExecutionError) {
          return {
            content: [
              {
                type: "text",
                text: error.cause.message,
              },
            ],
          };
        }
        return {
          content: [
            {
              type: "text",
              text: (error as Error).message,
            },
          ],
        };
      }
    },
  • Zod input schema for the 'call' tool parameters: to (Address), data (Calldata), optional value (bigint).
    parameters: z.object({
      to: Address.describe("The contract address or recipient."),
      data: Calldata.describe("A contract hashed method call with encoded args."),
      value: z.coerce.bigint().optional().describe("Value (in wei) sent with this transaction."),
    }),
  • Calldata zod schema validator used in the 'call' tool's data parameter. Validates 0x-prefixed hex string.
    export const Calldata = z.string().transform((val, ctx) => {
      const regex = /^0x[a-fA-F0-9]+$/;
    
      if (!regex.test(val)) {
        ctx.addIssue({
          code: z.ZodIssueCode.custom,
          message: `Invalid calldata ${val}`,
        });
      }
    
      return val as BytesType;
    });
  • registerCallTools function that registers the 'call' tool on the FastMCP server with name, description, schema, and handler.
    export function registerCallTools(server: FastMCP, wagmiConfig: Config): void {
      server.addTool({
        name: "call",
        description: "Executing a new message call immediately without submitting a transaction to the network.",
        parameters: z.object({
          to: Address.describe("The contract address or recipient."),
          data: Calldata.describe("A contract hashed method call with encoded args."),
          value: z.coerce.bigint().optional().describe("Value (in wei) sent with this transaction."),
        }),
        execute: async (args) => {
          try {
            const result = await call(wagmiConfig, args);
            return {
              content: [
                {
                  type: "text",
                  text: JSONStringify({
                    hash: result,
                  }),
                },
              ],
            };
          }
          catch (error) {
            if (error instanceof TransactionExecutionError) {
              return {
                content: [
                  {
                    type: "text",
                    text: error.cause.message,
                  },
                ],
              };
            }
            return {
              content: [
                {
                  type: "text",
                  text: (error as Error).message,
                },
              ],
            };
          }
        },
      });
    };
  • Invocation of registerCallTools within the main registerTools function to register all tools including 'call'.
    registerCallTools(server, wagmiConfig);
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It mentions the tool executes 'without submitting a transaction', implying it's non-destructive and likely read-only, but doesn't clarify key behaviors: whether it requires authentication, has rate limits, returns simulation results or errors, or how it handles gas estimation. For a tool with no annotation coverage, this leaves significant gaps.

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 key information ('Executing a new message call') and adds crucial context ('immediately without submitting a transaction'). There is zero waste, and every word earns its place.

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 interactions, no annotations, and no output schema, the description is incomplete. It doesn't explain what the tool returns (e.g., simulation results, contract state), error conditions, or prerequisites (e.g., network connection). For a tool with 3 parameters and significant behavioral implications, this leaves too much unspecified.

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 three parameters ('to', 'data', 'value') with clear descriptions. The description adds no additional parameter semantics beyond what's in the schema, such as examples or constraints. Baseline 3 is appropriate when the schema does the heavy lifting.

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 action ('Executing a new message call') and distinguishes it from submitting a transaction to the network. It specifies the immediate execution aspect, which helps differentiate from sibling tools like 'send-transaction' or 'write-contract'. However, it doesn't explicitly mention what a 'message call' is or its typical use cases (e.g., reading contract state).

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

Usage Guidelines3/5

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

The description implies when to use this tool ('immediately without submitting a transaction') versus alternatives like 'send-transaction', suggesting it's for read-only or simulation purposes. However, it lacks explicit guidance on when NOT to use it (e.g., for state-changing operations) or detailed comparisons with siblings like 'read-contract' or 'estimate-gas'.

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

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/Xiawpohr/metamask-mcp'

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