get_price
Retrieve current token prices for trading simulation by specifying token addresses and optional blockchain parameters to support informed decision-making.
Instructions
Get the current price for a token
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| token | Yes | Token address | |
| chain | No | Optional blockchain type | |
| specificChain | No | Optional specific chain for EVM tokens |
Implementation Reference
- src/index.ts:160-185 (registration)Registration of the 'get_price' MCP tool, including name, description, and input schema definition.{ name: "get_price", description: "Get the current price for a token", inputSchema: { type: "object", properties: { token: { type: "string", description: "Token address" }, chain: { type: "string", enum: ["svm", "evm"], description: "Optional blockchain type" }, specificChain: { type: "string", enum: ["eth", "polygon", "bsc", "arbitrum", "base", "optimism", "avalanche", "linea", "svm"], description: "Optional specific chain for EVM tokens" } }, required: ["token"], additionalProperties: false, $schema: "http://json-schema.org/draft-07/schema#" } },
- src/index.ts:495-509 (handler)MCP server handler for the 'get_price' tool: validates input arguments, extracts parameters, calls tradingClient.getPrice(), and returns the response.case "get_price": { if (!args || typeof args !== "object" || !("token" in args)) { throw new Error("Invalid arguments for get_price"); } const token = args.token as string; const chain = "chain" in args ? args.chain as BlockchainType : undefined; const specificChain = "specificChain" in args ? args.specificChain as SpecificChain : undefined; const response = await tradingClient.getPrice(token, chain, specificChain); return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }], isError: false }; }
- src/api-client.ts:332-349 (helper)Core implementation of getPrice in TradingSimulatorClient: constructs query parameters and makes HTTP GET request to the backend API endpoint /api/price.async getPrice( token: string, chain?: BlockchainType, specificChain?: SpecificChain ): Promise<PriceResponse | ErrorResponse> { const params = new URLSearchParams(); params.append('token', token); if (chain) params.append('chain', chain); if (specificChain) params.append('specificChain', specificChain); return this.request<PriceResponse>( 'GET', `/api/price?${params.toString()}`, null, 'get token price' ); }