get-chain-id
Retrieve the current blockchain network identifier to verify the correct chain for secure transactions and interactions.
Instructions
Get the current chain id
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "get-chain-id"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- Handler function for the 'get-chain-id' tool. Retrieves the current chain ID using wagmi's getChainId with the configured wagmiConfig and returns it as a text content block.
execute: async () => { const result = getChainId(wagmiConfig) return { content: [ { type: "text", text: result.toString(), }, ], } }, - Zod schema defining the input parameters for the 'get-chain-id' tool: an empty object indicating no parameters are required.
parameters: z.object({}), - packages/metamask-mcp/src/tools/get-chain-id.ts:6-23 (registration)Local registration function for the 'get-chain-id' tool, exported for use in the main server setup. Includes name, description, schema, and handler.
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(), }, ], } }, }); }; - packages/metamask-mcp/src/index.ts:47-47 (registration)Calls the registerGetChainIdTools function to add the 'get-chain-id' tool to the main FastMCP server instance.
registerGetChainIdTools(server);