Skip to main content
Glama

save_script

Save a reusable userscript with match patterns and manual or auto run modes. Reusing an existing name replaces the script and increments its version.

Instructions

Save a reusable userscript. code is the body of a function: plain JavaScript with full DOM access in the page, no imports; use return to hand a result back to run_script. These GM_ APIs work in Tether and in Tampermonkey: GM_addStyle, GM_getValue, GM_setValue, GM_deleteValue, GM_listValues, GM_xmlhttpRequest, GM_openInTab, GM_setClipboard, GM_notification, unsafeWindow. run=manual puts a Run button in the popup (and a menu command in Tampermonkey); run=auto runs on every matching page load. Saving an existing name replaces it and bumps its version.

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": {
      "name": "<name>",
      "matches": "<matches>",
      "code": "<code>"
    },
    "name": "save_script"
  }
}

Input Schema

NameRequiredDescriptionDefault
runNo
codeYes
nameYes
runAtNoFor run=auto. Default document-idle.
matchesYesMatch patterns, e.g. ["https://mail.example.com/*"].
descriptionNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.1/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 substantial work: it defines the execution model (function body, full DOM access, no imports), enumerates the supported GM_ APIs and their portability to Tampermonkey, and discloses the destructive-on-collision behavior ('saving an existing name replaces it and bumps its version'). It stops short of covering permissions/consent for GM_xmlhttpRequest, error behavior, or what saving returns, which keeps it below 5.

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?

Purpose is front-loaded in the first clause, followed by code semantics, capability surface, and run-mode behavior in a logical order. The GM_ API enumeration is a dense list but earns its place as capability disclosure; nothing is redundant padding.

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?

For a six-parameter mutation tool with no annotations and no output schema, the description covers the essential unknowns: what `code` must be, how run modes behave, and that same-name saves overwrite. Gaps remain around return value, permission prompts for network/tab APIs, and how `description` is used, but an agent could invoke this correctly from what is given.

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 only 33%, so the description must compensate, and it does for the two least obvious parameters: `code` is defined as a function body with a return convention, and `run` is given concrete manual/auto semantics including the popup button and Tampermonkey menu command. `matches` and `runAt` are already documented in the schema, but the `description` parameter is not explained anywhere.

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 ('Save a reusable userscript') and immediately scopes what is being saved: a function body with DOM access and no imports. It also positions the tool against run_script by explaining that `return` hands a result back to run_script, so an agent can tell persistence apart from one-off execution.

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?

The run=manual vs run=auto explanation is genuine usage guidance for a parameter, and the replacement note tells the agent what happens on name collision. However, there is no explicit when-to-use-this-instead guidance versus run_script (execute now) or install_userscript, so the alternative routing is only implied by the `return`-to-run_script sentence.

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