TOKEN_LIST
Retrieve available tokens for trading on a specified blockchain network through the OpenOcean MCP server.
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-57 (handler)The main handler function that executes the TOKEN_LIST tool. It resolves the chain, calls ChainService.tokenList, handles errors, and returns JSON stringified token list.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, defaults 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-14 (registration)Tool registration object exporting the TOKEN_LIST tool with name, description, input schema, and handler reference.tokenList: { name: "TOKEN_LIST", description: "Get token list", parameters: chainParamsSchema, execute: chainExecute.tokenList