get-chain-id
Retrieve the current chain ID from a blockchain network using MCPilot. Facilitates secure interactions with MetaMask, enabling AI-powered blockchain tasks without exposing private keys.
Instructions
Get the current chain id
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- Handler function that retrieves the current chain ID using Wagmi's getChainId(wagmiConfig) and formats it as a text content response for MCP.execute: async () => { const result = getChainId(wagmiConfig) return { content: [ { type: "text", text: result.toString(), }, ], } },
- Tool metadata including name, description, and Zod schema for parameters (no parameters required).name: "get-chain-id", description: "Get the current chain id", parameters: z.object({}),
- packages/metamask-mcp/src/index.ts:47-47 (registration)Top-level registration call that invokes the tool registration function on the FastMCP server instance.registerGetChainIdTools(server);
- packages/metamask-mcp/src/tools/get-chain-id.ts:6-23 (registration)Dedicated registration function that adds the get-chain-id tool to the server, including handler and schema.export function registerGetChainIdTools(server: FastMCP): void { server.addTool({ name: "get-chain-id", description: "Get the current chain id", parameters: z.object({}), execute: async () => { const result = getChainId(wagmiConfig) return { content: [ { type: "text", text: result.toString(), }, ], } }, }); };