Skip to main content
Glama

ai-toolkit-mcp

An MCP server for ostris/ai-toolkit. It lets an AI agent in Griptape Nodes, Claude Code, Claude Desktop, or any other MCP client set up, launch, and monitor LoRA training runs on your own machine.

"Train a LoRA of my dog on the rufus dataset, same settings as last week's run but 2000 steps. Check on it in a bit and show me the latest samples."

It talks to the ai-toolkit web UI's API, so every job it creates shows up in the UI, uses the UI's per-GPU queue, and appears on the UI's loss graph. You can switch between chatting and clicking at any time.

Requirements

  • ai-toolkit installed, with its UI running (cd ai-toolkit/ui && npm run build_and_start, default address http://localhost:8675)

  • uv

You don't need to clone this repo. uvx fetches and runs it.

Related MCP server: sd-api-mcp

Setup

Griptape Nodes

  1. Open Settings → MCP Servers → + New MCP Server

  2. Server Name/ID: ai-toolkit, Connection Type: Local Process (stdio)

  3. Configuration JSON:

    {
      "transport": "stdio",
      "command": "uvx",
      "args": ["--from", "git+https://github.com/shhlife/ai-toolkit-mcp", "ai-toolkit-mcp"],
      "env": { "AI_TOOLKIT_URL": "http://localhost:8675" }
    }
  4. Enable the ai-toolkit server on an Agent node (or use it from an MCP Task node) and start asking.

This lets you build workflows like: generate or caption a dataset with Griptape nodes, have the Agent kick off training, then pull the finished LoRA back into a generation flow.

Claude Code

claude mcp add ai-toolkit -- uvx --from git+https://github.com/shhlife/ai-toolkit-mcp ai-toolkit-mcp

Claude Desktop (or any MCP client using mcpServers JSON)

{
  "mcpServers": {
    "ai-toolkit": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/shhlife/ai-toolkit-mcp", "ai-toolkit-mcp"]
    }
  }
}

Configuration

Env var

Default

Purpose

AI_TOOLKIT_URL

http://localhost:8675

Where the ai-toolkit UI is running. Can point at another machine or a cloud GPU box.

AI_TOOLKIT_AUTH

unset

Set this if you started the UI with AI_TOOLKIT_AUTH (same token).

Tools

Tool

What it does

training_guide

Best practices by topic: workflow, dataset, captions, models, settings, VRAM, monitoring, troubleshooting

ai_toolkit_status

Connection check: GPUs, VRAM, queues, active jobs, data folders

list_datasets

Dataset folders with full paths and file counts

create_dataset

Make a dataset (or add to one) from local files/folders, including existing caption .txt files

get_captions / set_captions

Read and write per-image captions

auto_caption_dataset

Queue ai-toolkit's built-in captioner (Qwen3-Omni) on a dataset

list_jobs / get_job

Jobs with status, step progress, speed, model

get_job_config

A job's full config as YAML

list_models

Every model your ai-toolkit install can train (read live from it), with preset names

create_job

New job from a model preset, YAML, or a clone of an existing job, plus dotted-path overrides like {"train.steps": 2000}. Returns warnings (missing captions, trigger-word mistakes, gated models without a token) and won't auto-start while there are any

update_job

Edit a stopped job, including switching its model preset

start_job / stop_job

Queue or stop a job (graceful stop saves a checkpoint; force kills it)

trigger

Ask a running job to save or sample now

get_job_log

Tail of the training log, without progress-bar noise

get_loss

Loss curve summary (start/end/min, smoothed trend)

list_job_outputs

Checkpoint files and samples

view_samples

Returns the latest sample images so the agent can see how training looks

Read-only tools are marked as read-only, so clients with tool approval (Griptape Nodes, Claude) can auto-approve them and only ask before anything that creates, starts, or stops a job. Nothing in this server deletes jobs, datasets, or files (set_captions does overwrite the captions you give it).

create_dataset uploads through the UI's API rather than writing into ai-toolkit's folder directly, so it works the same whether ai-toolkit is on your machine or a remote GPU box. ai-toolkit replaces spaces and special characters in uploaded file names with _.

