Skip to main content
Glama

Run Code

run_code

Execute Google Apps Script as the user and return results with logs. Access built-in services like SpreadsheetApp and UrlFetchApp, opening files by ID or URL because no active document is set.

Instructions

Run Apps Script (JavaScript, V8) as the user and return the result and logs.

code is a function body: use return to send back a JSON-serializable value. All built-in services are available (SpreadsheetApp, DocumentApp, DriveApp, GmailApp, CalendarApp, UrlFetchApp, ...). console.log and Logger.log output is returned in logs. There is no active document, so open files by ID or URL. Executions stop after 6 minutes.

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_code"
  }
}

Input Schema

NameRequiredDescriptionDefault
codeYes

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.7/5.0
Behavior4/5

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

With no annotations supplied, the description carries the full behavioral burden and does well: it discloses that execution happens as the user, lists available built-in services, explains that there is no active document, and states the 6-minute execution limit. It does not discuss permission scopes or destructive side effects, but the core execution behavior is transparent.

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 front-loaded with the core action, then adds environment details, parameter semantics, logging behavior, and the timeout. Every sentence contributes useful information with no filler.

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?

An output schema exists, so return values need not be explained in detail, but the description still clarifies result and log behavior. It covers the execution environment and key constraints, though it omits sibling differentiation and permission/scope details that would make it fully complete.

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 description coverage is 0%, so the description must compensate, and it does: it explains that `code` is a function body, that `return` sends back a JSON-serializable value, and that logs are captured. This adds substantial meaning beyond the bare `string` schema.

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 states a specific verb and resource: it runs Apps Script (JavaScript, V8) as the user. It is clear what the tool does, but it does not explicitly distinguish itself from a sibling like `run_function`, so it falls short of a 5.

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 operational context such as 'no active document' and 'open files by ID or URL,' but it gives no explicit guidance on when to choose this tool versus alternatives like `run_function`. There are no when-not-to-use conditions or alternative routing cues.

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