TOKEN_LIST
Retrieve available tokens for trading on OpenOcean MCP's decentralized exchange across multiple blockchain networks.
Instructions
Get token list
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chain | No | The blockchain network to execute the transaction on. uses fraxtal as default | fraxtal |
Implementation Reference
- src/tools/chain.ts:36-58 (handler)The main handler function for the TOKEN_LIST tool. It takes chain parameters, resolves the chain object, fetches the token list from ChainService, handles errors, and returns JSON stringified result.export const tokenList = async (args: z.infer<typeof chainParamsSchema>) => { try { const inputChain = args.chain.toLowerCase(); const chainObject = getChainFromName(inputChain); console.error(`[TOKEN_LIST] Using chain: ${chainObject.name}`); const service = new ChainService(); const tokenList = await service.tokenList(chainObject.id); if (tokenList instanceof Error) { return `Error fetching tokenList: ${tokenList.message}`; } return JSON.stringify(tokenList, null, 2); } catch (error: unknown) { const message = error instanceof Error ? error.message : "An unknown error occurred while fetching tokenList."; console.error(`[TOKEN_LIST] Error: ${message}`); throw new Error(`Failed to fetch tokenList: ${message}`); } }
- src/types.ts:4-12 (schema)Zod schema defining the input parameters for the TOKEN_LIST tool: optional chain name defaulting to 'fraxtal'.export const chainParamsSchema = z.object({ chain: z .string() .optional() .describe( "The blockchain network to execute the transaction on. uses fraxtal as default", ) .default("fraxtal") });
- src/tools/index.ts:10-15 (registration)Tool definition object for TOKEN_LIST, including name, description, parameters schema, and reference to the execute handler.tokenList: { name: "TOKEN_LIST", description: "Get token list", parameters: chainParamsSchema, execute: chainExecute.tokenList },
- src/index.ts:14-14 (registration)Registers the TOKEN_LIST tool with the FastMCP server instance.server.addTool(tools.tokenList);