Skip to main content
Glama
maven81g

TradeStation MCP Server

by maven81g

barChart

Retrieve historical price bars and candlestick data for trading symbols to analyze market trends and patterns.

Instructions

Get historical price bars/candles

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYesTrading symbol
intervalYesBar interval value (e.g., 1, 5, 15)
unitYesBar interval unit
beginTimeNoBegin time in ISO format (optional)
endTimeNoEnd time in ISO format (optional)
barsBackNoNumber of bars to return (optional)

Implementation Reference

  • Handler function that parses input parameters, constructs the TradeStation API endpoint for bar chart data, authenticates and fetches the historical price bars, and returns the JSON response or error.
    async ({ arguments: args }) => {
      try {
        const { symbol, interval, unit, beginTime, endTime, barsBack } = args;
        const userId = args.userId; // You might need to pass this differently
        
        let endpoint = `/marketdata/barcharts/${encodeURIComponent(symbol)}?interval=${interval}&unit=${unit}`;
        
        if (beginTime) {
          endpoint += `&begin=${encodeURIComponent(beginTime)}`;
        }
        
        if (endTime) {
          endpoint += `&end=${encodeURIComponent(endTime)}`;
        }
        
        if (barsBack) {
          endpoint += `&barsback=${barsBack}`;
        }
        
        const bars = await makeAuthenticatedRequest(userId, endpoint);
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(bars, null, 2)
            }
          ]
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `Failed to fetch bar chart data: ${error.message}`
            }
          ],
          isError: true
        };
      }
    }
  • Zod schema defining the input parameters for the barChart tool: symbol (required), interval (number), unit (enum), and optional beginTime, endTime, barsBack.
    const barChartSchema = z.object({
      symbol: z.string().describe('Trading symbol'),
      interval: z.number().describe('Bar interval value (e.g., 1, 5, 15)'),
      unit: z.enum(['Minute', 'Daily', 'Weekly', 'Monthly']).describe('Bar interval unit'),
      beginTime: z.string().optional().describe('Begin time in ISO format (optional)'),
      endTime: z.string().optional().describe('End time in ISO format (optional)'),
      barsBack: z.number().optional().describe('Number of bars to return (optional)')
    });
  • index.js:458-502 (registration)
    Registers the barChart tool with the MCP server using server.tool(), providing name, description, input schema, and handler function.
    server.tool(
      "barChart",
      "Get historical price bars/candles",
      barChartSchema,
      async ({ arguments: args }) => {
        try {
          const { symbol, interval, unit, beginTime, endTime, barsBack } = args;
          const userId = args.userId; // You might need to pass this differently
          
          let endpoint = `/marketdata/barcharts/${encodeURIComponent(symbol)}?interval=${interval}&unit=${unit}`;
          
          if (beginTime) {
            endpoint += `&begin=${encodeURIComponent(beginTime)}`;
          }
          
          if (endTime) {
            endpoint += `&end=${encodeURIComponent(endTime)}`;
          }
          
          if (barsBack) {
            endpoint += `&barsback=${barsBack}`;
          }
          
          const bars = await makeAuthenticatedRequest(userId, endpoint);
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(bars, null, 2)
              }
            ]
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Failed to fetch bar chart data: ${error.message}`
              }
            ],
            isError: true
          };
        }
      }
    );
  • TypeScript handler function for barChart tool, similar to JS version, constructs endpoint and fetches data using makeAuthenticatedRequest.
    async (args) => {
      try {
        const { symbol, interval, unit, beginTime, endTime, barsBack } = args;
        
        let endpoint = `/marketdata/barcharts/${encodeURIComponent(symbol)}?interval=${interval}&unit=${unit}`;
        
        if (beginTime) {
          endpoint += `&begin=${encodeURIComponent(beginTime)}`;
        }
        
        if (endTime) {
          endpoint += `&end=${encodeURIComponent(endTime)}`;
        }
        
        if (barsBack) {
          endpoint += `&barsback=${barsBack}`;
        }
        
        const bars = await makeAuthenticatedRequest(endpoint);
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(bars, null, 2)
            }
          ]
        };
      } catch (error: unknown) {
        return {
          content: [
            {
              type: "text",
              text: `Failed to fetch bar chart data: ${error instanceof Error ? error.message : 'Unknown error'}`
            }
          ],
          isError: true
        };
      }
    }
  • Input schema object for barChart tool parameters in TypeScript version.
    const barChartSchema = {
      symbol: z.string().describe('Trading symbol'),
      interval: z.number().describe('Bar interval value (e.g., 1, 5, 15)'),
      unit: z.enum(['Minute', 'Daily', 'Weekly', 'Monthly']).describe('Bar interval unit'),
      beginTime: z.string().optional().describe('Begin time in ISO format (optional)'),
      endTime: z.string().optional().describe('End time in ISO format (optional)'),
      barsBack: z.number().optional().describe('Number of bars to return (optional)')
    };
Behavior2/5

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

No annotations are provided, so the description carries full burden for behavioral disclosure. 'Get' implies a read operation, but the description doesn't mention rate limits, authentication requirements, data freshness, or what happens when optional parameters are omitted. This leaves significant gaps for a tool with 6 parameters.

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 that immediately communicates the core functionality. There's no wasted language or unnecessary elaboration, making it optimally concise while still being informative.

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?

For a tool with 6 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain what the returned data looks like, how bars/candles are structured, or provide any context about data sources, limitations, or typical use cases. The agent would need to guess about important behavioral aspects.

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%, providing complete parameter documentation. The description adds no additional parameter information beyond what's already in the schema, so it meets the baseline expectation but doesn't enhance understanding of parameter usage or relationships.

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 action ('Get') and resource ('historical price bars/candles'), making the tool's purpose immediately understandable. However, it doesn't differentiate itself from potential siblings like 'marketData' or other data retrieval tools, which prevents a perfect score.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. With siblings like 'marketData' and 'getSymbolDetails' available, there's no indication of what makes this tool distinct or when it should be preferred over other data retrieval methods.

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