Skip to main content
Glama

Trading Simulator MCP Server

by recallnet

execute_trade

Facilitates token trades on the Trading Simulator MCP Server by specifying source and destination tokens, amounts, and optional parameters like slippage tolerance and blockchain chains for accurate execution.

Instructions

Execute a trade between tokens

Input Schema

NameRequiredDescriptionDefault
amountYesAmount of fromToken to trade
fromChainNoOptional blockchain type for source token
fromSpecificChainNoOptional specific chain for source token
fromTokenYesSource token address
reasonYesReason for executing this trade
slippageToleranceNoOptional slippage tolerance percentage (e.g., '0.5' for 0.5%)
toChainNoOptional blockchain type for destination token
toSpecificChainNoOptional specific chain for destination token
toTokenYesDestination token address

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "amount": { "description": "Amount of fromToken to trade", "type": "string" }, "fromChain": { "description": "Optional blockchain type for source token", "enum": [ "svm", "evm" ], "type": "string" }, "fromSpecificChain": { "description": "Optional specific chain for source token", "enum": [ "eth", "polygon", "bsc", "arbitrum", "base", "optimism", "avalanche", "linea", "svm" ], "type": "string" }, "fromToken": { "description": "Source token address", "type": "string" }, "reason": { "description": "Reason for executing this trade", "type": "string" }, "slippageTolerance": { "description": "Optional slippage tolerance percentage (e.g., '0.5' for 0.5%)", "type": "string" }, "toChain": { "description": "Optional blockchain type for destination token", "enum": [ "svm", "evm" ], "type": "string" }, "toSpecificChain": { "description": "Optional specific chain for destination token", "enum": [ "eth", "polygon", "bsc", "arbitrum", "base", "optimism", "avalanche", "linea", "svm" ], "type": "string" }, "toToken": { "description": "Destination token address", "type": "string" } }, "required": [ "fromToken", "toToken", "amount", "reason" ], "type": "object" }

Implementation Reference

  • The handler function for the 'execute_trade' tool. Validates the input arguments, constructs TradeParams, and calls tradingClient.executeTrade to perform the trade.
    case "execute_trade": { if (!args || typeof args !== "object" || !("fromToken" in args) || !("toToken" in args) || !("amount" in args) || !("reason" in args)) { throw new Error("Invalid arguments for execute_trade"); } const tradeExecParams: TradeParams = { fromToken: args.fromToken as string, toToken: args.toToken as string, amount: args.amount as string, reason: args.reason as string }; if ("slippageTolerance" in args) tradeExecParams.slippageTolerance = args.slippageTolerance as string; if ("fromChain" in args) tradeExecParams.fromChain = args.fromChain as BlockchainType; if ("toChain" in args) tradeExecParams.toChain = args.toChain as BlockchainType; if ("fromSpecificChain" in args) tradeExecParams.fromSpecificChain = args.fromSpecificChain as SpecificChain; if ("toSpecificChain" in args) tradeExecParams.toSpecificChain = args.toSpecificChain as SpecificChain; const response = await tradingClient.executeTrade(tradeExecParams); return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }], isError: false }; }
  • Tool definition including name, description, and detailed input schema for 'execute_trade'.
    name: "execute_trade", description: "Execute a trade between tokens", inputSchema: { type: "object", properties: { fromToken: { type: "string", description: "Source token address" }, toToken: { type: "string", description: "Destination token address" }, amount: { type: "string", description: "Amount of fromToken to trade" }, reason: { type: "string", description: "Reason for executing this trade" }, slippageTolerance: { type: "string", description: "Optional slippage tolerance percentage (e.g., '0.5' for 0.5%)" }, fromChain: { type: "string", enum: ["svm", "evm"], description: "Optional blockchain type for source token" }, toChain: { type: "string", enum: ["svm", "evm"], description: "Optional blockchain type for destination token" }, fromSpecificChain: { type: "string", enum: ["eth", "polygon", "bsc", "arbitrum", "base", "optimism", "avalanche", "linea", "svm"], description: "Optional specific chain for source token" }, toSpecificChain: { type: "string", enum: ["eth", "polygon", "bsc", "arbitrum", "base", "optimism", "avalanche", "linea", "svm"], description: "Optional specific chain for destination token" } }, required: ["fromToken", "toToken", "amount", "reason"], additionalProperties: false, $schema: "http://json-schema.org/draft-07/schema#" } },
  • src/index.ts:411-415 (registration)
    Registration of all tools, including 'execute_trade', via the ListToolsRequestSchema handler.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: TRADING_SIM_TOOLS }; });
  • TypeScript interface defining the TradeParams used in the execute_trade handler.
    export interface TradeParams { fromToken: string; toToken: string; amount: string; reason: string; slippageTolerance?: string; fromChain?: BlockchainType; toChain?: BlockchainType; fromSpecificChain?: SpecificChain; toSpecificChain?: SpecificChain; }

Other Tools

Related Tools

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/recallnet/trading-simulator-mcp'

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