run_analysis_script
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
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | JavaScript code to execute (Cloud Script API, read-only) | |
| project_id | No | ID 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). |