Using Liminalia from AI assistants (MCP)
On this page
lim mcp is an MCP server (over standard input and output) for using Liminalia from AI assistants such as Claude Desktop, Claude Code and Codex.
Ask for a visual novel, and the assistant can take it all the way: creating the project, writing the scenario, checking it, running it, confirming the result with screenshots and exporting it.
Tools
| Tool | What it does |
|---|---|
list_projects | Lists the projects in the project roots |
create_project | Creates a project from a template (title, screen size, sound novel, blank, source language, and with ci the GitHub Actions check and a script test) |
list_files | Lists the scenarios, assets and characters |
read_scenario | Reads a scenario (a .lim in the scenario folder) and returns hash at the end. With numbered, the lines are numbered |
write_scenario | Saves a whole scenario. For a scenario that already exists, pass the hash from when you read it as baseHash (see “Using it with Studio” below). If saving would add errors, it doesn’t save (see “Not adding errors” below). After saving, checks the whole project and returns the result |
edit_scenario | Rewrites some lines of a scenario. Confirms the lines before the rewrite (expect) and then saves. If that would add errors, it doesn’t save. After saving, checks the whole project |
restore_scenario | Restores a scenario to an earlier version in .liminalia/history/. Without id, it’s the version just before (the contents before the last save); with list, returns the list of versions. If restoring would add errors, it doesn’t restore |
apply_fixes | Applies the suggested fixes attached to diagnostics (replacing a name with a similarly spelled one, deleting an unneeded line, combining several lines into one and so on; the same as “Fix” in Studio) and saves. Narrow them down with codes and lines. Suggested fixes that rewrite things outside the line, such as adding a speaker, aren’t applied and are returned |
fmt | Tidies scenarios (the same as lim fmt). Without file, all of them (pack scenarios too, which can be named as packs/<id>/scenario/<scenario>). A scenario with syntax errors isn’t tidied, and the reason is returned. The previous version is kept in the history |
read_cast | Returns as JSON the characters’ (cast.json) speaker names, name colors, sprite sets (the default one), variants (the base variant), positions (the names you can write in at=, and auto), layers of composited sprites, and the list of speakers. who narrows it to one character |
list_macros | The macros (@define): name, parameters (name: type = default), summary (the // lines just above), location, whether @with can pass content (whether it has @content), and how many times it’s called |
line_state | The stage at a scenario line (background, sprites, BGM, looping sound effects, window and so on), the variables, and the choices made up to there (the same as the current position in Studio). line, or from to to (up to 50 lines) |
check_text | Checks a scenario’s contents without saving and returns that file’s diagnostics as JSON (the same rules as ctx.check for Studio plugins) |
check | Checks all scenarios (lim check). With format set to json, returns the JSON from lim check --json |
query | Looks up definitions and references as JSON (lim query --json). Pass project and kind (label, var, asset); omit name for an inventory. Unknown names return candidates and isError |
scenario_guide | A guide to writing scenarios (kinds of lines, dialogue, labels, inline markup such as ruby, value types, sprites, choices, @if, variables and expressions, macros, expression functions). The resource liminalia://guide/scenario is the same thing |
trace | The result of running without a screen (lim trace). The [N] at the start of each page is its number, counted from 1 from the start position; pass it to skip of screenshot (lim shot --skip, the player’s ?skip=) to stop at that page |
screenshot | Returns a screenshot as an image (lang sets the language; lim shot --lang). If the project is open in the Studio app or lim studio, it’s taken with that dev server; if not, with lim shot (Chromium is required). See “Using an open Studio” below |
list_screens | Returns the built-in screens (save, settings, log, ending and so on) as JSON. For each screen: its name, whether it opens with sample content (the reason if not), the states you can pick, the parts table (part name, CSS selector, and the theme values and CSS variables that decide its look), theme values, text keys, CSS classes and variables, and replacement hooks. With project, the themes you can pick are returned too. screen narrows it to one screen (the same as the tables in screens.md) |
screen_shot | Opens a built-in screen with sample content, captures it and returns the image (lim shot --screen; the same sample as “Game screens” in Studio). You can pick state (filled, empty or long), orientation (portrait or landscape; another orientation than the project’s swaps width and height), lang and theme. If it can’t open, the reason and problems are returned. If it captures but the screen isn’t visible, something still covers it (a load curtain or a full-screen effect layer) or the sample content isn’t showing, the image comes back with ok set to false and the reasons in problems. If a plugin replaces the screen, replacedBy names the plugin. Chromium is required |
copy_screen | Copies a built-in screen template into the project (same as lim screens copy). It goes to ui/screens/<screen>/<screen>.html (or the registered location), is registered in ui.templates, and the copied original is kept in .liminalia/screens/. parts copies only those parts, js also puts a screen JS skeleton. Existing files (parts) aren’t rewritten without force. Returns the file, the parts, whether it was registered, overriddenBy when a plugin comes first, and the template check after copying (diagnostics) |
read_screen_files | Reads a screen’s files: the project’s template (text is null if missing), the current built-in template and its part names, the screen rules (the data-role and data-field values that work, the required data-role), the screen JS and the project CSS (ui.css) |
write_screen_file | Writes a screen’s file. kind is template (registered if it isn’t), script (the screen JS) or css (project CSS; pick it with file; without ui.css it writes ui/screens.css and registers it). After writing, runs the same template check as lim check (the project CSS check for css) and returns diagnostics and ok (no errors) |
diff_screen | How the project’s template differs from the built-in one (same as lim screens diff): for each part, the diff from the current built-in part to the project’s (authorDiff), what changed in the built-in template since the copied version (standardChange), and a readable form (text) |
command_reference | Command specs. Narrow them down by putting what you want to do (“shake”, “fade to black”, “rain”) or a name in query |
set_theme | Applies a theme for the look of the whole game (Default, Washi, Night, Pastel, Terminal, Mansion, Near Future, School, Chat for portrait projects only, or themes/<id>/theme.json in the project) and copies its assets into the project. Trying to apply a portrait-only theme to a landscape project is refused, with the reason |
install_plugin | Installs an official plugin (leave out the id to get the list) |
import_asset | Copies a file on this computer into the assets (you specify the kind) |
register_character | Registers a character (a person in cast.json) and links sprites to it, along with the name color, speaker name, sprite sets and default variant. Images given as absolute paths on this computer are copied to assets/fgimage/<character folder>/ |
read_settings / update_settings | Reads / changes the project settings (title, version, author, screen size, start position, saves, export and so on) and the initial values of variables |
list_variables | The variables used in the scenarios, their initial values, and the lines that set and read them |
search | Searches all scenarios (text only, regular expressions, treating hiragana and katakana, the two Japanese syllabaries, as the same) |
story_map | The branching map (scenes and how they connect; the same as the flowchart) |
coverage | The all-routes test (lines reached and not reached, diagnostics from running). Pack scenarios are run too, with the packs laid over the main scripts as in lim coverage |
text_stats | Character counts (total, per file, per scene, per speaker) and possible spelling variants |
rename_label | Renames a scene (label), and updates jump targets and references in liminalia.json too |
i18n_sync | Updates the translation file of a language (lang/<language>.json) to the current scenarios (the same as lim i18n). With stampIds, fixed line IDs (#line:) are stamped first (lim i18n --stamp-ids) |
read_translation | Returns the translation, updated to the current scenarios, as JSON in pages. By default only items without a translation (with only set to changed, items whose source changed after translation; with all, everything). file narrows it to a scenario, and offset and limit (default 100) split it. Each item has the key, the source, the translation, the previous source and translation, the source when translated, and the place (file, line, scene, previous and next lines). Returns hash |
write_translation | Saves translations per key (pass the hash from read_translation as baseHash). Translations of text lines and choices are checked for how they’re written, and unreadable ones aren’t saved; which item it was and the reason are returned. With source, items whose source changed aren’t saved |
voice_script | Returns as JSON the rows of the recording script (the same as lim voice-script: voice file, speaker, line, acting notes, previous line, scene, place, why it won’t play, needs re-recording). Narrow it with speaker, and split it with offset and limit. With write, writes CSV files to exports/voice-script/ |
open_studio | Opens Studio and returns its URL (for when a person edits by hand). If Studio is already open, uses that |
build | Exports (browser, mac, windows, linux) |
run_tests | Runs the scenario tests (tests/*.limtest; lim test --json) and returns each test’s result as JSON. paths narrows it to files or folders |
reach | Searches for choices that reach a place from the start (lim reach --json): target (file#label, file:line, file), ending (kind or name of an ending) or endings (every ending). When found, it also returns a test that can be written as is (test) |
migrate | Moves scenarios and settings to the current format (lim migrate --json). By default nothing is rewritten and it only returns what would move; with write, it rewrites. keepBehavior also writes settings that keep the old behavior (--keep-behavior) |
rename | Renames something and rewrites the references too (lim rename; kind is label, file, variable, character, speaker, asset or macro) |
playtest | Plays the exported browser version to the end automatically and returns the errors and where it stopped as JSON (lim playtest --json --fast --log; rebuild exports first) |
read_playtest_log | Reads the log of lim playtest --log (playtest/run-N.jsonl in the export folder) and returns the pages and choices in order as JSON. run picks which run, and offset and limit (default 200) split it |
read_crash_report | Reads a crash record of an exported game, maps the program positions back to the original files and lines with the kept source maps, and returns them as JSON next to the scenario positions (lim crash --json) |
record_video | Records video from that position while advancing at real speed (lim shot --video; needs ffmpeg and Chromium). Output goes only inside the export folder. split, until, resume, redo (records one part again) |
The tools run lim commands in child processes (so that the progress the commands write to standard output doesn’t get mixed into the MCP communication).
Reading and writing scenarios, the check before saving, the command reference and the guide write no output, so they run in the same process (even if a project plugin loaded in that process writes output with
console.log, it’s sent to standard error).
The tools from register_character onward call the same processing as Studio’s dev server API (@liminalia/studio/server, and @liminalia/web/caster-server, the save API of the sprite position editor)
in the same process (packages/cli/src/commands/mcp-studio.ts). The rules and the change history are the same as in Studio:
register_character: the rules for character IDs (no spaces and none of" = ( ) # @), adding a character also adds it as a speaker, thecastProblemscheck, not saving if the file was rewritten elsewhere after it was read, keeping the contents before saving in.liminalia/backups/cast-<date and time>.json, and, for projects made by import, writing back to the import source too. The position and size of a variant (frame) are fitted to the non-transparent part of the base variant (normal → default → the first variant), the same as when you drop an image onto Studio; without a base variant, the image is fitted to the screen (the transparent parts of the PNG are read in this process;packages/cli/src/image-info.ts). For a variant with the same name, only the image is replacedupdate_settings:settingsis laid over the current settings (objects are merged all the way down, and items set tonullare removed). The shape check and, whenbaseHashis passed, the check that nothing was changed elsewhere after reading work the same as on the “Project” screen (setSettings). Initial values of variables work the same as on the “Variables” screen (setVariable; they can’t be set fortemp.). The previousliminalia.jsonis kept in.liminalia/history/@config/. Settings that run outside commands or modules (build.windows.wrap,build.windows.sign,build.mac,build.store.desktop,build.store.android),allowScript(which allows scripts in the scenario), andpathsandimport(which can point outside the workspace) can’t be changed (so instructions planted in documents the AI reads can’t use them; the user changes them inliminalia.jsonor in Studio)rename_label: the same as renaming a scene (renameLabel). The scenario change history is kept in.liminalia/history/line_state: the current position in Studio (sweepofStudioWorkspace, made by running from the beginning as in the game). For text and choice lines it’s the state just before the line is shown, and for command lines just after it runs. Lines never reached arereached: false. It’s remembered until a scenario is rewritten, so it’s fast from the second time onread_translationandwrite_translation: the same as the Translation screen in Studio (readTranslationandwriteTranslation). The previous translation file is kept in.liminalia/history/@lang/<language>/. For languages other than Japanese and English, the system screen text is listed too, asui:keyitems (the source is English)
read_cast, list_macros, line_state, the tools for translation and the voice script, restore_scenario, apply_fixes and fmt are in packages/cli/src/commands/mcp-authoring.ts.
The tools from run_tests to record_video are in packages/cli/src/commands/mcp-testing.ts, and all of them run lim commands in child processes.
list_screens, screen_shot, copy_screen, read_screen_files, write_screen_file and diff_screen are in packages/cli/src/commands/mcp-screens.ts. screen_shot runs lim shot --screen --json in a child process. Copying and diffing are the same as lim screens (@liminalia/project/screen-copy).
The instructions in the first exchange (initialize) tell the assistant to read scenario_guide before writing for the first time, and explain hash and baseHash, edit_scenario and check_text,
read_cast and list_macros, not saving when errors would increase (allowErrors), restore_scenario,
list_screens and screen_shot for changing the look of a built-in screen, and copy, edit, then capture (copy_screen, read_screen_files, write_screen_file, screen_shot, diff_screen) for changing its shape.
Not adding errors
Before saving, write_scenario, edit_scenario, restore_scenario and apply_fixes check the project as it would be before and after the save, and compare them
(the diagnostics of that scenario and the checks across scenarios, counted by file, code and message, ignoring line numbers). If errors would increase, nothing is saved, and the added errors are returned as JSON (addedErrors).
The AI fixes them and saves again. If errors that were already there just remain, it saves.
To save even with errors, set allowErrors to true (the earlier behavior; for example, when saving a scenario partway through writing it).
What was saved can be restored to the version just before with restore_scenario.
Changing a built-in screen and checking it
When the author asks to change the look of a built-in screen, such as “put the save slots side by side,” the AI goes through these steps.
- With
screenoflist_screens(for examplesaveload), read the parts table of that screen and pick the part to change (such as.lm-slots) and the theme value that applies (such assaveSlots) - Change
uiinliminalia.jsonwithupdate_settings(for a part with no value in the parts table, override its selector in the project’s CSS) - Capture it with sample content using
screen_shotand check it. Uselongforstatefor lots of content and long text,emptyfor an empty screen, andportraitfororientationfor a portrait screen
screen_shot starts a dev server and a headless Chromium each time it captures (it doesn’t use an open Studio). The sample content only exists inside the page,
and nothing is written to the project’s files or the player’s saves. For a replaced screen (replacedBy), the built-in parts table and theme values may not apply.
Change the shape of a built-in screen (copy, edit, then capture)
For a shape that theme values and project CSS can’t reach, such as reordering buttons or adding elements, copy the built-in screen template into the project and edit it (design/screen-templates.md).
- Copy it with
copy_screen(for exampleconfirm). Right after copying, it works the same as the built-in screen - Read the copied template and the screen rules (the
data-roleanddata-fieldvalues that work) withread_screen_files - Write the template (HTML and attributes), project CSS or screen JS with
write_screen_file. The template check comes back after writing; fix any errors and write again - Capture it with
screen_shotand check it
When lim check reports template-outdated after an engine update, see what changed in the built-in template with diff_screen, copy it again, and set the part’s data-version to the current version.
The scenario writing guide
scenario_guide is a short version of design/format.md for AI (packages/cli/src/commands/scenario-guide.ts).
It doesn’t list the parameters of each command, and leaves those to command_reference. The table of expression functions is made from the same table as lim reference (FUNCTION_* in @liminalia/lang).
packages/cli/test/scenario-guide.test.ts checks that the guide contains format.md’s main headings, the list of inline markup, how the tables of line kinds and value types are written, and every expression function name,
so when you edit format.md, update the guide to match.
Using it with Studio
Writing scenarios uses the same code as Studio’s dev server (write of StudioWorkspace in @liminalia/studio/server).
- Pass the
hashthatread_scenarioreturns asbaseHashtowrite_scenario. If the scenario was edited in Studio (or another editor) after it was read, nothing is saved, and the current contents andhashare returned. The AI adjusts its changes to them and saves again. A scenario that already exists isn’t saved withoutbaseHash(it can be left out only for new scenarios) edit_scenariotakes the same form asctx.script.applyfor plugins (from,to,expect,text; plugins.md). It checks only that the lines being rewritten are unchanged, not the whole file, so it can save even while someone keeps writing other lines in Studio- The contents before saving are kept in
.liminalia/history/<file>/, the same as when saving in Studio (you can restore them from “Change history” in Studio) - If Studio is open, the dev server’s file watching reports the write as an outside change, and an open scenario is merged with the text being edited (Studio waits while you’re typing, and when changes to the same line overlap, you choose in Studio)
Using an open Studio
When the Studio app (engine/run.ts in packages/studio-desktop) or lim studio opens a project, it writes the dev server’s URL and process to .liminalia/studio-server.json in the project,
and deletes it when it quits (@liminalia/studio/running). The MCP server reads this file, and uses it only when the process is running and
the dev server answers that it has the same project open (GET /__liminalia/studio/api/server). A file left behind by a crash is treated as if it weren’t there.
open_studio: if Studio is open, returns its URL without starting another dev server. An MCP server registered from the Studio app (the app’s executable run withELECTRON_RUN_AS_NODE, whereprocess.versions.electronexists) runs the app’s executable as a launch that opens the project (if the app is already running, the running app opens it or comes to the front), waits until the dev server starts, and returns the URL. The app in development receives the app’s folder inLIMINALIA_STUDIO_APP_PATH(“Connect an AI Assistant…” writes it into the registered settings). If neither applies, it startslim studioas beforescreenshot: if Studio is open, takes the screenshot withPOST /__liminalia/studio/api/shot/playon that dev server (opened and waited for the same way aslim shot; the Studio app takes it in a hidden window of the app, so neither playwright nor Chromium is needed). If not, it takes it withlim shot. Ifplaywright-coreor Chromium is missing (always the case for an MCP server registered from the Studio app), it refuses and says to open the project withopen_studioand try again
Where the tools can reach
The tools can read and write only inside the “project roots”. The roots are set with --root (as many as you like) and the environment variable LIMINALIA_MCP_ROOTS (separated by the OS path separator);
if neither is given, the root is ~/Liminalia. A project is specified by its folder name in a root, or by an absolute path pointing inside a root. Reading and writing scenarios is limited to .lim files in the scenario folder (paths.scenario in liminalia.json; scenario/ by default).
Connecting (desktop version)
From “Help → Connect an AI Assistant…” in the desktop version’s menu, choose Claude Desktop, Claude Code or Codex,
then choose the folder where the AI may put projects (the project root), and Liminalia is registered in that assistant’s settings. You don’t need Node or npm
(the app’s executable is started as Node with ELECTRON_RUN_AS_NODE=1, and runs the mcp processing of the engine inside the app).
- Claude Desktop: writes
mcpServers.liminaliainclaude_desktop_config.json(other servers and items are kept, and the contents before the change are kept in.bak) - Claude Code: runs
claude mcp add-json --scope user liminalia …(theclaudecommand is required) - Codex: rewrites the
[mcp_servers.liminalia]section of~/.codex/config.toml(inCODEX_HOMEif that’s set) (other sections are kept)
After registering, restart that assistant. How each one is written is in packages/studio-desktop/src/shared/assistants.ts.
Connecting (running from this repository)
Claude Code:
claude mcp add liminalia -- node /path/to/liminalia/packages/cli/bin/lim.mjs mcp --root ~/Liminalia
Codex (~/.codex/config.toml):
[mcp_servers.liminalia]
command = "node"
args = ["/path/to/liminalia/packages/cli/bin/lim.mjs", "mcp", "--root", "/Users/me/Liminalia"]
Claude Desktop (mcpServers in claude_desktop_config.json):
{ "liminalia": { "command": "node", "args": ["/path/to/liminalia/packages/cli/bin/lim.mjs", "mcp", "--root", "/Users/me/Liminalia"] } }
You need the same version of Node.js as in the getting started section of the README.