MCP Server
Connect Claude Code or any MCP client to Mode 8, see what a tool call returns, and learn the habits that keep an agent's art on model.
mode8 mcp serves Mode 8's tools to coding agents over the Model Context Protocol. An agent calls mode8_draft, mode8_anim or mode8_project_save_layer the way it calls any other tool, and gets back the same report the CLI prints, plus a PNG preview of every image it made so a model that can see images can look at its work. The tools run Mode 8's engine in the server process: there is no shell and no subprocess per call.
The server needs the mcp extra. pip install -e ".[all]" from Install Mode 8 includes it.
Connect Claude Code or Codex#
If you installed Mode 8 onto your PATH (with uv tool install), register the MCP server in one command:
# Claude Code
claude mcp add mode8 -- mode8 mcp
# Codex CLI
codex mcp add mode8 -- mode8 mcpIf you installed into a local .venv instead, pass the full path (e.g. ~/mode8/.venv/bin/mode8) so the agent finds it regardless of its own PATH:
claude mcp add mode8 -- ~/mode8/.venv/bin/mode8 mcpTo share the setup with everyone who works in a repository, commit a .mcp.json at its root instead:
{
"mcpServers": {
"mode8": {
"command": "/home/you/mode8/.venv/bin/mode8",
"args": ["mcp"]
}
}
}Then give the agent the skill, which teaches it the pipeline and how to react to each result: see Skill and scripts.
Other clients#
Any client that can start a stdio server works. The command is mode8 (or its full path) and the only argument is mcp; there are no flags. The server answers until the client closes its input, then exits with code 0.
Relative paths in tool arguments (out, out_dir, project_root, image_path) are resolved against the folder the client started the server in. Pass absolute paths, especially project_root, and the question never comes up.
Make a call by hand#
You can talk to the server without an agent. This short script uses the MCP Python SDK (installed with the mcp extra) to start mode8 mcp, call one tool and print what comes back:
import asyncio, json, os, sys
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client
async def main(tool: str, args: dict) -> None:
server = StdioServerParameters(command="mode8", args=["mcp"], env=dict(os.environ))
async with stdio_client(server) as (read, write):
async with ClientSession(read, write) as session:
await session.initialize()
result = await session.call_tool(tool, args)
for block in result.content:
if block.type == "text":
print(json.dumps(json.loads(block.text), ensure_ascii=False))
else:
print(f"[{block.type} {block.mime_type}, {len(block.data)} bytes of base64]")
asyncio.run(main(sys.argv[1], json.loads(sys.argv[2])))Ask for a slime draft:
$ python mcp_call.py mode8_draft '{"archetype": "slime", "out": "slime.png"}'
{
"ok": true,
"tool": "mode8_draft",
"out": "slime.png",
"archetype": "slime",
"size": [48, 40]
}
[image image/png, 1424 bytes of base64]A tool result is the CLI's --json report with a tool key added, followed by an image block for each picture the tool wrote (here, the draft). Arguments are checked against the tool's input schema before anything runs, so a misspelled parameter is refused, with the names the tool accepts, instead of being ignored:
$ python mcp_call.py mode8_draft '{"archetype": "slime", "colour": "red", "out": "slime.png"}'
{
"ok": false,
"tool": "mode8_draft",
"error": {
"type": "InputError",
"msg": "mode8_draft got unknown argument(s) colour; accepted: archetype, colors, key_color, out, palette, pose, size, source",
"param": "colour",
"suggestions": ["colors"]
}
}A failed call is also flagged at the protocol level (isError), so the client knows without reading the JSON. A failure that happens inside a command that ran, such as mode8_doctor finding ComfyUI down, is a successful result with "pass": false and a failure object; the key error only ever means the envelope above.
The tools#
There are 28 tools. Each parameter is the snake_case twin of the CLI flag (out_dir is --out-dir, project_root is --project-root), with the same defaults and limits.
| Task | Tools |
|---|---|
| Make art | mode8_draft, mode8_gen, mode8_pixelize, mode8_tile, mode8_ui, mode8_font, mode8_fx, mode8_recolor |
| Animate and ship | mode8_anim, mode8_export, mode8_maps, mode8_import |
| Check | mode8_lint, mode8_verify, mode8_check_animation, mode8_doctor |
| Projects | mode8_project_init, mode8_project_info, mode8_project_get_asset, mode8_project_create_asset, mode8_project_save_master, mode8_project_save_override |
| Layers and history | mode8_project_layers, mode8_project_save_layer, mode8_project_edit_layers, mode8_project_history, mode8_project_undo, mode8_project_redo |
The mode8_project_* tools are the ones to use whenever a person might have the same project open in the Studio: they write through the project's journal, record the edit as the agent, and refuse to overwrite a file that changed since the agent read it. Co-editing shows how. Every parameter of every tool is listed in MCP tools and in mode8 schema --section mcp.
The server also publishes two read-only resources: mode8://palettes, every bundled palette with its colors, and mode8://archetypes, the draft archetypes, tile kinds and rigs with their frames and animations.
Rules of thumb for agents#
- Ask the contract.
mode8 schema --section mcplists every tool and parameter of the installed version. Unknown arguments are refused, never guessed. - Draft before you generate a character, and choose an art type first. See Sprites.
- Animate the master.
mode8_animmoves the approved sprite's pixels, so frames cannot drift; never generate frames one by one. - Use the deterministic tools for everything that is not a new subject:
mode8_recolorfor palette swaps,mode8_fxfor effects,mode8_tilefor terrain and props,mode8_uiandmode8_fontfor the interface. - Look at the previews and check what you make against the palette it was made with (
mode8_lint,mode8_verify). - In a project, write with
expected_sha256, and keeprespect_pinson. AConflictErrormeans a person just changed the art: read it again, never retry without the hash. - Ignore report keys you do not know. New releases add keys; they never remove the ones a tool documents.
- No ComfyUI?
mode8_doctorsays so with"pass": false. Stay on the tools that run on the CPU (everything exceptmode8_gen) and tell the person that generation is unavailable.
Next#
- Skill and scripts: the skill file, exit codes and the JSON envelope.
- Co-editing: an agent and a person on the same sprite.
- MCP tools: every tool and parameter.