Skip to main content

SOTA CLI + MCP server for programmatic painting in Krita

Project description

Krita MCP Server & CLI

Let AI agents paint in Krita via the Model Context Protocol.

This subproject provides the core implementation of the Krita-MCP ecosystem, including the FastMCP server, the krita CLI, and the high-performance Python plugin.

🛠️ Components

  1. Krita Plugin (krita-plugin/) — A Python plugin for Krita that exposes a thread-safe HTTP server on localhost using the configured port (default 5678).
  2. MCP Server (src/krita_mcp/) — A FastMCP server exposing 40+ painting and manipulation tools.
  3. Krita CLI (src/krita_cli/) — A Typer-based command line interface for human operators.
  4. Krita Client (src/krita_client/) — A reusable, fully-typed Python library for Krita automation.

🚀 Setup

1. Krita Plugin Installation

Copy the contents of krita-plugin/ to your Krita resources:

  • Windows: %APPDATA%\krita\pykrita\
  • Linux: ~/.local/share/krita/pykrita/
  • macOS: ~/Library/Application Support/krita/pykrita/

Enable "Krita MCP Bridge" in Krita (Configure Krita → Python Plugin Manager) and restart.

2. Environment Setup

# Install dependencies with uv
uv sync

3. Windows Validation Checklist

Before debugging the plugin, make sure the local Python runtime is healthy:

  1. python -c "import ssl, ctypes" must succeed.
  2. python scripts/windows_preflight.py should report a clean Windows setup.
  3. uv run pytest tests/e2e/test_e2e_mock.py should pass without Krita.
  4. The plugin files must exist under %APPDATA%\krita\pykrita\kritamcp\.
  5. Krita must be restarted after enabling Krita MCP Bridge in the Plugin Manager.
  6. The plugin should expose http://127.0.0.1:<configured-port>/health once Krita finishes loading.

If Krita starts but /health never appears, check the diagnostic artifacts in your home directory:

  • ~/kritamcp_startup.log
  • ~/kritamcp_diag.log

If those logs are missing entirely, the plugin likely was not enabled or did not load during startup.

🔧 CLI Commands

The krita CLI is grouped into logical subcommands:

  • Painting: stroke, fill, clear, draw-shape
  • Layers: layers list, layers create, layers select, layers delete
  • Selection: selection select-rect, selection transform, selection save-channel
  • Canvas: canvas-info, current-color, current-brush
  • Session: history, replay, rollback, batch
  • System: health, config, capabilities, security-status

Run uv run krita --help for full details.

🤖 MCP Server Tools (40 Total)

The MCP server exposes a vast range of capabilities to AI agents:

Category Key Tools
Core krita_health, krita_new_canvas, krita_save, krita_open_file
Painting krita_stroke, krita_fill, krita_draw_shape, krita_set_color, krita_set_brush
Selection krita_select_rect, krita_select_ellipse, krita_select_polygon, krita_select_by_color, krita_select_by_alpha
Selection Ops krita_transform_selection, krita_grow_selection, krita_combine_selections, krita_invert_selection
Persistence krita_save_selection, krita_load_selection, krita_save_selection_channel, krita_list_selection_channels
Automation krita_batch, krita_rollback, krita_get_command_history
Inspection krita_get_canvas_info, krita_get_color_at, krita_selection_stats, krita_security_status

⚡ Performance

The plugin uses numpy-accelerated direct pixel manipulation for rendering. This ensures that strokes and shapes are rendered significantly faster than standard Python loops, especially on high-resolution canvases.

🔒 Security

Krita MCP includes a built-in security layer to protect your system:

  • Path Sanitization: Restricts file operations to allowed directories.
  • Resource Limits: Prevents OOM by limiting max canvas dimensions and layer counts.
  • Rate Limiting: Throttles rapid command execution.
  • Security Tool: krita_security_status allows agents to check active limits.

📄 License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

krita_cli-1.0.1.tar.gz (251.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

krita_cli-1.0.1-py3-none-any.whl (45.2 kB view details)

Uploaded Python 3

File details

Details for the file krita_cli-1.0.1.tar.gz.

File metadata

  • Download URL: krita_cli-1.0.1.tar.gz
  • Upload date:
  • Size: 251.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for krita_cli-1.0.1.tar.gz
Algorithm Hash digest
SHA256 d818d86921e36cb856dcbed40fa405b443d397a08622d02e92a166154970c8ee
MD5 01d383cf16990308c74575db7166a121
BLAKE2b-256 d2a0f683b184f3430eb6a00d372385b11f2b3eb53ec719e08a95396665355a11

See more details on using hashes here.

Provenance

The following attestation bundles were made for krita_cli-1.0.1.tar.gz:

Publisher: ci.yml on edithatogo/krita-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file krita_cli-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: krita_cli-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 45.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for krita_cli-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 94536efff294444f0360af4c9192819640a527999dcf586baa93b0222e649f88
MD5 1ace688c639d5423a88ea86c8c3630e0
BLAKE2b-256 cff96353395f4c4b26ba1b595bb6366922896bd4dcb0cf183fea6b2c297cc2ba

See more details on using hashes here.

Provenance

The following attestation bundles were made for krita_cli-1.0.1-py3-none-any.whl:

Publisher: ci.yml on edithatogo/krita-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page