Skip to main content
Glama
maven81g

TradeStation MCP Server

by maven81g

getOrders

Retrieve order history from TradeStation accounts with status filtering options to track trading activity.

Instructions

Get order history with optional status filter

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accountIdNoAccount ID (optional, uses TRADESTATION_ACCOUNT_ID from env if not provided)
statusNoFilter orders by statusAll

Implementation Reference

  • Handler function that fetches account orders from TradeStation API, optionally filtering by status (Open, Filled, etc.). Uses makeAuthenticatedRequest helper.
    async (args) => {
      try {
        const accountId = args.accountId || TS_ACCOUNT_ID;
        const { status } = args;
    
        if (!accountId) {
          throw new Error('Account ID is required. Either provide accountId parameter or set TRADESTATION_ACCOUNT_ID in .env file.');
        }
    
        let endpoint = `/brokerage/accounts/${encodeURIComponent(accountId)}/orders`;
    
        if (status && status !== 'All') {
          endpoint += `?status=${status}`;
        }
    
        const orders = await makeAuthenticatedRequest(endpoint);
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(orders, null, 2)
            }
          ]
        };
      } catch (error: unknown) {
        return {
          content: [
            {
              type: "text",
              text: `Failed to fetch orders: ${error instanceof Error ? error.message : 'Unknown error'}`
            }
          ],
          isError: true
        };
      }
    }
  • Input schema for getOrders tool using Zod validation: optional accountId and status filter (defaults to 'All').
    const ordersSchema = {
      accountId: z.string().optional().describe('Account ID (optional, uses TRADESTATION_ACCOUNT_ID from env if not provided)'),
      status: z.enum(['Open', 'Filled', 'Canceled', 'Rejected', 'All'])
        .default('All')
        .describe('Filter orders by status')
    };
  • src/index.ts:547-588 (registration)
    MCP server registration of the 'getOrders' tool with description, schema reference, and inline handler function.
    server.tool(
      "getOrders",
      "Get order history with optional status filter",
      ordersSchema,
      async (args) => {
        try {
          const accountId = args.accountId || TS_ACCOUNT_ID;
          const { status } = args;
    
          if (!accountId) {
            throw new Error('Account ID is required. Either provide accountId parameter or set TRADESTATION_ACCOUNT_ID in .env file.');
          }
    
          let endpoint = `/brokerage/accounts/${encodeURIComponent(accountId)}/orders`;
    
          if (status && status !== 'All') {
            endpoint += `?status=${status}`;
          }
    
          const orders = await makeAuthenticatedRequest(endpoint);
    
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(orders, null, 2)
              }
            ]
          };
        } catch (error: unknown) {
          return {
            content: [
              {
                type: "text",
                text: `Failed to fetch orders: ${error instanceof Error ? error.message : 'Unknown error'}`
              }
            ],
            isError: true
          };
        }
      }
    );
Behavior2/5

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

With no annotations provided, the description carries full burden but only states the basic function. It doesn't disclose important behavioral traits like whether this is a read-only operation, if it requires authentication, rate limits, pagination behavior, or what format the order history returns. The description is minimal and lacks necessary context for safe invocation.

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?

The description is a single, efficient sentence with zero waste. It's appropriately sized for a simple retrieval tool and front-loads the core purpose immediately.

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

Completeness2/5

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

Given no annotations and no output schema, the description is incomplete for a tool that retrieves potentially sensitive order data. It should explain what information is returned, any authentication requirements, and behavioral constraints. The current description provides only basic functional intent without necessary operational context.

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?

Schema description coverage is 100%, so the schema already fully documents both parameters. The description mentions 'optional status filter' which aligns with the schema's status parameter, but adds no additional semantic context beyond what the schema provides. Baseline 3 is appropriate when schema does the heavy lifting.

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

Purpose4/5

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

The description clearly states the verb 'Get' and resource 'order history' with the specific capability of 'optional status filter'. It distinguishes from sibling tools like getOrderDetails (specific order) and getExecutions (filled trades), but doesn't explicitly mention these distinctions in the description itself.

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

Usage Guidelines3/5

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

The description implies usage for retrieving order history with optional filtering, but doesn't provide explicit guidance on when to use this vs. alternatives like getOrderDetails (for specific orders) or getExecutions (for filled trades). No prerequisites or exclusions are mentioned.

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/maven81g/tradestation_mcp'

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