Skip to main content
Glama

run_analysis_script

Read-only

Run read-only JavaScript to analyze project data — use this instead of paging large datasets through query tools when a question involves aggregation, joins across entity types, or more than a page of records. The code runs in Telerivet's Cloud Script API sandbox (synchronous JavaScript) with the project global set when a project is bound (undefined in organization-only runs with no project_id), plus an organization global for organization-level data (billing details and transactions, usage, the organization's projects) — organization methods work only where the user's own permissions allow. Write top-level statements — do NOT wrap the code in a main() function — and end with a top-level return <value> returning a compact JSON-serializable result (counts, samples, summaries — never full datasets); use console.log(...) for progress output. Each run has limited execution time and API requests (12 seconds / 250 requests unless the project's admin settings allow more): prefer cursor.count() and filtered queries over scanning every record, avoid one API call per record, and bound big jobs with cursor.limit(n), processing one segment per run. The result's 'usage' property reports usage against these limits, for sizing batches across runs. For genuinely large bulk operations, create an asynchronous batch task instead (project.createTask, or the Project_createTask API method), which processes all matching records server-side without these limits. Use get_method_schema for JavaScript example code for a specific method, and call get_documentation with id 'cloud_script_api' for the Cloud Script API reference — check it before writing nontrivial code rather than guessing method signatures. This tool's API access is READ-ONLY: methods that create, update, send, or delete fail, and HTTP requests are disabled. To perform changes, use run_script instead.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "code": "<code>"
    },
    "name": "run_analysis_script"
  }
}

Input Schema

NameRequiredDescriptionDefault
codeYesJavaScript code to execute (Cloud Script API, read-only)
project_idNoID of the project to run the script in (call API_queryProjects to look up a project ID if you don't already have one). Optional: omit it to run in organization-only context — the `project` global is then undefined, while the `organization` global is still available (e.g. for billing or usage questions).

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.8/5.0
Behavior5/5

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

Far exceeds the annotations: it discloses the sandbox runtime, the 12-second/250-request limits, the `usage` property for sizing batches, the read-only enforcement including disabled HTTP, the main()-free top-level return requirement, and the result-size expectation. These are exactly the failure modes an agent would otherwise hit blind.

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?

Front-loaded with purpose and the alternative, and nearly every sentence carries operational content. The trade-off is a single dense paragraph of ~380 words with embedded constraints and limits that would scan better as short grouped statements.

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

Completeness5/5

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

For a code-execution tool with no output schema, the description covers execution model, limits, return-value contract, permission scoping, and where to find API references. Nothing an agent needs in order to call this successfully is missing.

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?

Schema coverage is 100%, so the baseline is 3, and the description does add meaning: it explains that omitting project_id leaves `project` undefined while `organization` remains usable for billing and usage questions. This largely mirrors the schema text but reinforces why the optional parameter matters for tool selection.

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?

States a specific verb and resource — "run read-only JavaScript to analyze project data" — and immediately scopes it against query tools and run_script. An agent can distinguish it from every sibling without opening a schema.

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

Usage Guidelines5/5

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

Explicit selection criteria are given (aggregation, joins across entity types, more than a page of records) plus exclusions: use batch tasks for large bulk operations, run_script for writes, get_method_schema and get_documentation before writing nontrivial code. This is close to a complete decision tree.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources