send-transaction
Facilitates secure blockchain transactions by sending data, value, and recipient details to networks through MCPilot, enabling AI-powered interactions without exposing private keys.
Instructions
Send transactions to networks
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| data | No | ||
| to | Yes | ||
| value | No |
Implementation Reference
- The main handler function that executes the transaction using wagmi's sendTransaction, handles errors, and returns the transaction hash 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 sendTransaction(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 schema defining the input parameters for the send-transaction tool: to (recipient address), value (optional ETH amount), data (optional calldata).parameters: z.object({ to: z.string(), value: z.coerce.number().optional(), data: z.string().optional(), }),
- packages/metamask-mcp/src/tools/send-transaction.ts:9-58 (registration)The server.addTool call within registerSendTransactionTools that defines name, description, schema, and handler for the tool.server.addTool({ name: "send-transaction", description: "Send transactions to networks", parameters: z.object({ to: z.string(), value: z.coerce.number().optional(), data: z.string().optional(), }), 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 sendTransaction(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:55-55 (registration)The invocation of registerSendTransactionTools on the main FastMCP server instance, effectively registering the tool.registerSendTransactionTools(server);