tapp_get_swap_route
Retrieve the optimal swap route between two tokens on the Tapp Exchange MCP Server for efficient decentralized trading and liquidity management on the Aptos blockchain.
Instructions
Get the optimal route information between two tokens
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| token0 | Yes | The address of the first token | |
| token1 | Yes | The address of the second token |
Implementation Reference
- src/mcp/tapp/swap-tools.ts:37-43 (handler)MCP tool handler function that extracts token addresses from input, calls TappAgent.getSwapRoute, and returns the route in a standardized success response.handler: async (agent: TappAgent, input: Record<string, any>) => { const route = await agent.getSwapRoute(input.token0, input.token1); return { status: "success", route }; },
- src/mcp/tapp/swap-tools.ts:33-36 (schema)Zod-based input schema validating token0 and token1 as strings with descriptions.schema: { token0: z.string().describe("The address of the first token"), token1: z.string().describe("The address of the second token") },
- src/index.ts:20-52 (registration)Dynamic registration loop in MCP server creation that registers the tool by its name "tapp_get_swap_route", description, schema, and wrapped handler.for (const [_key, tool] of Object.entries(TappExchangeMcpTools)) { server.tool(tool.name, tool.description, tool.schema, async (params: any): Promise<any> => { try { // Execute the handler with the params directly const result = await tool.handler(agent, params); // Format the result as MCP tool response return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; } catch (error) { console.error("error", error); // Handle errors in MCP format return { isError: true, content: [ { type: "text", text: error instanceof Error ? error.message : "Unknown error occurred", }, ], }; } }) }
- src/agent/index.ts:247-250 (helper)Supporting method in TappAgent that delegates to the Tapp SDK's Swap.getRoute for obtaining the optimal swap route between two tokens.async getSwapRoute(token0: string, token1: string): Promise<any> { const route = await this.sdk.Swap.getRoute(token0, token1); return route; }
- src/mcp/index.ts:32-32 (registration)Inclusion of the GetSwapRouteTool in the TappExchangeMcpTools object used for MCP server registration."GetSwapRouteTool": GetSwapRouteTool,