get-chain-id
Retrieve the current chain ID for blockchain interactions using MetaMask MCP. This tool ensures secure blockchain operations by keeping private keys in your wallet while fetching the chain ID.
Instructions
Get the current chain id.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/get-chain-id.ts:11-21 (handler)The async execute handler for the 'get-chain-id' tool. It calls getChainId from @wagmi/core using the provided config and returns the chain ID as a text content block.execute: async () => { const result = getChainId(wagmiConfig); return { content: [ { type: "text", text: result.toString(), }, ], }; },
- src/tools/get-chain-id.ts:10-10 (schema)Zod schema defining the input parameters for the tool, which takes no arguments.parameters: z.object({}),
- src/tools/get-chain-id.ts:7-22 (registration)Direct registration of the 'get-chain-id' tool on the FastMCP server within the registerGetChainIdTools function.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(), }, ], }; }, });
- src/tools/register-tools.ts:44-44 (registration)Call to register the 'get-chain-id' tool as part of the overall registerTools function.registerGetChainIdTools(server, wagmiConfig);