call
Execute message calls to blockchain contracts directly without submitting transactions, enabling secure testing and interaction through MetaMask wallet integration.
Instructions
Executing a new message call immediately without submitting a transaction to the network
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| to | Yes | ||
| value | No | ||
| data | Yes |
Implementation Reference
- Handler function that executes the low-level 'call' action using wagmi/core's call, casting arguments, handling TransactionExecutionError and generic errors, returning JSON-stringified result or error message.execute: async (args) => { try { const to = args.to as Address const value = args.value ? BigInt(args.value) : undefined const data = args.data as Address const result = await call(wagmiConfig, { to, value, data, }) 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 defining parameters: to (string address), optional value (number coerced to bigint), data (string calldata).parameters: z.object({ to: z.string(), value: z.coerce.number().optional(), data: z.string(), }),
- packages/metamask-mcp/src/tools/call.ts:9-58 (registration)Core registration of the 'call' tool on the FastMCP server within registerCallTools, including name, description, schema, and handler.server.addTool({ name: "call", description: "Executing a new message call immediately without submitting a transaction to the network", parameters: z.object({ to: z.string(), value: z.coerce.number().optional(), data: z.string(), }), execute: async (args) => { try { const to = args.to as Address const value = args.value ? BigInt(args.value) : undefined const data = args.data as Address const result = await call(wagmiConfig, { to, value, data, }) 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, } ] } } }, });
- packages/metamask-mcp/src/index.ts:39-39 (registration)Invocation of the registerCallTools function on the main FastMCP server instance to register the 'call' tool.registerCallTools(server);