Skip to main content
Glama

sanitize_command

Rewrites shell commands stage by stage to prune lockfiles and cap verbose git, Docker, Kubernetes, and search output, cutting token use while preserving compound operators.

Instructions

Per-stage shell command rewrites: prunes lockfiles, caps unbounded git log/show/blame/rg and docker/kubectl logs, quiets npm/pip installs, bounds cat/curl output. Compound commands (a && b ; c) are optimized per stage without breaking operators. For unit-test runs prefer the tests CLI wrapper (tokensafe tests [pytest]) over raw python3 -m unittest discover. Pass cwd for test-runner commands: the guard reads /package.json to force jest/vitest into run-once mode (CI=true, --watch=false, --forceExit) so agents never hang on watch mode.

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": {
      "command": "<command>"
    },
    "name": "sanitize_command"
  }
}

Input Schema

NameRequiredDescriptionDefault
cwdNoOptional working directory the command will run in; enables the package.json peek that identifies the runner behind opaque yarn/npm test scripts
commandYesRaw bash command line

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv2.8.4

TDQS

A3.7/5.0
Behavior3/5

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

With no annotations, the description carries the full disclosure burden. It does well on effects (what gets pruned, capped, quieted) and even discloses a non-obvious side effect — forcing jest/vitest into run-once mode with CI=true, --watch=false, --forceExit by reading <cwd>/package.json. However, it never states whether the tool executes the command or merely returns a rewritten string, nor what happens on unparseable input, which is a meaningful gap for a mutation-adjacent tool.

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 definition is front-loaded with the core behavior and packed into three dense sentences with no filler. The enumeration of bounded commands is slightly list-heavy and reads as a run-on, but every clause carries operational information.

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

Completeness3/5

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

For a two-parameter tool with no annotations and no output schema, the description covers transformations and the test-runner special case adequately. The unresolved question of whether the input command is executed or returned rewritten, plus no guidance on failure or invalid-input behavior, leaves a real hole an agent would hit in practice.

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 baseline is 3. The description adds real meaning beyond the schema by explaining the consequence of cwd — the guard forces jest/vitest into run-once mode via specific env vars — which the schema's cwd description only gestures at. Minor overlap with the existing cwd text keeps it from a 5.

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 opening phrase 'Per-stage shell command rewrites' names a specific verb (rewrite) and resource (shell command), and the following clause enumerates concrete transformations (lockfile pruning, git log/blame caps, npm/pip quieting, cat/curl bounds). It is clearly distinguishable from siblings like smart_read_file or scoped_search. It falls short of 5 because the description never states plainly whether the tool returns a transformed command string or executes it.

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

Usage Guidelines4/5

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

It gives an explicit routing rule: for unit-test runs prefer the `tests` CLI wrapper over raw `python3 -m unittest discover`, and it instructs the agent to pass cwd for test-runner commands. What's missing is the general trigger — when an agent should route a command through sanitize_command versus running it directly — but the test-runner case is handled concretely.

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