Skip to main content
Glama

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
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • 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(), }, ], }; },
  • Input schema using Zod: empty object, indicating no parameters required for the tool.
    parameters: z.object({}),
  • 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(), }, ], }; }, }); };
  • Calls the specific registration function for 'get-chain-id' tool within the overall registerTools function.
    registerGetChainIdTools(server, wagmiConfig);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Xiawpohr/metamask-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server