Skip to main content
Glama

send_gcode

Destructive

Sends raw G-code commands to a connected 3D printer in sequence, validating safety limits and optionally previewing commands with a dry run before execution.

Instructions

Send raw G-code commands directly to the printer.

Args:
    commands: One or more G-code commands separated by newlines or spaces.
        Examples: ``"G28"`` (home all axes), ``"G28\nG1 Z10 F300"``
        (home then move Z up 10mm), ``"M104 S200"`` (set hotend to 200C).
    dry_run: When ``True``, run the full validation pipeline (auth,
        rate-limit, G-code safety) but do **not** actually send commands
        to the printer.  Returns what *would* have been sent.

The commands are sent sequentially in order.  The printer must be
connected (unless ``dry_run`` is ``True``).

G-code is validated before sending.  Commands that exceed temperature
limits or modify firmware settings are blocked.  Use ``validate_gcode``
to preview what would be allowed without actually sending.

Raw G-code has no general read-back, so ``outcome`` here is
``"accepted"`` whenever the command was sent: the printer took the
bytes, and whether it EXECUTED them is not reported. Observe the
printer (``printer_status()``, or the machine itself) before building
on a G-code send. ``"failed"`` means the transport refused it.

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": {
      "commands": "<commands>"
    },
    "name": "send_gcode"
  }
}

Input Schema

NameRequiredDescriptionDefault
dry_runNoWhen ``True``, run the full validation pipeline (auth, rate-limit, G-code safety) but do **not** actually send commands to the printer. Returns what *would* have been sent. Default: false.
commandsYesOne or more G-code commands separated by newlines or spaces. Examples: ``"G28"`` (home all axes), ``"G28\nG1 Z10 F300"`` (home then move Z up 10mm), ``"M104 S200"`` (set hotend to 200C).

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv1.5.1
    • addedInput schema / properties / commands / description
      Added value: +"One or more G-code commands separated by newlines or spaces. Examples: ``\"G28\"`` (home all axes), ``\"G28\\nG1 Z10 F300\"`` (home then move Z up 10mm), ``\"M104 S200\"`` (set hotend to 200C)."
    • changedInput schema / properties / dry_run / description
      Previous value: -"Default: false."New value: +"When ``True``, run the full validation pipeline (auth, rate-limit, G-code safety) but do **not** actually send commands to the printer.  Returns what *would* have been sent. Default: false."
  2. Changed2 schema fields changedv1.5.0
    • removedInput schema / properties / dry_run / default
      Removed value: -false
    • addedInput schema / properties / dry_run / description
      Added value: +"Default: false."
  3. First observedv0.1.0

TDQS

A4.4/5.0
Behavior5/5

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

Beyond the destructiveHint=true annotation, the description discloses that commands run sequentially, that a validation pipeline blocks over-temperature and firmware-modifying commands, and exactly what dry_run does and does not do. Crucially it explains that outcome='accepted' only means bytes were transported, not executed, and that 'failed' means the transport refused — behavior an annotation could never convey.

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 core semantics are front-loaded — send, then dry_run, then validation, then outcome interpretation — which is a sensible reading order. The Args block duplicating the schema verbatim is wasted space, though the closing paragraph on outcome semantics earns its place.

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

Completeness5/5

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

For a two-parameter mutation tool with no output schema, the description covers connection requirements, validation limits, execution ordering, and return-value semantics ('accepted' vs 'failed'). That is enough for an agent to call it correctly and interpret the result without further documentation.

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

Parameters3/5

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

Schema description coverage is 100% and the schema already contains the same examples and the same dry_run explanation, including the default. The description's Args block largely restates that text rather than adding new meaning such as separator edge cases or an upper bound on command count, so the baseline 3 applies.

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?

The opening sentence gives a specific verb and resource (send raw G-code directly to the printer) and scopes it as raw/low-level, which distinguishes it from higher-level siblings. It also names validate_gcode as the non-sending counterpart, so an agent can identify which tool performs the actual send.

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 states prerequisites (printer must be connected unless dry_run is True) and directs the agent to validate_gcode for previewing allowed commands. It also instructs the agent to observe the printer via printer_status() before building on a send. It does not, however, explain when to prefer this low-level tool over siblings like home_axes, park_head, or set_temperature.

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

Deploy Server

Other Tools