Skip to main content
Glama

get-token

Retrieve token details from blockchain networks using wallet addresses and chain IDs to verify asset information.

Instructions

Get the token information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYes
chainIdNo

Implementation Reference

  • The execute function (handler) for the 'get-token' tool. Fetches token information using wagmi's getToken for the given address and optional chainId, then stringifies and returns the result.
    execute: async (args) => { const address = args.address as Address const chainId = args.chainId as typeof wagmiConfig['chains'][number]['id'] const result = await getToken(wagmiConfig, { address, chainId, }) return { content: [ { type: "text", text: JSONStringify(result), }, ], }
  • Zod schema defining input parameters: address (string) and optional chainId (number).
    parameters: z.object({ address: z.string(), chainId: z.coerce.number().optional(), }),
  • Registers the 'get-token' tool on the FastMCP server, including name, description, parameters schema, and execute handler.
    server.addTool({ name: "get-token", description: "Get the token information", parameters: z.object({ address: z.string(), chainId: z.coerce.number().optional(), }), execute: async (args) => { const address = args.address as Address const chainId = args.chainId as typeof wagmiConfig['chains'][number]['id'] const result = await getToken(wagmiConfig, { address, chainId, }) return { content: [ { type: "text", text: JSONStringify(result), }, ], } }, });
  • Invokes the registerGetTokenTools function to add the 'get-token' tool to the main MCP server instance.
    registerGetTokenTools(server);
  • Exports the get-token tool registration function from the tools index for use in the main index.
    export * from "./get-token.js";

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/mcpilot'

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