get-token
Retrieve detailed token information by providing the token address and chain ID, enabling secure blockchain interactions through MetaMask MCP.
Instructions
Fetch the token information.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| address | Yes | Address to get token for. | |
| chainId | No | ID of chain to use when fetching data. |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"address": {
"description": "Address to get token for.",
"type": "string"
},
"chainId": {
"description": "ID of chain to use when fetching data.",
"type": "number"
}
},
"required": [
"address"
],
"type": "object"
}
Implementation Reference
- src/tools/get-token.ts:9-27 (registration)Primary registration of the 'get-token' MCP tool via server.addTool, defining name, description, parameters schema, and execute handler.server.addTool({ name: "get-token", description: "Fetch the token information.", parameters: z.object({ address: Address.describe("Address to get token for."), chainId: z.coerce.number().optional().describe("ID of chain to use when fetching data."), }), execute: async (args) => { const result = await getToken(wagmiConfig, args); return { content: [ { type: "text", text: JSONStringify(result), }, ], }; }, });
- src/tools/get-token.ts:16-26 (handler)The core handler logic: invokes wagmi's getToken function with config and args, stringifies the result as JSON, and returns it as text content.execute: async (args) => { const result = await getToken(wagmiConfig, args); return { content: [ { type: "text", text: JSONStringify(result), }, ], }; },
- src/tools/get-token.ts:12-15 (schema)Zod schema defining input parameters: required 'address' (Address type) and optional 'chainId' (coerced number).parameters: z.object({ address: Address.describe("Address to get token for."), chainId: z.coerce.number().optional().describe("ID of chain to use when fetching data."), }),