How agents learn best practices

  • training_guide returns practical advice per topic. The tool descriptions tell agents to call it before planning a run, so this works in every MCP client. The text lives in guide.py; edit it as you learn what works.

  • Model presets come from your ai-toolkit install's own model definitions, the same ones the UI's model dropdown uses, so new models show up automatically when you update ai-toolkit.

  • create_job / update_job check the config and return warnings in plain language.

  • The server also sends usage instructions when a client connects. Claude Code reads those; Griptape Nodes currently doesn't pass them to its agents, which is why the guide is a tool.

Reusing models you already downloaded

ai-toolkit keeps ComfyUI-format weights in its own models folder for many models and downloads them there even when the model is already in your Hugging Face cache (LTX-2.5 always loads this way). When ai-toolkit runs on the same machine as this server, create_job / update_job point the job at the cached files instead and say so under using_hf_cache. Models that aren't cached get a warning before anything starts. The cache location comes from HF_HUB_CACHE, HUGGINGFACE_HUB_CACHE, or HF_HOME.

Tips

  • create_job(model=...) applies the same settings the UI does when you pick a model. For edit models that need control images (Kontext, Qwen-Image-Edit), set one job up in the UI and have the agent clone it with base_job.

  • Per-model reference configs live in ai-toolkit's config/examples/ folder. You can paste one into create_job(config=...).

Development

uv sync
uv run pytest
uv run mcp dev src/ai_toolkit_mcp/server.py   # MCP Inspector

Griptape Nodes library (experimental)

The griptape_library/ folder is a Griptape Nodes library that exposes a subset of the tools (status, datasets, models, jobs, job logs, start and stop) through the engine's own MCP server. It needs an engine that supports AdvancedNodeLibrary.get_mcp_tools (griptape-nodes-engine#6035).

  1. In Griptape Nodes, add griptape_library/griptape_nodes_library.json from a checkout of this repo as a library.

  2. Add an MCP server pointing at http://localhost:8125/mcp/libraries/ai_toolkit/ (or use http://localhost:8125/mcp/?libraries=ai_toolkit for the engine's tools plus these).

The handlers call the same functions as the standalone server, so results match.

License

Apache 2.0

Available Tools

19 tools
ai_toolkit_statusA
Read-only

Connection check and machine overview: GPUs (VRAM, load), queues, active jobs, and data folders.

Inputs: no named parameters. Returns: result

auto_caption_datasetA

Queue ai-toolkit's built-in captioning job (Qwen3-Omni) for a dataset, like the UI's Caption button.

Only uncaptioned files are captioned unless recaption is set. prompt overrides the captioning instruction; by default an image prompt is used for image-only datasets and ai-toolkit's video/audio prompt otherwise. Uses GPU time and downloads the captioner model on first use. Track it with get_job.

Inputs: dataset (required), prompt, gpu_ids, recaption, +1 more. Returns: result

create_datasetA

Create a dataset (or add to an existing one) by uploading local files into ai-toolkit.

paths are files or folders on the machine running this MCP server; folders are searched recursively for images, videos, audio, and matching caption files (e.g. photo1.jpg + photo1.txt). Files are sent over the UI's API, so this also works when ai-toolkit runs on another machine.

Inputs: name (required), paths (required), caption_ext. Returns: result

create_jobA

Create a training job in the ai-toolkit UI.

Config source (pick one): config as YAML/JSON text (full job file or just its config: body), or base_job (id/name) to clone an existing job's config. Neither = the default template. overrides sets values inside config.process[0] by dotted path, e.g. {"train.steps": 4000, "datasets.0.folder_path": "D:/datasets/me", "trigger_word": "ohwx", "network.linear": 16, "sample.samples": [{"prompt": "ohwx at the beach"}]}. gpu_ids is the GPU index (e.g. "0" or "0,1"). Set start to queue it immediately.

Inputs: name (required), start, config, gpu_ids, +2 more. Returns: result

get_captionsB
Read-only

