get_quote
Obtain swap quotes for token trading on Casper Network, showing amounts, price impact, and routing paths before executing trades.
Instructions
Get a swap quote for trading between two tokens. Returns amounts, price impact, and routing path.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| token_in | Yes | Input token: symbol (e.g., "CSPR"), name, or contract hash | |
| token_out | Yes | Output token: symbol (e.g., "USDT"), name, or contract hash | |
| amount | Yes | Human-readable amount (e.g., "100" for 100 CSPR) | |
| type | Yes | "exact_in" = specify input amount, "exact_out" = specify desired output amount |
Implementation Reference
- packages/mcp/src/tools/market-data.ts:51-64 (registration)Registration of the 'get_quote' tool within the MCP server, defining its schema and handler function.
server.tool( 'get_quote', 'Get a swap quote for trading between two tokens. Returns amounts, price impact, and routing path.', { token_in: z.string().describe('Input token: symbol (e.g., "CSPR"), name, or contract hash'), token_out: z.string().describe('Output token: symbol (e.g., "USDT"), name, or contract hash'), amount: z.string().describe('Human-readable amount (e.g., "100" for 100 CSPR)'), type: z.enum(['exact_in', 'exact_out']).describe('"exact_in" = specify input amount, "exact_out" = specify desired output amount'), }, async ({ token_in, token_out, amount, type }) => { const quote = await client.getQuote({ tokenIn: token_in, tokenOut: token_out, amount, type }); return { content: [{ type: 'text' as const, text: JSON.stringify(quote, null, 2) }] }; }, ); - Handler implementation for 'get_quote' which calls client.getQuote.
async ({ token_in, token_out, amount, type }) => { const quote = await client.getQuote({ tokenIn: token_in, tokenOut: token_out, amount, type }); return { content: [{ type: 'text' as const, text: JSON.stringify(quote, null, 2) }] }; },