Skip to main content
Glama

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
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • 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(), }, ], }; },
  • Zod schema defining the input parameters for the tool, which takes no arguments.
    parameters: z.object({}),
  • 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(), }, ], }; }, });
  • Call to register the 'get-chain-id' tool as part of 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