Skip to main content
Glama
jwaresolutions

Polygon MCP Server

get_aggregates

Retrieve aggregated financial market data for a specific ticker symbol over defined time periods. Specify ticker, time range, and interval to access historical price bars for analysis.

Instructions

Get aggregate bars for a ticker

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tickerYesTicker symbol (e.g., AAPL)
timespanYesSize of the time window
fromYesStart date (YYYY-MM-DD format)
toYesEnd date (YYYY-MM-DD format)
adjustedNoWhether to adjust for splits (default: true)
sortNoSort order (default: asc)
limitNoNumber of results (default: 120, max: 50000)

Implementation Reference

  • The async handler function that implements the 'get_aggregates' tool logic, calling the Polygon API to retrieve aggregate bars (OHLCV data) for a ticker over a specified date range and timespan.
    get_aggregates: async (args: { 
      ticker: string; 
      timespan: string; 
      from: string; 
      to: string;
      adjusted?: boolean;
      sort?: string;
      limit?: number;
    }) => {
      try {
        const params: any = {
          adjusted: args.adjusted !== false,
          sort: args.sort || 'asc',
          limit: args.limit || 120
        };
    
        const response = await polygonApi.get(
          `/v2/aggs/ticker/${args.ticker}/range/1/${args.timespan}/${args.from}/${args.to}`,
          { params }
        );
        return {
          content: [{
            type: "text",
            text: JSON.stringify(response.data, null, 2)
          }]
        };
      } catch (error: any) {
        return {
          content: [{
            type: "text",
            text: `Error getting aggregates: ${error.response?.data?.message || error.message}`
          }],
          isError: true
        };
      }
    },
  • The input schema definition for the 'get_aggregates' tool, specifying parameters like ticker, timespan, date range, and options for the API call.
    inputSchema: {
      type: "object",
      properties: {
        ticker: {
          type: "string",
          description: "Ticker symbol (e.g., AAPL)"
        },
        timespan: {
          type: "string",
          enum: ["minute", "hour", "day", "week", "month", "quarter", "year"],
          description: "Size of the time window"
        },
        from: {
          type: "string",
          description: "Start date (YYYY-MM-DD format)"
        },
        to: {
          type: "string",
          description: "End date (YYYY-MM-DD format)"
        },
        adjusted: {
          type: "boolean",
          description: "Whether to adjust for splits (default: true)"
        },
        sort: {
          type: "string",
          enum: ["asc", "desc"],
          description: "Sort order (default: asc)"
        },
        limit: {
          type: "number",
          description: "Number of results (default: 120, max: 50000)"
        }
      },
      required: ["ticker", "timespan", "from", "to"]
    }
  • src/index.ts:272-311 (registration)
    The tool registration in the ListTools response, including name, description, and input schema.
    {
      name: "get_aggregates",
      description: "Get aggregate bars for a ticker",
      inputSchema: {
        type: "object",
        properties: {
          ticker: {
            type: "string",
            description: "Ticker symbol (e.g., AAPL)"
          },
          timespan: {
            type: "string",
            enum: ["minute", "hour", "day", "week", "month", "quarter", "year"],
            description: "Size of the time window"
          },
          from: {
            type: "string",
            description: "Start date (YYYY-MM-DD format)"
          },
          to: {
            type: "string",
            description: "End date (YYYY-MM-DD format)"
          },
          adjusted: {
            type: "boolean",
            description: "Whether to adjust for splits (default: true)"
          },
          sort: {
            type: "string",
            enum: ["asc", "desc"],
            description: "Sort order (default: asc)"
          },
          limit: {
            type: "number",
            description: "Number of results (default: 120, max: 50000)"
          }
        },
        required: ["ticker", "timespan", "from", "to"]
      }
    },
  • src/index.ts:405-407 (registration)
    The dynamic dispatch mechanism in the CallToolRequest handler that routes calls to the appropriate tool handler based on name.
    if (name in toolHandlers) {
      return await (toolHandlers as any)[name](args || {});
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure but only states the basic action without details on rate limits, authentication needs, error handling, or output format. It doesn't mention whether this is a read-only operation, if it has side effects, or any performance considerations, which are critical for an agent to use it effectively.

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, clear sentence with no wasted words, making it highly concise and easy to parse. It front-loads the essential information ('Get aggregate bars for a ticker'), though it could benefit from more detail given the lack of annotations and sibling context.

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 the complexity of 7 parameters, no annotations, and no output schema, the description is incomplete. It doesn't explain what 'aggregate bars' are, how the output is structured, or any behavioral traits, leaving significant gaps for an agent to understand the tool's full context and usage.

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?

The schema description coverage is 100%, so the input schema fully documents all parameters with descriptions and enums. The description adds no additional meaning beyond the schema, such as explaining how 'aggregate bars' relate to parameters like 'timespan' or 'adjusted'. This meets the baseline for high schema coverage but doesn't enhance understanding.

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 ('aggregate bars for a ticker'), making the purpose understandable. However, it doesn't differentiate from sibling tools like 'get_daily_open_close' or 'get_latest_quote', which also retrieve financial data for tickers, leaving some ambiguity about when to choose this specific tool.

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 like 'get_daily_open_close' or 'get_latest_quote'. It lacks context about scenarios where aggregate bars are preferred over other data types, such as for time-series analysis or specific financial metrics, leaving the agent to infer usage from the tool name alone.

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/jwaresolutions/polygon-mcp-server'

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