Skip to main content
Glama

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
NameRequiredDescriptionDefault
token0YesThe address of the first token
token1YesThe address of the second token

Implementation Reference

  • 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 }; },
  • 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", }, ], }; } }) }
  • 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,

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/tamago-labs/tapp-exchange-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server