Skip to main content
Glama
recallnet

Trading Simulator MCP Server

by recallnet

execute_trade

Execute token trades in a simulated environment by specifying source and destination tokens, amount, and reason, with optional chain and slippage settings.

Instructions

Execute a trade between tokens

Input Schema

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

Implementation Reference

  • MCP CallToolRequest handler for execute_trade: validates input arguments, constructs TradeParams, calls tradingClient.executeTrade, and returns the response.
    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 }; }
  • TypeScript interface defining the TradeParams used for execute_trade input validation and typing.
    export interface TradeParams { fromToken: string; toToken: string; amount: string; reason: string; slippageTolerance?: string; fromChain?: BlockchainType; toChain?: BlockchainType; fromSpecificChain?: SpecificChain; toSpecificChain?: SpecificChain; }
  • src/index.ts:253-304 (registration)
    MCP Tool registration definition including name, description, and JSON schema for input validation.
    { 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#" } },
  • Helper method in TradingSimulatorClient that performs the actual API POST request to execute the trade.
    async executeTrade(params: TradeParams): Promise<TradeResponse | ErrorResponse> { if (this.debug) { logger.info('[ApiClient] executeTrade called with params:', JSON.stringify(params, null, 2)); } return this.request<TradeResponse>( 'POST', '/api/trade/execute', params, 'execute trade' ); }

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