Captions for each file in a dataset (empty string = uncaptioned), plus a count of missing ones.

Inputs: dataset (required), limit, caption_ext. Returns: result

get_jobC
Read-only

Status and progress of one job. job is a job id or name.

Inputs: job (required). Returns: result

get_job_configB
Read-only

Full training config of a job as YAML. Useful as a starting point for a new run.

Inputs: job (required). Returns: result

get_job_logB
Read-only

Last lines of a job's training log, with progress-bar noise collapsed.

Inputs: job (required), tail_lines. Returns: result

get_lossB
Read-only

Loss curve summary: first/last/min values, a smoothed trend, and evenly spaced points.

Inputs: job (required), key, max_points. Returns: result

list_datasetsA
Read-only

List dataset folders in ai-toolkit's datasets folder, with full paths and file counts.

Use the path value as datasets.0.folder_path when creating a job.

Inputs: no named parameters. Returns: result

list_job_outputsB
Read-only

Checkpoint (.safetensors) files and sample media produced by a job, as local paths.

Inputs: job (required). Returns: result

list_jobsB
Read-only

List training jobs (newest first) with status, progress, and model.

Inputs: active_only. Returns: result

new_job_templateA
Read-only

The ai-toolkit UI's default job config (Flex.1 LoRA) as YAML, to edit and pass to create_job.

For other models, cloning a previous job with create_job(base_job=...) is more reliable, or see ai-toolkit's config/examples/*.yaml for per-model settings.

Inputs: no named parameters. Returns: result

set_captionsA

Write captions. captions maps a file name (as shown by get_captions) to its caption text; existing captions for those files are replaced.

Inputs: dataset (required), captions (required), caption_ext. Returns: result

start_jobA

Queue a job and start its GPU queue. Resumes from the last checkpoint if one exists.

Inputs: job (required). Returns: result

stop_jobA
Destructive

Stop a job gracefully (saves a checkpoint first). force kills the process immediately, only for jobs stuck and ignoring a normal stop.

Inputs: job (required), force. Returns: result

triggerA

Ask a running job to save a checkpoint or generate samples on its next step.

Inputs: job (required), action (required). Returns: result

update_jobA

Edit a job that isn't running: replace its config (YAML/JSON) and/or apply dotted-path overrides inside config.process[0] (same format as create_job).

Inputs: job (required), config, gpu_ids, overrides. Returns: result

view_samplesB
Read-only

Return the most recent sample images from a job so you can judge training progress visually.

Inputs: job (required), count.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.5/5.0

    Scored across 19 tools

    Disambiguation4/5

    Most tools have distinct resource+action boundaries, but get_job_config and new_job_template both return starting-point YAML, and view_samples overlaps list_job_outputs in surfacing sample media. Descriptions clarify intended contexts, so misselection risk is low.

    Naming Consistency4/5

    Predominantly snake_case verb_noun names (list_jobs, create_job, stop_job), with minor exceptions like trigger, ai_toolkit_status, and new_job_template that are verbless or namespaced nouns. The pattern is readable and mostly predictable.

    Tool Count4/5

    19 tools across datasets, captions, job lifecycle, and monitoring is slightly heavy but each tool earns its place. It is not excessive for a server covering dataset preparation, captioning, job CRUD, and training monitoring.

    Completeness4/5

    Dataset and captioning flows are well covered (list/create, get/set/auto), and job lifecycle is rich (create/update/start/stop/trigger, logs/loss/outputs). Missing explicit delete operations for datasets/jobs and checkpoints, but core workflows have no dead ends.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      A
      quality
      C
      maintenance
      Enables AI agents to connect to the NeuralForgeAI cluster for inspecting and controlling YOLO training jobs, including launching, monitoring, canceling studies, and verifying dataset paths.
      8
      -
    • A
      license
      A
      quality
      B
      maintenance
      Enables AI agents to generate images on a local Stable Diffusion Forge Neo instance, automatically inferring prompt style and sampling parameters from the user's setup and past generations, and providing tools for LoRA search, model management, and module checks.
      10
      1
      MIT