get_supported_tokens
Retrieves a list of supported tokens for a specific blockchain or across all chains, optionally including testnet tokens, leveraging the ValueRouter MCP Server for multi-chain USDC bridging.
Instructions
Get supported tokens for a specific chain or all chains
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chainId | No | Chain ID to get tokens for (optional) | |
| includeTestnets | No | Whether to include testnet tokens |
Input Schema (JSON Schema)
{
"additionalProperties": false,
"properties": {
"chainId": {
"description": "Chain ID to get tokens for (optional)",
"oneOf": [
{
"type": "number"
},
{
"type": "string"
}
]
},
"includeTestnets": {
"default": false,
"description": "Whether to include testnet tokens",
"type": "boolean"
}
},
"type": "object"
}
Implementation Reference
- src/services/quote.ts:65-105 (handler)Core handler function in QuoteService that implements the logic to retrieve supported tokens for a specific chain or all supported chains, filtering by testnets and using getTokensForChain helper.async getSupportedTokens(request: SupportedTokensRequest): Promise<SupportedTokensResponse> { const { chainId, includeTestnets = false } = request; if (chainId) { const chainIdTyped = chainId as SupportedChainId; const chainInfo = CHAIN_INFO[chainIdTyped]; if (!chainInfo) { throw new Error(`Unsupported chain: ${chainId}`); } if (!includeTestnets && chainInfo.isTestnet) { return { tokens: [], chains: [] }; } const tokens = await this.getTokensForChain(chainIdTyped); return { tokens, chains: [chainInfo], }; } // Get tokens for all chains const allTokens: Token[] = []; const allChains: typeof CHAIN_INFO[keyof typeof CHAIN_INFO][] = []; for (const [chainId, chainInfo] of Object.entries(CHAIN_INFO)) { if (!includeTestnets && chainInfo.isTestnet) { continue; } const tokens = await this.getTokensForChain(chainId as SupportedChainId); allTokens.push(...tokens); allChains.push(chainInfo); } return { tokens: allTokens, chains: allChains, }; }
- src/index.ts:385-396 (handler)MCP server handler for 'get_supported_tokens' tool that parses input arguments using Zod schema and delegates to QuoteService.getSupportedTokens.private async getSupportedTokens(args: any): Promise<MCPToolResult> { try { const request = SupportedTokensRequestSchema.parse(args); const result = await this.quoteService.getSupportedTokens(request); return createSuccessResponse(result); } catch (error) { return createErrorResponse( error instanceof Error ? error.message : String(error), 'INVALID_REQUEST' ); } }
- src/index.ts:79-98 (registration)Tool registration in the listTools handler, defining the name, description, and input schema for 'get_supported_tokens'.name: 'get_supported_tokens', description: 'Get supported tokens for a specific chain or all chains', inputSchema: { type: 'object', properties: { chainId: { oneOf: [ { type: 'number' }, { type: 'string' }, ], description: 'Chain ID to get tokens for (optional)', }, includeTestnets: { type: 'boolean', description: 'Whether to include testnet tokens', default: false, }, }, additionalProperties: false, },
- src/types/index.ts:166-171 (schema)Zod schema and TypeScript type definition for the SupportedTokensRequest input used for validation in the tool handler.export const SupportedTokensRequestSchema = z.object({ chainId: z.union([z.number(), z.string()]).optional(), includeTestnets: z.boolean().optional().default(false), }); export type SupportedTokensRequest = z.infer<typeof SupportedTokensRequestSchema>;
- src/services/quote.ts:237-262 (helper)Helper function that retrieves the list of supported tokens (native and USDC) for a given chain using constants.private async getTokensForChain(chainId: SupportedChainId): Promise<Token[]> { const chainInfo = CHAIN_INFO[chainId]; const tokens: Token[] = []; // Add native token if (NATIVE_TOKENS[chainId]) { tokens.push(NATIVE_TOKENS[chainId]); } // Add USDC if available if (chainInfo.usdcAddress) { tokens.push({ address: chainInfo.usdcAddress, chainId, symbol: 'USDC', name: 'USD Coin', decimals: 6, isNative: false, logoURI: 'https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/logo.png', }); } // For production, you'd fetch from token lists or APIs // For now, we'll return the basic tokens return tokens; }