Skip to main content
Glama

menese_swap

Swap tokens across 19 blockchain networks using native DEX protocols. Supports Ethereum, Solana, ICP, SUI, Cardano, XRP, and other chains with quote and execute modes.

Instructions

Swap tokens via DEX on supported chains. EVM: Uniswap V3 | Solana: Raydium | ICP: ICPSwap/KongSwap | SUI: Cetus | Cardano: Minswap | XRP: XRPL DEX.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chainYesChain to swap on
fromTokenYesSource token symbol or address
toTokenYesDestination token symbol or address
amountYesAmount of fromToken to swap (decimal)
slippageBpsNoSlippage tolerance in basis points (default 250 = 2.5%)
modeNo'quote' to preview swap, 'execute' to swap. Default: execute

Implementation Reference

  • The registerSwapTool function contains the server.registerTool definition for "menese_swap".
    export function registerSwapTool(
      server: McpServer,
      store: IdentityStore,
      config: MeneseConfig,
    ): void {
      server.registerTool(
        "menese_swap",
        {
          description:
            "Swap tokens via DEX on supported chains. " +
            "EVM: Uniswap V3 | Solana: Raydium | ICP: ICPSwap/KongSwap | SUI: Cetus | " +
            "Cardano: Minswap | XRP: XRPL DEX.",
          inputSchema: {
            chain: z.enum(SUPPORTED_CHAINS as unknown as [string, ...string[]]).describe("Chain to swap on"),
            fromToken: z.string().describe("Source token symbol or address"),
            toToken: z.string().describe("Destination token symbol or address"),
            amount: z.string().describe("Amount of fromToken to swap (decimal)"),
            slippageBps: z.number().min(1).max(5000).optional()
              .describe("Slippage tolerance in basis points (default 250 = 2.5%)"),
            mode: z.enum(["quote", "execute"]).optional()
              .describe("'quote' to preview swap, 'execute' to swap. Default: execute"),
          },
        },
        async ({ chain, fromToken, toToken, amount, slippageBps, mode }) => {
          const identity = store.get();
          if (!identity) {
            return { content: [{ type: "text" as const, text: "No wallet configured. Use menese_setup first." }], isError: true };
          }
    
          const guard = checkGuard("menese_swap", { chain, fromToken, toToken, amount, slippageBps, mode }, config);
          if (!guard.allowed) {
            return { content: [{ type: "text" as const, text: guard.reason! }], isError: true };
          }
    
          if (mode === "quote") {
            return {
              content: [{
                type: "text" as const,
                text: `Ready to swap ${amount} ${fromToken} → ${toToken} on ${chain} (slippage: ${slippageBps ?? 250}bps). Call again with mode "execute" to confirm.`,
              }],
            };
          }
    
          const result = await swapTokensOnChain(config, resolveActorIdentity(store), {
            chain, fromToken, toToken, amount, slippageBps,
          });
    
          if (result.ok) {
            invalidateBalanceCaches(store.getPrincipal()!);
          }
    
          return {
            content: [{
              type: "text" as const,
              text: JSON.stringify(result, bigIntReplacer, 2),
            }],
          };
        },
      );
    }
  • The async handler function for "menese_swap", which processes quotes and executes swaps.
    async ({ chain, fromToken, toToken, amount, slippageBps, mode }) => {
      const identity = store.get();
      if (!identity) {
        return { content: [{ type: "text" as const, text: "No wallet configured. Use menese_setup first." }], isError: true };
      }
    
      const guard = checkGuard("menese_swap", { chain, fromToken, toToken, amount, slippageBps, mode }, config);
      if (!guard.allowed) {
        return { content: [{ type: "text" as const, text: guard.reason! }], isError: true };
      }
    
      if (mode === "quote") {
        return {
          content: [{
            type: "text" as const,
            text: `Ready to swap ${amount} ${fromToken} → ${toToken} on ${chain} (slippage: ${slippageBps ?? 250}bps). Call again with mode "execute" to confirm.`,
          }],
        };
      }
    
      const result = await swapTokensOnChain(config, resolveActorIdentity(store), {
        chain, fromToken, toToken, amount, slippageBps,
      });
    
      if (result.ok) {
        invalidateBalanceCaches(store.getPrincipal()!);
      }
    
      return {
        content: [{
          type: "text" as const,
          text: JSON.stringify(result, bigIntReplacer, 2),
        }],
      };
    },
  • The inputSchema definition for "menese_swap" using Zod.
    inputSchema: {
      chain: z.enum(SUPPORTED_CHAINS as unknown as [string, ...string[]]).describe("Chain to swap on"),
      fromToken: z.string().describe("Source token symbol or address"),
      toToken: z.string().describe("Destination token symbol or address"),
      amount: z.string().describe("Amount of fromToken to swap (decimal)"),
      slippageBps: z.number().min(1).max(5000).optional()
        .describe("Slippage tolerance in basis points (default 250 = 2.5%)"),
      mode: z.enum(["quote", "execute"]).optional()
        .describe("'quote' to preview swap, 'execute' to swap. Default: execute"),
    },

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/Aboodtt404/mcp-menesesdk'

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