get-chain-id
Retrieve the current blockchain network identifier from MetaMask to verify connection and ensure correct network operations.
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 core handler function that implements the 'get-chain-id' tool logic by calling getChainId from wagmi/core and formatting the result as MCP text content.execute: async () => { const result = getChainId(wagmiConfig); return { content: [ { type: "text", text: result.toString(), }, ], }; },
- src/tools/get-chain-id.ts:10-10 (schema)Input schema using Zod: empty object, indicating no parameters required for the tool.parameters: z.object({}),
- src/tools/get-chain-id.ts:6-23 (registration)The registration function for the 'get-chain-id' tool, which adds the tool to the FastMCP server with name, description, schema, and handler.export function registerGetChainIdTools(server: FastMCP, wagmiConfig: Config): 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(), }, ], }; }, }); };
- src/tools/register-tools.ts:44-44 (registration)Calls the specific registration function for 'get-chain-id' tool within the overall registerTools function.registerGetChainIdTools(server, wagmiConfig);