Skip to main content
Glama
jun229

truemarkets-mcp-server

by jun229

Execute a quoted trade

tm_execute_trade
Destructive

Execute irreversible trades on True Markets by signing and submitting validated quotes within 60 seconds using Turnkey API authentication.

Instructions

Execute a trade using a quote_id from tm_get_quote.

IMPORTANT: Only call this after inspecting the quote from tm_get_quote. The quote must be less than 60 seconds old and have no issues.

This tool signs the quote payloads with the user's Turnkey API key and submits the trade. It is irreversible.

Args:

  • quote_id (string): The quote_id from tm_get_quote

Returns: { success, order_id, tx_hash, explorer_url }

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
quote_idYesquote_id from tm_get_quote

Implementation Reference

  • The handler function for 'tm_execute_trade' that retrieves a cached quote, signs its payloads using the provided signer, and executes the trade via the API.
      async ({ quote_id }) => {
        const quote = getCachedQuote(quote_id);
        if (!quote) {
          return {
            isError: true,
            content: [{
              type: "text",
              text: "Quote expired or not found. Call tm_get_quote to get a fresh quote.",
            }],
          };
        }
    
        if (quote.issues.length > 0) {
          return {
            isError: true,
            content: [{
              type: "text",
              text: `Quote has issues: ${quote.issues.map((i) => i.message).join(", ")}. Cannot execute.`,
            }],
          };
        }
    
        if (!quote.payloads || quote.payloads.length === 0) {
          return {
            isError: true,
            content: [{ type: "text", text: "Quote has no payloads to sign." }],
          };
        }
    
        // Sign payloads
        const signer = getSigner();
        const signatures = signer.signAll(quote.payloads);
    
        // Execute
        const result = await api.executeTrade({
          quote_id: quote.quote_id,
          signatures,
          auth_type: "api_key",
        });
    
        // Clean up cache
        quoteCache.delete(quote_id);
    
        const chain = quote.base_asset.startsWith("0x") ? "base" : "solana";
        const explorerUrl = result.tx_hash
          ? txExplorerUrl(chain, result.tx_hash)
          : null;
    
        const output = {
          success: true,
          order_id: result.order_id ?? null,
          tx_hash: result.tx_hash ?? null,
          explorer_url: explorerUrl,
        };
    
        return {
          content: [{ type: "text", text: JSON.stringify(output, null, 2) }],
          structuredContent: output,
        };
      }
    );
  • Registration of the 'tm_execute_trade' tool within the McpServer.
      // ─── tm_execute_trade ────────────────────────────────────────
      server.registerTool(
        "tm_execute_trade",
        {
          title: "Execute a quoted trade",
          description: `Execute a trade using a quote_id from tm_get_quote.
    
    IMPORTANT: Only call this after inspecting the quote from tm_get_quote.
    The quote must be less than 60 seconds old and have no issues.
    
    This tool signs the quote payloads with the user's Turnkey API key
    and submits the trade. It is irreversible.
    
    Args:
      - quote_id (string): The quote_id from tm_get_quote
    
    Returns: { success, order_id, tx_hash, explorer_url }`,
          inputSchema: {
            quote_id: z.string().describe("quote_id from tm_get_quote"),
          },
          annotations: {
            readOnlyHint: false,
            destructiveHint: true,
            idempotentHint: false,
            openWorldHint: true,
          },
        },
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description adds valuable behavioral context beyond annotations: it explains the irreversible nature of the trade (reinforcing destructiveHint=true), mentions signing with API keys (security context), and specifies time constraints (60-second validity). While annotations cover safety aspects, the description provides operational details that help the agent use the tool correctly.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Perfectly structured with critical information front-loaded: purpose, prerequisites, and warnings in the first sentences. Every sentence earns its place by providing essential guidance. The Args/Returns section is clear without redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a destructive trade execution tool with no output schema, the description provides excellent completeness: it explains the irreversible nature, prerequisites, timing constraints, and even outlines the return structure. Given the complexity and risk level, this description gives the agent everything needed to use the tool safely and correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 100% schema description coverage, the schema already documents the single parameter thoroughly. The description adds minimal extra context by linking quote_id to tm_get_quote, but doesn't provide additional semantic meaning beyond what's in the schema. This meets the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Execute a trade') and resource ('using a quote_id from tm_get_quote'), distinguishing it from siblings like tm_execute_transfer (transfers) and tm_get_quote (quotes only). It provides a complete picture of the tool's function beyond just the title.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly states when to use ('Only call this after inspecting the quote from tm_get_quote') and includes critical prerequisites ('quote must be less than 60 seconds old and have no issues'). It also distinguishes from tm_get_quote by specifying this is the execution step after obtaining a quote.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/jun229/tm-mcp-server'

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