Skip to main content
Glama

Run Function

run_function

Executes a top-level function from saved Apps Script code and returns its result and logs, so you can test project logic through the MCP bridge.

Instructions

Run a top-level function from a project's saved code and return its result and logs.

The project's .gs files are loaded into the bridge and executed there, so it runs as the user but outside the real project: there is no active document (getActiveSpreadsheet() returns null), and the project's own libraries, advanced services, script properties and triggers are not available. Only standalone projects can be loaded. args must be JSON-serializable.

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": {
      "script_id": "<script_id>",
      "function_name": "<function_name>"
    },
    "name": "run_function"
  }
}

Input Schema

NameRequiredDescriptionDefault
argsNo
script_idYes
function_nameYes

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.5/5.0
Behavior4/5

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

With no annotations, the description carries the full burden and does so well: it discloses the execution sandbox (code loaded into the bridge, runs as the user but outside the real project), the concrete failure modes (getActiveSpreadsheet() returns null), and the unavailable services (libraries, advanced services, script properties, triggers). It stops short of timeouts, permission/auth requirements, or whether side effects persist.

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?

The action and return value are front-loaded in sentence one, and the environment caveats follow in a compact block. Every sentence carries information, though the paragraph could be tightened into a short list of limitations for faster scanning.

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?

Because an output schema exists, the description need not explain return values, and the sandbox limitations are well covered — the main risk area for a code-execution tool. The remaining gap is what identifier script_id expects and whether execution has a time limit, both relevant to invoking it successfully.

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

Parameters2/5

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

Schema coverage is 0%, so the description must explain all three parameters and only addresses one: 'args must be JSON-serializable.' Even that is imprecise, since the schema constrains args to an array or null, not arbitrary JSON, and the description never says args are positional arguments to the target function. script_id and function_name are self-descriptive but get no clarification of whether script_id is a project id or script id.

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 first sentence gives a specific verb and resource ('Run a top-level function from a project's saved code') and states what comes back ('its result and logs'). It does not, however, distinguish this from the sibling run_code, leaving the agent to guess which execution entry point applies.

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?

Usage is only implied through constraints: 'Only standalone projects can be loaded' and the missing-feature list tell the agent when this tool will fail, which is genuinely useful routing information. But there is no explicit 'use this instead of run_code when...' statement and no stated preconditions such as project id requirements.

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