Skip to main content
Glama

merge_multicolor_gcode

Merge separately-sliced gcode files into a single multi-tool gcode file, using a batched strategy to reduce tool changes for multi-color prints. Requires parts with non-overlapping XY footprints.

Instructions

Merge separately-sliced gcode files into one multi-tool gcode.

Uses a batched strategy that minimises tool changes for multi-color
prints.  Parts with overlapping Z ranges are printed in tool order
within the overlap zone, then remaining layers continue above.

This is the key step between slicing individual parts and wrapping
as a Bambu 3MF.  The merged gcode contains T0/T1/... tool change
commands that ``wrap_gcode_as_3mf`` converts to M620/M621 AMS
load sequences.

**Precondition:** Parts must be **XY-disjoint** (non-overlapping
footprints on the build plate).  The batched merge prints each
tool's layers independently in the overlap zone — overlapping XY
regions will cause collisions.

Args:
    parts: JSON array of part objects.  Each must have:

        - ``gcode_path``: Path to the sliced ``.gcode`` file.
        - ``tool_index``: Tool number (0, 1, ...) for AMS mapping.
        - ``name``: Human-readable name (e.g. ``"body_grey"``).

        Example::

            [
              {"gcode_path": "/path/body.gcode", "tool_index": 0, "name": "body"},
              {"gcode_path": "/path/qr.gcode", "tool_index": 1, "name": "qr_pads"}
            ]

    output_path: Output file path.  Defaults to a temp directory.

Returns a dict with ``output_path``, merge phases, layer count,
and estimated print time.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
partsYes
output_pathNo
Behavior4/5

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

With no annotations, the description carries full burden. It details the batched merge strategy, tool change commands, and output contents. It discloses the precondition and limitation about XY overlap. It doesn't mention destructiveness or authentication needs, but for a file merge tool, the behavior is well explained.

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?

Well-structured with bold preconditions, a clear example, and sections. The description is front-loaded with purpose and strategy. Every sentence adds value without redundancy or fluff.

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?

Covers behavior, parameters, preconditions, output, and relationship to sibling tool wrap_gcode_as_3mf. Lacks error handling or edge cases, but for a file merge tool with no output schema and no annotations, it is remarkably thorough.

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

Parameters5/5

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

Schema coverage is 0%, so the description fully compensates. The Args section thoroughly explains both parameters: parts (JSON array with required fields gcode_path, tool_index, name, including an example) and output_path (default behavior). It adds meaning far beyond the schema's property definitions.

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 description clearly states the tool merges separately-sliced gcode files into one multi-tool gcode, with a specific batched strategy for multi-color prints. It distinguishes itself from sibling tools like wrap_gcode_as_3mf by describing this as the key intermediate step.

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?

Explicitly states the use case (between slicing and 3MF wrapping) and preconditions (XY-disjoint parts). It warns about overlapping XY regions causing collisions, providing clear when-not-to-use guidance. However, it does not list alternative tools or scenarios where this tool is inappropriate.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/codeofaxel/kiln'

If you have feedback or need assistance with the MCP directory API, please join our Discord server