Skip to main content
Glama
harshil1502

tradingview-mcp

by harshil1502

screenshot_chart

Capture the current chart pane as a base64-encoded PNG image for programmatic use or storage.

Instructions

Capture the chart pane as a base64-encoded PNG.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler for the screenshot_chart tool. Calls page.screenshotChart() and wraps errors in ToolExecutionError.
    export async function screenshotChart(
      _input: z.infer<typeof screenshotChartInput>,
      page: TradingViewPage,
    ): Promise<z.infer<typeof screenshotChartOutput>> {
      try {
        return await page.screenshotChart();
      } catch (cause) {
        throw new ToolExecutionError(
          'screenshot_chart',
          'Failed to capture chart screenshot.',
          cause,
        );
      }
    }
  • Input and output Zod schemas for screenshot_chart. Input is an empty strict object; output is the shared screenshotOutputSchema (format, data, width, height).
    export const screenshotChartInput = z.object({}).strict();
    export const screenshotChartOutput = screenshotOutputSchema;
  • Registration of screenshot_chart in the TOOLS array with name, description, input/output schemas, and the handler function.
    // --- screenshot ---
    {
      name: 'screenshot_chart',
      description: 'Capture the chart pane as a base64-encoded PNG.',
      input: screenshotChartInput,
      output: screenshotChartOutput,
      handler: screenshotChart,
    },
  • The low-level TradingViewPage method that performs the screenshot. Currently delegates to screenshotFull() as a v0.1 workaround; planned v0.2 improvement to clip to .chart-container.
    async screenshotChart(): Promise<Screenshot> {
      // TODO(v0.2): clip to `.chart-container` bounding rect via CDP
      // Page.captureScreenshot `clip` parameter once selector is stable.
      return this.screenshotFull();
    }
  • The screenshotFull() helper that screenshotChart currently delegates to. Uses CDP to capture full viewport as base64 PNG and returns Screenshot object.
    /** Capture the full TradingView viewport as a base64 PNG. */
    async screenshotFull(): Promise<Screenshot> {
      const data = await this.cdp.screenshot();
      const dims = await this.cdp.evaluate<{ width: number; height: number }>(
        `({ width: window.innerWidth, height: window.innerHeight })`,
      );
      return { format: 'png', data, width: dims.width, height: dims.height };
    }
Behavior3/5

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

With no annotations, the description carries the full burden. It correctly implies a read operation ('capture') but does not mention potential side effects, error conditions (e.g., no chart loaded), or authentication needs. It is adequate but not thorough.

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, concise sentence that conveys all necessary information. It is front-loaded with the core purpose and efficiently structured.

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

Completeness4/5

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

Given no parameters and no output schema, the description is largely complete. It specifies the action and output format. However, additional context about when the tool might fail or prerequisites would improve completeness.

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

Parameters4/5

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

The input schema has zero parameters, so baseline is 4. The description adds value by specifying the output format (base64-encoded PNG), which is beyond the schema. However, there is no additional semantic enrichment for parameters.

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 action ('capture'), the target ('chart pane'), and the output format ('base64-encoded PNG'). It is specific and distinguishes from the sibling tool 'screenshot_full' which captures the full screen.

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 the tool is used when needing a chart pane screenshot, but provides no explicit guidance on when to use it versus alternatives or any prerequisites (e.g., a chart must be open).

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/harshil1502/tradingview-mcp'

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