Skip to main content
Glama
harshil1502

tradingview-mcp

by harshil1502

pine_set_source

Replace the current Pine Script code in TradingView's Pine Editor with new source code, including the required version header.

Instructions

Replace the Pine Editor source code with new content.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesNew Pine Script source code. Replaces the current editor contents entirely. Include `//@version=5` at the top.

Implementation Reference

  • Input schema for pine_set_source: expects a 'code' string with min length 1.
    export const pineSetSourceInput = z
      .object({
        code: z
          .string()
          .min(1)
          .describe(
            'New Pine Script source code. Replaces the current editor contents entirely. Include `//@version=5` at the top.',
          ),
      })
      .strict();
  • Output schema for pine_set_source: returns {ok: true, bytes: number}.
    export const pineSetSourceOutput = z.object({
      ok: z.literal(true),
      bytes: z.number().int().nonnegative(),
    });
  • Handler function that calls page.setPineSource(input.code) and returns {ok: true, bytes} or throws ToolExecutionError.
    export async function pineSetSource(
      input: z.infer<typeof pineSetSourceInput>,
      page: TradingViewPage,
    ): Promise<z.infer<typeof pineSetSourceOutput>> {
      try {
        await page.setPineSource(input.code);
        return { ok: true, bytes: input.code.length };
      } catch (cause) {
        throw new ToolExecutionError(
          'pine_set_source',
          'Failed to set Pine source. Is the Pine Editor open?',
          cause,
        );
      }
    }
  • Imports pineSetSource, pineSetSourceInput, pineSetSourceOutput from './pine.js'.
      pineSetSource,
      pineSetSourceInput,
      pineSetSourceOutput,
    } from './pine.js';
  • Registration entry: name 'pine_set_source', description, input/output schemas, and handler reference.
    {
      name: 'pine_set_source',
      description: 'Replace the Pine Editor source code with new content.',
      input: pineSetSourceInput,
      output: pineSetSourceOutput,
      handler: pineSetSource,
    },
Behavior3/5

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

With no annotations, the description must convey behavioral traits. It notes that the replacement is 'entirely,' indicating full overwrite. However, it omits important details such as whether the operation triggers compilation, validates syntax, or interacts with unsaved content. The description is minimal but not misleading.

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

Conciseness4/5

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

Extremely concise at 8 words. While efficient, it could be slightly expanded to include usage context (e.g., 'before compiling'). The single sentence is front-loaded but borderline under-specified for a set operation.

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

Completeness3/5

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

For a simple setter with one parameter and no output schema, the description is adequate but not comprehensive. It fails to mention typical usage patterns (e.g., paired with pine_get_source and pine_compile) or the need for valid Pine Script. Schema covers parameter details, but contextual workflow is missing.

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 coverage is 100%, and the schema already provides a detailed description of the 'code' parameter (new source, replaces entirely, include version). The tool description adds no additional semantic value beyond the schema, meeting 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 tool's function: 'Replace the Pine Editor source code with new content.' It uses a specific verb ('Replace') and resource ('Pine Editor source code'). This distinguishes it from sibling tools like pine_get_source (retrieve) and pine_compile (compile), and from unrelated tools like chart_get_ohlcv.

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?

No guidance on when to use this tool versus alternatives (e.g., pine_save). No prerequisites, constraints, or workflow hints (e.g., compiling after setting). The description only states what it does, not when it's appropriate.

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