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
| Name | Required | Description | Default |
|---|---|---|---|
| address | Yes | ||
| chainId | No |
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(), }), - packages/metamask-mcp/src/tools/get-token.ts:9-32 (registration)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), }, ], } }, }); - packages/metamask-mcp/src/index.ts:51-51 (registration)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";