Story Mode Engine exposes a unified Model Context Protocol (MCP) surface across its native desktop workbench (.NET 10 + Avalonia 11 + SkiaSharp), its Vite web preview, and standalone stdio CLI hosts.
Any MCP-capable client or LLM can connect to inspect .sme projects, author scripts and game entities with strict cross-file validation, stage 16:9 Artist Stage Previews, capture PNG screenshots for visual verification, launch Godot 4.7 debug states, and drive 4-panel interactive Spotlight coach marks and multi-step guided tours across UI controls and canvas nodes.
This document is also served directly inside the protocol as resource sme://docs/guide.
1. Quick Orientation and Connection Modes
| Mode | Executable or Endpoint | Node.js Needed | Best Used For | Live GUI Support |
|---|
1. Native Companion Binary (stdio) | StoryModeEngine.Mcp (packaged next to StoryModeEngine) | No | Claude Desktop, Cursor, Antigravity, standalone scripts on Windows, macOS, and Linux | Auto-bridges to open Story Mode Engine desktop app via mcp-session.json; runs headless .sme disk edits when closed |
| 2. Desktop App Embedded HTTP | http://127.0.0.1:47831/mcp (default port, fallback if occupied) | No | HTTP Streamable MCP clients, direct curl / SDK calls while Story Mode Engine is open | Direct in-process access to live Avalonia window on Dispatcher.UIThread |
| 3. Vite Web Preview HTTP | http://127.0.0.1:5173/api/studio/mcp | Yes | Browser preview workflows started with npm run dev or vite preview | Proxies live GUI commands over SSE to open /studio.html tabs |
4. TypeScript Standalone CLI (stdio) | npm run mcp (tsx src/mcp/cli.ts) | Yes | Repo contributors testing Zod v4 tools in CI or bridging Desktop/Web sessions from terminal | Auto-bridges to open Story Mode Engine desktop app or web preview via mcp-session.json |
Decision Rule: Which Mode Should I Use?
- If you installed Story Mode Engine (Windows, macOS, or Linux): Configure your MCP client to spawn
StoryModeEngine.Mcp (StoryModeEngine.Mcp.exe on Windows). It requires zero runtime dependencies, reads/writes .sme files headlessly when the app is closed, and automatically upgrades to live GUI + Spotlight + visual capture whenever Story Mode Engine is running. - If you are working inside the
StoryModeEngine repository: Use npm run mcp for stdio clients or http://127.0.0.1:5173/api/studio/mcp during npm run dev. - When connected inside Story Mode Engine: Click the
MCP pill in the status strip (topbar.mcp_status) to view the active port, copy-ready client JSON snippets, enable/disable toggle, and recent tool activity log.
2. Client Setup Recipes
Claude Desktop
Add storymodeengine to your claude_desktop_config.json:
- Windows:
%APPDATA%\Claude\claude_desktop_config.json - macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json
Installed Story Mode Engine Desktop App (Recommended, Zero Node.js)
{
"mcpServers": {
"storymodeengine": {
"command": "C:\\Users\\YOU\\AppData\\Local\\StoryModeEngine\\current\\StoryModeEngine.Mcp.exe",
"args": []
}
}
}
On macOS/Linux, point "command" to the packaged StoryModeEngine.Mcp binary inside your app directory (or open the MCP Server and Artist Spotlight dialog from the MCP status pill inside Story Mode Engine and click Copy Config JSON to copy the exact installed path).
Optional Pre-Bound Project or Explicit URL Flags
{
"mcpServers": {
"storymodeengine": {
"command": "StoryModeEngine.Mcp",
"args": ["--project", "D:\\Games\\MyStory", "--url", "http://127.0.0.1:47831/mcp"]
}
}
}
Repository Source Setup (npm run mcp)
{
"mcpServers": {
"storymodeengine": {
"command": "npx",
"args": ["tsx", "D:\\StoryModeEngine\\src\\mcp\\cli.ts", "--project", "D:\\Games\\MyStory"]
}
}
}
Cursor (.cursor/mcp.json)
{
"mcpServers": {
"storymodeengine-stdio": {
"command": "C:\\Users\\YOU\\AppData\\Local\\StoryModeEngine\\current\\StoryModeEngine.Mcp.exe",
"args": []
},
"storymodeengine-http": {
"type": "http",
"url": "http://127.0.0.1:47831/mcp"
}
}
}
Antigravity / Generic mcpServers JSON
{
"mcpServers": {
"storymodeengine": {
"command": "StoryModeEngine.Mcp",
"args": ["--project", "/path/to/your-project"]
}
}
}
Claude Code CLI
claude mcp add-json storymodeengine '{"command":"StoryModeEngine.Mcp","args":["--project","/path/to/your-project"]}'
CLI Flags and Environment Variables
Both StoryModeEngine.Mcp and src/mcp/cli.ts support:
--project <dir-or-sme> (or -p <path> in TS CLI): Sets default projectRoot when tools omit projectRoot.--url <http://127.0.0.1:PORT/mcp> (or -u <url> in TS CLI): Forces a specific running Studio HTTP endpoint.SME_DEFAULT_PROJECT: Environment variable fallback for default project directory or .sme manifest file.SME_MCP_URL: Explicit loopback HTTP endpoint override for stdio bridging.
Wire Protocol Examples (JSON-RPC 2.0)
Supported MCP protocol versions: 2025-03-26 (default) and 2024-11-05. Server identifier: serverInfo.name = "storymodeengine".
HTTP Streamable (POST http://127.0.0.1:47831/mcp)
curl -s -X POST http://127.0.0.1:47831/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26"}}'
curl -s -X POST http://127.0.0.1:47831/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"sme_validate_and_lint","arguments":{}}}'
NDJSON (stdio over stdin/stdout)
{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26"}}
{"jsonrpc":"2.0","method":"notifications/initialized"}
{"jsonrpc":"2.0","id":2,"method":"tools/list"}
{"jsonrpc":"2.0","id":3,"method":"resources/read","params":{"uri":"sme://docs/guide"}}
{"jsonrpc":"2.0","id":4,"method":"prompts/get","params":{"name":"audit_project_health","arguments":{"chapter":"1"}}}
Health check endpoint (GET without running a tool):
- Story Mode Engine Desktop App:
GET http://127.0.0.1:47831/mcp/health - Story Mode Engine Web Preview:
GET http://127.0.0.1:5173/api/studio/mcp/health
3. Session Discovery (mcp-session.json) and Security Guardrails
Session Auto-Discovery Paths and Priority Order
When StoryModeEngine.Mcp or npm run mcp starts, stdio requests resolve live Story Mode Engine endpoints in this priority order:
--url CLI argumentSME_MCP_URL environment variable- Desktop app session file (
mcp-session.json inside SettingsStore.SettingsDirectory):- Windows:
%APPDATA%\StoryModeEngine\mcp-session.json - macOS:
~/Library/Application Support/StoryModeEngine/mcp-session.json - Linux:
$XDG_CONFIG_HOME/StoryModeEngine/mcp-session.json or ~/.config/StoryModeEngine/mcp-session.json
- Workspace Vite session file (walking upward from current working directory):
<repo>/artifacts/.mcp-session.json
Session JSON fields:
{
"url": "http://127.0.0.1:47831/mcp",
"healthUrl": "http://127.0.0.1:47831/mcp/health",
"port": 47831,
"pid": 12345,
"runtime": "avalonia-desktop",
"mode": "http",
"projectRoot": "D:/Games/MyStory",
"version": "0.2.8"
}
Offline vs. Live Proxying Behavior
sme_* project tools run locally on disk even when no Studio window is open. Whenever a live Studio session IS detected and matches the edited projectRoot, project/asset mutations automatically ask Studio to refresh safely.studio_* GUI tools (studio_navigate, studio_spotlight, studio_stage_artist_preview, studio_capture_visual_preview, etc.) require a running Studio GUI. If no live Studio window is reachable, they return a clear actionable error telling the user to launch Studio.
Built-In Security and Safety Guardrails
- Strict Loopback Binding (
127.0.0.1): Embedded HTTP servers never bind to 0.0.0.0 or LAN interfaces. - DNS Rebinding and CSRF Protection (
HTTP 403): Requests with non-loopback Host headers (anything other than 127.0.0.1, localhost, or [::1]) or non-loopback Origin headers are rejected immediately with 403 Forbidden. - Pre-Write Cross-File Validation: Every
sme_* edit validates the complete ProjectBundle (validateProjectBundle in TS, SmeProjectValidator.Validate in C#) BEFORE writing to disk. Invalid changes leave files untouched and return structured errors. - Explicit Confirmation for Destructive / Remote Operations:
sme_delete_script, sme_delete_dialogue_node, sme_delete_character_pose, sme_delete_hub_entity, sme_delete_topdown_building, sme_delete_item, sme_delete_knowledge, sme_delete_minigame, sme_delete_entity, sme_delete_snapshot, and sme_git_push fail unless confirm: true is passed. - Dirty-State Protection:
studio_open_project and studio_reload_project refuse to overwrite unsaved edits in the Studio UI unless force: true is supplied, and automatic background reloads preserve dirty user edits cleanly. - Synchronous UI Re-entrancy Lock (
AsyncActionGate): UI mutations block overlapping clicks, modal saves, and Spotlight dismissals while an async action is running. - Windows Piped Stdio UTF-8 BOM Tolerance: Both
McpStdioHost.cs and src/mcp/cli.ts strip leading \uFEFF characters on incoming stdin lines.
4. .sme Project Mental Model for LLMs
Directory Anatomy
my-story/
my-story.sme # Root ProjectManifest (or <slug>.storymodeengine / project.json)
characters.json # Cast, startingStats, bossConfig, per-character poses, and outfit pose slots
assets.json # ONLY place mapping semantic descriptor keys -> relative asset files
art-manifest.json # Auto-distilled inventory of fulfilled vs. missing asset slots
scripts/*.json # DialogueScript files (10 node types)
hubs/*.json # 2.5D JRPG / 2D exploration HubDefinition scenes
minigames/*.json # Registered MinigameManifest configurations
items.json # Optional trinkets, boss relics, consumables, key items
knowledge.json # Optional per-learner Truths & Insights
campaign.json # Optional multi-chapter structure + POV rotation rules
saves/*.json # Save snapshots and _godot_launch.json
assets/... # Concrete PNG, SVG, WebP, OGG, MP3, WAV, MP4, WebM, OGV files
Critical Domain Invariants
- Semantic Asset Addressing Only: Scripts, hubs, and minigames NEVER reference file paths directly. They reference semantic descriptors (or upload via
sme_upload_asset with a descriptor key like environment:town_square:default or character:companion:default:vn_portrait:neutral). - Node Types (All 10 Supported by
sme_upsert_dialogue_node):line: { type: "line", speaker?: { characterId, expression, position }, listener?: { characterId, expression, position }, text, presentation?, background?, bgmCue?, sfxCue?, combatMode?, next? }choice: { type: "choice", prompt?, speaker?, choices: [{ id, label, condition?, next }], background? }branch: { type: "branch", branches: [{ condition, next }], defaultNext? }mutate: { type: "mutate", mutations: [...], next }transition: { type: "transition", background?, bgmCue?, effect?, durationMs?, next }cinematic: { type: "cinematic", mode: "video" | "timeline", title?, skippable?, skipLabel?, durationSec?, initialColor?, persistBackground?, video?, poster?, volume?, muted?, events?: [{ id, atSec, durationSec?, easing?, action, ... }], mutations?, next } (supports 10 timed actions: set_image, fade, focus, camera, caption, play_bgm, stop_bgm, play_sfx, effect, mutate, auto-advancing to next on completion)tiered_stat_check: { type: "tiered_stat_check", prompt?, speaker?, approaches: [{ id, label, stat, cleanThreshold, costlyThreshold, nextClean, nextCostly, nextFail, ... }] }launch_exploration: { type: "launch_exploration", hubId, objectiveHint?, onReturn }launch_minigame: { type: "launch_minigame", minigameId, params?, onWin?, onLose?, onDraw?, onQuit?, onComplete? }end: { type: "end", nextScriptId?, returnToHub?: boolean }
- Outgoing Edge Ports (
sme_rewire_dialogue_edge, sme_draw_connected_node):- Scalar ports:
next, defaultNext, onReturn, onWin, onLose, onDraw, onQuit, onComplete - Choice option ports:
choice:<choiceId>, or choice:new (appends a new choice option, optionally named via choiceLabel) - Branch arm ports:
branch:<zeroBasedIndex>, or branch:new (appends a new condition branch arm) - Stat-check outcome ports:
approach:<approachId>:clean, approach:<approachId>:costly, approach:<approachId>:fail
- Sticky Scene Background Precedence (Visual Key & Node Canvas):
- explicit node
background or cinematic initial frame (override) - upstream
transition background or cinematic (persistBackground: true) final background along incoming edges (transition) - script
defaultBackground (script_default) - exploration hub backdrop on
launch_exploration nodes (hub)
Omit projectRoot whenever a project is already open in Studio or set via --project / SME_DEFAULT_PROJECT.
| Tool Name | Purpose | Key Arguments (* = required) | Returns / Notes |
|---|
sme_list_projects | List known .sme projects (recent Studio folders / workspace projects). | (none) | { activeProjectRoot, projects } |
sme_create_project | Create a starter .sme project directly via <dir>/<slug>.sme OR slug + parentDir. | filePath OR slug + parentDir; optional name, description, companionName | Creates starter script, companion, hub, minigame, and manifest |
sme_get_project_summary | Inspect project metadata, entity counts, asset totals, and balance error/warning counts. | projectRoot? | Concise overview before full reads |
sme_get_project_bundle | Read a filtered section or full project bundle. | projectRoot?, section (project|characters|scripts|hubs|minigames|items|knowledge|campaign|assetCatalog|all), id? | Filter with section + id to keep payloads small |
sme_update_project_config | Update project metadata, initial entry mode/script/hub, or RPG config (affinityMode, deathMode, onPlayerDefeat, weakenedStatPenalty, stats, synergies, theme, titleMenu). | projectRoot?, name?, description?, initialMode? (dialogue|hub), initialScriptId?, initialHubId?, config? | Validated before save |
sme_validate_and_lint | Run strict cross-file schema validation, reachability / Balance Linter (stat checks, data-driven perimeter posts, dynamic POV/boss reachability, meeting coverage, boss knowledge/exploit audits), and optional chapter POV matrix. | projectRoot?, matrixChapter? | Check this before declaring any project edit done |
| Tool Name | Purpose | Key Arguments (* = required) | Returns / Notes |
|---|
sme_export_manifest | Export standalone .sme root manifest JSON (matching Studio Export .sme). | projectRoot?, destinationPath? | Writes .sme/.storymodeengine/.json file when destinationPath given, always returns manifestJson |
sme_submit_feature_request | Submit a feature request or bug report (routes to Linear if LINEAR_API_KEY is set, else local draft). | title*, details*, requestType?, targetArea?, projectRoot? | Automatically attaches live Studio tab/node context when connected |
| Tool Name | Purpose | Key Arguments (* = required) | Returns / Notes |
|---|
sme_list_scripts | List all dialogue scripts with title, entry node, node count, and default background status. | projectRoot? | Quick index of scripts/*.json |
sme_get_script | Read full script JSON PLUS computed flow layout, unreachable node IDs, and sticky resolved backgrounds. | scriptId*, projectRoot? | Shows exact graph topology and inherited backgrounds |
sme_upsert_script | Create or replace a full DialogueScript JSON object. | scriptId*, script*, setAsInitial?, projectRoot? | Cross-file validated before disk write |
sme_delete_script | Delete a dialogue script (confirm: true required). | scriptId*, confirm* (true), projectRoot? | Refuses if referenced by initialScriptId or campaign/other scripts |
sme_upsert_dialogue_node | Add or update any of the 10 node types inside an existing script. | scriptId*, nodeId*, node*, setAsEntry?, projectRoot? | Cross-file validated before disk write |
sme_delete_dialogue_node | Delete a dialogue node from a script (confirm: true required). | scriptId*, nodeId*, confirm* (true), projectRoot? | Fails on entry node or dangling references |
sme_draw_connected_node | Create a new default dialogue node of any of the 10 types and wire an outgoing port from fromNodeId to it atomically (splicing any replaced target to preserve flow). | scriptId*, fromNodeId*, nodeType*, nodeId?, port?, choiceLabel?, node?, projectRoot? | Mirrors Studio drag-to-draw workflow; rejects end source nodes |
sme_rewire_dialogue_edge | Rewire an outgoing port on fromNodeId to toNodeId. | scriptId*, fromNodeId*, toNodeId*, port?, choiceLabel?, projectRoot? | Supports next, defaultNext, onReturn, onWin, onLose, onDraw, onQuit, onComplete, choice:<id>, choice:new, branch:<i>, branch:new, approach:<id>:clean|costly|fail |
sme_create_social_scene | Create a standardized chapter POV x NPC conversation script (<povId>_talks_to_<npcId>_ch<N> or _m<M>). | chapter*, povId*, npcId*, meeting? (1..10), title?, openingLine?, defaultBackground?, projectRoot? | Preserves existing script safely if already created |
sme_scaffold_social_meetings | Scaffold Meeting 1, 2, and 3 branching social scripts with choices and affinity mutations for a POV x NPC pair. | chapter*, povId*, npcId*, meetings? ([1,2,3]), defaultBackground?, overwrite?, projectRoot? | Skips existing meeting scripts unless overwrite: true |
| Tool Name | Purpose | Key Arguments (* = required) | Returns / Notes |
|---|
sme_list_characters | List cast members, playable/role flags (playable, initiallyPlayable, inSocialRoster, canBeBoss), starting stats, bossConfig, effective poses, and variant IDs. | projectRoot? | Read before authoring dialogue speakers |
sme_upsert_character | Create or update a CharacterDefinition in characters.json (auto-syncs poses across outfits if supplied). | characterId*, character*, projectRoot? | Cross-file validated |
sme_upsert_character_variant | Create or update an outfit variant, synced pose slots, hub animations, or minigame actors. | characterId*, variantId*, variant*, setAsDefault?, projectRoot? | Auto-updates distilled manifest slots |
sme_upsert_character_pose | Create or update a full character POSE definition (displayName, mood, framing, facing, artBrief, mediaType, rigSpec, tags, stageTransform) and sync all outfits on that character. | characterId*, poseId*, pose*, projectRoot? | Ensures every outfit gets a slot for this pose |
sme_delete_character_pose | Delete a character POSE definition and remove its synced slot across all outfits (confirm: true required). | characterId*, poseId*, confirm* (true), projectRoot? | Refuses deleting the last remaining pose |
sme_list_hubs | List exploration hubs (2_5d_jrpg, top_down_2d, hotspot_nodes), pitch, ground color, hasTopDownMap, building counts, movement style, and entities. | projectRoot? | Hub index |
sme_upsert_hub | Create or update a HubDefinition (hubs/<id>.json), including scene3d and topDown2d grids/buildings. | hubId*, hub*, projectRoot? | Supports 2.5D camera/ground and Top-Down 2D grids |
sme_upsert_hub_entity | Create or update an interactive NPC, door (triggerMode: "walk_in", exitOffset), kiosk, portal, or inspectable entity inside a hub. | hubId*, entityId*, entity*, projectRoot? | Cross-file validated |
sme_delete_hub_entity | Delete an entity from a hub (confirm: true required). | hubId*, entityId*, confirm* (true), projectRoot? | Validates hub integrity before saving |
sme_paint_topdown_tiles | Paint NES/GameBoy top_down_2d map tiles and/or fill the grid with a base tile type. | hubId*, fillTile?, tiles? ([{ col, row, tile }]), projectRoot? | Auto-initializes 20x14 grid and syncs bounds |
sme_upsert_topdown_building | Create or update a solid building footprint and optional linked walk_in doorway HubEntity on a top_down_2d hub. | hubId*, buildingId*, building*, ensureDoorEntity?, dialogueScriptId?, projectRoot? | Keeps building footprint and door alignment in sync |
sme_delete_topdown_building | Delete a building from a top_down_2d hub (confirm: true required) and optionally remove its linked doorway entity. | hubId*, buildingId*, confirm* (true), deleteLinkedDoorEntity?, projectRoot? | Cleanly updates buildings and entities |
sme_list_miniscene_templates | List all 14 built-in exploration, RPG combat, and tabletop/arcade mini-scene templates. | (none) | Use returned id in sme_add_miniscene_from_template |
sme_add_miniscene_from_template | Instantiate any of the 14 mini-scene templates and optionally wire it into a script. | templateId*, id*, name?, wireMode? (append_node|wire_after_selected|attach_to_choice|standalone_only), scriptId?, selectedNodeId?, returnNodeId?, participantCharacters?, projectRoot? | Creates hub/minigame/stat-check + wiring node |
sme_list_minigames | List registered MinigameManifest files (minigames/*.json). | projectRoot? | Returns IDs, minigameType, templateType, godotScenePath, participants |
sme_upsert_minigame | Create or update a MinigameManifest JSON object (supports posts[] defense configs, dieSides, startingComposure, exposeDamage, allyAssistThreshold, maxCardsPerTurn, and handSize). | minigameId*, minigame*, projectRoot? | Validates participants, statIds, & asset descriptors |
sme_delete_minigame | Delete a minigame manifest and clean up minigames/<id>.json (confirm: true required). | minigameId*, confirm* (true), projectRoot? | Fails if any dialogue node or campaign chapter still references it |
sme_init_campaign | Initialize a composable starter campaign.json on a project without one (or overwrite with overwrite: true). | title?, prologueScriptId?, epilogueScriptId?, firstChapterTitle?, conversationBudget?, overwrite?, projectRoot? | Sets files.campaign and writes Chapter 1 steps |
sme_upsert_campaign_chapter | Create or update a CampaignChapter entry in campaign.json (supports legacy slots and composable steps[], completionCriteria, nextChapterRules, posts[], secrets_deck, and duel/deck tuning). | chapter*, projectRoot? | Auto-initializes campaign.json if absent |
sme_get_campaign_flow | Inspect normalized chapter step sequences, completion criteria, conditional transitions, and social/POV rules. | projectRoot? | Normalizes legacy chapters into ordered steps[] |
sme_upsert_chapter_step | Create, update, or reorder a CampaignChapterStep inside a chapter (normalizing legacy chapters if needed). | chapterId*, step*, insertAtIndex?, projectRoot? | Supports all 8 step types and completion criteria |
sme_update_campaign_rules | Update campaign-level rules or chapter completionCriteria, nextChapterRules, socialMode, socialHubId, and povSwitch guardrails. | title?, prologueScriptId?, epilogueScriptId?, gameOverScriptId?, socialRules?, chapterId?, completionCriteria?, nextChapterRules?, socialMode?, socialHubId?, chapterGameOverScriptId?, povSwitch?, projectRoot? | Also syncs povSwitch patch to pov_switch steps |
sme_delete_campaign_chapter | Delete a chapter from campaign.json (confirm: true required). | chapterId*, confirm* (true), projectRoot? | Refuses deleting the last remaining chapter |
sme_delete_chapter_step | Delete a composable step from a chapter (confirm: true required). | chapterId*, stepId*, confirm* (true), projectRoot? | Refuses deleting the last remaining step |
sme_upsert_item | Create or update a trinket, boss relic, key item, or consumable in items.json (supports statBonuses, combatEffects, and synergyTag). | itemId*, item*, projectRoot? | Auto-initializes items.json if absent |
sme_delete_item | Delete an item or boss relic from items.json (confirm: true required). | itemId*, confirm* (true), projectRoot? | Refuses deleting items still referenced by boss relicId |
sme_upsert_knowledge | Create or update a Truth or Insight in knowledge.json (relatedCharacterId, onLearnScriptId, confrontationScriptId, confrontationCondition). | knowledgeId*, entry*, projectRoot? | Auto-initializes knowledge.json if absent |
sme_delete_knowledge | Delete a Truth or Insight entry from knowledge.json (confirm: true required). | knowledgeId*, confirm* (true), projectRoot? | Refuses deleting entries still referenced by truthId / truthAutoCleanWin |
sme_update_initial_state | Patch project.initialState (activeCharacterId, currentChapter, currentPhase, flags, relationships, characterVariants, location, inventory). | initialState*, projectRoot? | Merges fields & validates |
sme_delete_entity | Delete a character, character_variant, hub, hub_entity, item, knowledge, or campaign_chapter (confirm: true required). | entityType*, id*, parentId? (required for character_variant & hub_entity), confirm* (true), projectRoot? | Refuses deleting dangling references, last variant, or active defaultVariant |
| Tool Name | Purpose | Key Arguments (* = required) | Returns / Notes |
|---|
sme_get_art_manifest | Filter art-manifest.json slots by fulfillment status, category, character, or substring search. | projectRoot?, status? (all|missing|fulfilled), category? (all|character|environment|minigame|ui_audio), characterId?, search? | Inspect before uploading art/audio |
sme_upload_asset | Write PNG/SVG/JPG/WebP/OGG/MP3/WAV/MP4/WebM/OGV asset into assets/, register descriptor key in assets.json, and re-distill. | descriptorKey*, mediaType*, category*, filename? (required with base64Data), base64Data? OR sourceFilePath?, projectRoot? | Provide either sourceFilePath or base64Data |
sme_preview_asset_image | Return an MCP image content block (png/jpg/webp/svg) for a fulfilled visual asset so vision LLMs can inspect it. | assetKey*, projectRoot? | Accepts semantic descriptor key or relative path |
| Tool Name | Purpose | Key Arguments (* = required) | Returns / Notes |
|---|
sme_list_saves | List all saved snapshots under saves/. | projectRoot? | Includes metadata, chapter, phase, POV |
sme_save_snapshot | Write a save snapshot JSON into saves/ from a full saveFile or launch parameters + playtest boosts. | name*, saveFile?, chapter?, phase?, povId?, scriptId?, nodeId?, hubId?, minigameId?, statBonus?, affinityBonus?, learnAllKnowledge?, label?, projectRoot? | Great for repeatable mid-game regression fixtures |
sme_delete_snapshot | Delete a snapshot file under saves/ (confirm: true required). | filename*, confirm* (true), projectRoot? | Requires confirm: true |
sme_git_status | Inspect Git repo initialization, branch, remote, ahead/behind counts, and changed files. | projectRoot? | Maps directly to Tab 7 status strip |
sme_git_init | Initialize a Git repository in the project directory. | projectRoot? | Safe no-op/init |
sme_git_pull | Pull latest commits from remote inside the project Git repository. | projectRoot? | Auto-refreshes open Studio UI on change |
sme_git_commit | Stage all project changes and create a commit. | message*, projectRoot? | Follows repo commit hygiene |
sme_git_push | Push local commits to configured remote (confirm: true required). | confirm* (true), projectRoot? | Requires confirm: true |
sme_godot_status | Inspect saved/detected Godot 4.7 executable and bundled/workspace godot/ runtime dir. | projectRoot? | Run before launching Godot |
sme_configure_godot | Save or clear the local Godot 4.7 executable path (binaryPath: "" resets to auto-detect). | binaryPath* | Returns refreshed godot status object |
sme_launch_godot | Write saves/_godot_launch.json (from snapshotFilename, custom saveFile, or chapter/phase/POV/boost args) and optionally launch Godot 4.7. | projectRoot?, writeOnly?, ignoreLaunchSave?, binaryPath?, snapshotFilename?, saveFile?, targetMode?, chapter?, phase?, povId?, scriptId?, nodeId?, hubId?, minigameId?, statBonus?, affinityBonus?, learnAllKnowledge?, label? | Use writeOnly: true in automated headless workflows |
| Tool Name | Purpose | Key Arguments (* = required) | Returns / Notes |
|---|
studio_get_ui_state | Read active tab, selections, isDirty, isBusy, openModal, Spotlight status, manifest summary, lint counts, Git status. | (none) | Always inspect isDirty / isBusy before destructive Studio UI calls |
studio_open_project | Open a folder or .sme manifest in the live Studio window. | projectPath*, force? | Refuses while isDirty unless force: true |
studio_reload_project | Reload the open project from disk into the live Studio UI. | force? | Refuses while isDirty unless force: true |
studio_save_project | Trigger Save Project in the live Studio window. | (none) | Validates and persists unsaved Studio UI edits |
studio_navigate | Switch workspace tab/sub-tab, select script/node/character/hub/asset, zoom/pan canvas, toggle Visual Key or Reference card, and set Artist filters. | tab? (story|characters|artist|exploration|campaign|saves|git), castSubTab? (characters|items|knowledge), scriptId?, nodeId?, characterId?, hubId?, assetKey?, canvasZoom? (0.4..2.0), resetCanvasView?, centerOnNodeId?, showVisualKey?, showInspectorReference?, assetFilter? (all|missing|character|environment|minigame|ui_audio|audio), assetCharacterFilter?, assetSearch? | Clean programmatic navigation |
studio_stage_artist_preview | Switch to Asset Preview and compose a 16:9 live VN scene composition (applying pose stageTransform if set), or reset override. | assetKey?, backgroundAssetKey?, characterId?, variant?, expression?, pose?, listenerCharacterId?, speakerLabel?, dialogueText?, audioAssetKey?, clearOverride? | Non-destructive visual composition check |
studio_list_ui_targets | Return all 61 static Spotlight targets + 8 dynamic target patterns with live currentlyVisible flags. | (none) | Inspect before running studio_spotlight |
studio_spotlight | Show a 4-panel dimmed cutout and explainer callout over any static target or dynamic entity/canvas node. | target*, title*, message*, interactive?, placement? (auto|right|left|bottom|top), padding?, badge? | Automatically switches tab and centers node if needed |
studio_spotlight_tour | Launch a multi-step guided walkthrough (Back / Next / Done + auto-navigation + optional stagePreview per step). | steps* ([{ target, title, message, interactive?, placement?, padding?, stagePreview? }]), startIndex? | Ideal for onboarding artists & writers |
studio_clear_spotlight | Dismiss active Spotlight or Guided Tour cleanly. | (none) | Fails if Studio is currently busy |
studio_show_notice | Show a concise non-blocking message on the Studio status bar. | message*, isError? | Useful feedback after background tasks |
studio_capture_visual_preview | Render and return an MCP image/png block of stage_preview, node_canvas, or window for visual inspection. | target? (stage_preview|node_canvas|window) | Check alignment, typography, and stage composition directly |
6. sme:// Resources and Prompts Reference
Static sme:// Resources (10)
| URI | MIME Type | Contents |
|---|
sme://docs/guide | text/markdown | Complete docs/MCP.md manual (this guide). |
sme://schemas/index | application/json | Index of all bundled Draft 2020-12 JSON Schema URIs. |
sme://project/summary | application/json | Same summary payload as sme_get_project_summary. |
sme://project/art-manifest | application/json | Distilled art-manifest.json slots and fulfillment counts. |
sme://project/missing-assets | application/json | Filtered list of missing art/audio slots. |
sme://project/balance-report | application/json | Full sme_validate_and_lint validation + Balance Linter report. |
sme://project/campaign-flow | application/json | Normalized chapter steps, completion criteria, conditional transitions, and social/POV rules from sme_get_campaign_flow. |
sme://templates/minigames | application/json | Full 14-template catalog (id, name, category, modeKind, godotScenePath, defaultParams). |
sme://studio/ui-state | application/json | Live StudioUiStateSnapshot (or { connected: false, runtime: "headless-stdio" } offline). |
sme://studio/ui-targets | application/json | Canonical catalog of all 61 static targets and 8 dynamic target patterns (currentlyVisible reflects live window if connected). |
Resource URI Templates (2)
| URI Template | MIME Type | Contents |
|---|
sme://schemas/{filename} | application/schema+json | Exact Draft 2020-12 JSON Schema for any .schema.json file (e.g. sme://schemas/project.schema.json, sme://schemas/dialogue.schema.json). |
sme://project/scripts/{scriptId} | application/json | Full script + graph layout + sticky backgrounds for scriptId. |
Built-In MCP Prompts (4)
| Prompt Name | Optional Arguments | Guided Workflow |
|---|
guide_artist_missing_art | projectRoot | Inspect missing art/audio slots, focus Asset Preview, stage 16:9 compositions, and launch an artist Spotlight tour. |
draft_branching_scene | scriptId, premise | Read characters & layout, author/expand a branching VN scene, validate/lint cross-file refs, and spotlight the key decision node. |
audit_project_health | projectRoot, chapter | Validate schemas, inspect chapter POV social coverage + Balance Linter, and highlight issues in Studio. |
review_character_assets | characterId | Inspect character outfit/portrait fulfillment, preview images, stage 16:9 composition, and capture a PNG visual check. |
7. Studio UI Spotlight Target Catalog (61 Static + 8 Dynamic)
Interactive vs. Non-Interactive Mode
interactive: false (default): All background controls and the cutout region are shielded; the artist reads the explainer card and clicks Next, Back, or Got it (or presses Escape when idle).interactive: true: Pointer clicks pass directly through the cutout to the highlighted control (such as typing a pitch angle or picking a floor color) while surrounding panels remain dimmed and blocked.
| Target ID | Control |
|---|
topbar.open_folder | Open Folder button |
topbar.new_project | + New .sme project button |
topbar.export_sme | Export .sme manifest button |
topbar.import_sme | Import .sme manifest button |
topbar.feature_request | Feature request / bug report button |
topbar.save | Save project button |
topbar.playtest | Godot... (Playtest Anywhere) button |
topbar.godot_settings | Godot 4.7 Engine Settings tool rail button |
topbar.run_godot | Run Game (F5) launch button |
topbar.mcp_status | MCP status pill and settings dialog launcher |
Workspace Tab Targets
| Target ID | Tab |
|---|
tab.story | Node Canvas tab |
tab.characters | Cast tab |
tab.artist | Asset Preview tab |
tab.exploration | 2.5D Hub tab |
tab.campaign | Matrix tab |
tab.saves | Snapshots tab |
tab.git | Git tab |
Per-Tab Static Control Targets
| Tab | Target ID | Control |
|---|
story | story.outliner | Scripts and nodes outliner dock |
story | story.node_canvas | Interactive Skia / SVG dialogue flow canvas |
story | story.draw_mode_btn | Draw Mode toggle button (D) for dragging outgoing transitions from cards or output nubs |
story | story.visual_key | Docked Visual Key / Index legend (auto-expands on spotlight) |
story | story.inspector | Selected node inspector dock |
story | story.inspector_bg_card | Sticky Scene Background preview & assignment card |
story | story.inspect_bg_art_btn | Inspect BG Art quick-jump button |
story | story.inspector_cinematic | Cinematic Sequencer card (16:9 preview, playback scrubber, video/timeline event editor) |
story | story.inspector_branch | Visual Conditional Branching builder card (branches, conditions, default fallback) |
story | story.inspector_mutate | Visual World State Mutations builder card (ordered mutations and next node) |
story | story.inspector_transition | Visual Transition and Audio node editor (type, duration, color, direction, BGM/SFX) |
story | story.inspector_reference | Collapsible Read-Only Reference card (auto-expands on spotlight) |
story | story.add_miniscene_btn | + Mini Scene template wizard button |
characters | characters.list | Cast roster list and add-character box |
characters | characters.inspector | Character stats, boss config, character poses, and outfit pose slots |
characters | characters.role_flags | Playable, roster, boss eligibility flags, name color, profile icon, and side portrait |
characters | characters.boss_profile | Toggleable Boss Profile config (weakStat, resistedStat, resolveMax, attackPower, relicId, battleScriptId) |
characters | characters.poses_section | Per-character defined Poses list with + Add Pose dialog launcher |
characters | characters.add_pose_btn | + Add Pose button opening the Pose Definition modal |
characters | characters.outfits_section | Outfit variants with synced upload and stage preview slots for every pose |
characters | characters.items_editor | Items and Relics (items.json) CRUD editor (stat bonuses, combat effects, synergy tag) |
characters | characters.knowledge_editor | Knowledge and Truths (knowledge.json) CRUD editor (expose damage/line, hooks, confrontation condition) |
artist | artist.stage_preview | 16:9 Live Artist Stage composition viewport |
artist | artist.filters | Asset category chips, character dropdown, and search box |
artist | artist.grid | Distilled asset cards and Upload / Replace actions |
artist | artist.reset_stage_btn | Reset Stage Override button (visible during studio_stage_artist_preview) |
exploration | exploration.hub_list | Defined 2.5D/2D exploration hubs list |
exploration | exploration.traversal_mode | Traversal mode selector (2_5d_jrpg, top_down_2d, hotspot_nodes) |
exploration | exploration.camera_pitch | 2.5D Camera Pitch numeric control (5 to 85 deg) |
exploration | exploration.ground_color | 2.5D Ground Color swatch & hex input |
exploration | exploration.topdown_settings | Top-Down 2D grid size, tile size, movement style (tile_grid/smooth), render mode, and custom asset overrides |
exploration | exploration.topdown_painter | Interactive NES/GBC tile palette, building stamper, spawn tool, and grid canvas |
exploration | exploration.topdown_buildings | Building footprints, roof styles, and linked walk-in doorway VN triggers |
exploration | exploration.hub_entities | Interactive Hub Entities CRUD editor (NPCs, walk-in door triggers, visuals, conditions, 5-kind interaction) |
exploration | exploration.hub_obstacles | Hub collision obstacle rectangles CRUD editor |
exploration | exploration.minigames | Mini Scenes list & Godot launch actions |
campaign | campaign.settings | Campaign rules (affinityMode, deathMode, onPlayerDefeat, stats, synergies, theme, chapters) |
campaign | campaign.flow_map | Visual Macro Chapter Flow Map canvas showing prologue, chapters, steps, routes, and endings |
campaign | campaign.chapter_inspector | Selected chapter Step Stack, completion criteria, conditional transitions, and POV switch rules |
campaign | campaign.pov_matrix | Multi-POV x NPC social coverage grid with 3-meeting scaffolding |
campaign | campaign.balance_linter | Reachability and Balance Linter report |
saves | saves.list | Saved snapshots grid (saves/) |
git | git.status_bar | Git branch, remote, ahead/behind, and dirty badges |
git | git.commit_box | Git commit message input, pull, commit, and push controls |
Dynamic Prefix Targets (8)
| Pattern | Auto-Navigation Behavior |
|---|
node:<nodeId> | Switches to story tab, selects owner script + node, centers graph canvas, cuts out exact node card |
node:<scriptId>/<nodeId> | Same as above targeting an explicit scriptId |
script:<scriptId> | Switches to story tab, selects script, highlights story.outliner |
character:<charId> | Switches to characters tab, selects character, highlights characters.inspector |
asset:<assetKey> | Switches to artist tab, clears filters, focuses assetKey card or artist.grid |
hub:<hubId> | Switches to exploration tab, selects hub, highlights exploration.hub_list |
minigame:<minigameId> | Switches to exploration tab and highlights exploration.minigames |
snapshot:<filename> | Switches to saves tab and highlights saves.list |
8. Four Copy-Paste LLM Workflow Playbooks
Playbook 1: Bootstrap and Validate a Brand-New Game Project
[
{"tool": "sme_create_project", "args": {"filePath": "D:/Games/LanternHarbor/lantern-harbor.sme", "name": "Lantern Harbor", "companionName": "Rowan"}},
{"tool": "sme_upsert_character", "args": {"characterId": "harbor_keeper", "character": {"id": "harbor_keeper", "name": "Morgan", "role": "Harbor Master", "playable": false, "defaultVariant": "coat", "variants": {"coat": {"id": "coat", "displayName": "Storm Coat", "representations": {"vn_portrait": {"mediaType": "2d_static", "expressions": ["neutral", "stern"]}}}}}}},
{"tool": "sme_upsert_dialogue_node", "args": {"scriptId": "opening_scene", "nodeId": "harbor_greeting", "node": {"type": "line", "speaker": {"characterId": "harbor_keeper", "expression": "neutral", "position": "right"}, "listener": {"characterId": "companion", "expression": "neutral", "position": "left"}, "text": "The tide brings strange cargo tonight.", "next": "start_town"}}},
{"tool": "sme_rewire_dialogue_edge", "args": {"scriptId": "opening_scene", "fromNodeId": "after_game", "toNodeId": "harbor_greeting", "port": "next"}},
{"tool": "sme_validate_and_lint", "args": {"matrixChapter": 1}}
]
Playbook 2: Artist Co-Pilot Visual Check and Interactive Spotlight Tour
- Call
sme_get_art_manifest with { "status": "missing" } to find missing backgrounds, portraits, or audio cues. - Call
sme_upload_asset with a local file (sourceFilePath) or SVG/PNG base64Data. - Call
studio_stage_artist_preview to compose speaker + dimmed listener + backdrop + dialogue copy at 16:9 without touching story scripts. - Call
studio_capture_visual_preview with { "target": "stage_preview" } and inspect the returned PNG image for portrait cropping, contrast, or spacing. - Call
studio_spotlight_tour to walk the artist interactively through fixing pitch/color settings or inspecting background inheritance:
{
"name": "studio_spotlight_tour",
"arguments": {
"steps": [
{
"target": "exploration.camera_pitch",
"title": "Adjust 2.5D Isometric Pitch",
"message": "Edit the camera tilt angle between 5 and 85 degrees directly through this cutout.",
"interactive": true,
"placement": "right"
},
{
"target": "artist.stage_preview",
"title": "Verify 16:9 Stage Composition",
"message": "Review character portraits, speaker label, and background art together at 16:9.",
"stagePreview": {
"characterId": "companion",
"expression": "neutral",
"speakerLabel": "COMPANION CHECK",
"dialogueText": "Lighting and crop verified at 16:9."
}
}
]
}
}
Playbook 3: Create a Social Scene and Test Mid-Game with Boosts in Godot
- Call
sme_create_social_scene with { "chapter": 1, "povId": "player", "npcId": "companion", "openingLine": "Before the investigation begins, let us compare notes." }. - Call
sme_save_snapshot with { "name": "ch1_social_boosted", "chapter": 1, "phase": "social", "povId": "player", "scriptId": "player_talks_to_companion_ch1", "statBonus": 3, "affinityBonus": 5, "learnAllKnowledge": true }. - Call
sme_launch_godot with { "snapshotFilename": "ch1_social_boosted.json", "writeOnly": true } (or omit writeOnly to spawn the Godot 4.7 window directly).
Playbook 4: Safe Dirty-State Editing Pattern
- Before calling any
sme_* disk write while a user is actively editing in Studio, call studio_get_ui_state. - If
isDirty === true, call studio_save_project (with the user's consent) OR inform the user before making disk changes. Never call studio_reload_project with force: true unless intentionally discarding unsaved UI edits.
9. Troubleshooting and Automated Parity Policy
Common Errors and Fixes
Tool "studio_*" requires a running Story Mode Engine window: Open Story Mode Engine (or run npm run dev with studio.html open in a browser), confirm the MCP status pill is green, then retry.HTTP 403 Forbidden non-loopback Host/Origin: Ensure requests target http://127.0.0.1:<port>/mcp with Host: 127.0.0.1:<port> (or localhost:<port>) and zero cross-origin non-loopback Origin headers.Story Mode Engine has unsaved changes on studio_open_project / studio_reload_project: Call studio_save_project first or pass force: true only when discarding unsaved changes is intended.- Spotlight says target is
not currently rendered/visible: Dynamic cards like story.inspector_bg_card require selecting a dialogue line/choice/transition node (studio_navigate({ nodeId })), and artist.reset_stage_btn is only visible while studio_stage_artist_preview override is active. Cross-file validation failed before write: Fix missing characterId, environmentId, scriptId, hubId, minigameId, or broken outgoing node references reported in details.errors. On sme_delete_entity or sme_delete_minigame, rewire or delete referring nodes/chapters before removing the target entity.
Contributor MCP-First Parity Enforcement
Every PR in Story Mode Engine is verified by node scripts/check.mjs, whose checkMcpParityAndDocs() audit asserts:
- Exact parity across
src/mcp/ and studio-avalonia/src/StoryModeEngine.Core/Mcp/ for all tool names (74), sme:// resources (10 static + 2 templates), prompts (4), and static UI target IDs (61). - Complete coverage of every Avalonia
[RelayCommand] and every web /api/studio/* endpoint inside src/mcp/capability-manifest.json. - Every tool, resource URI, template URI, prompt, and static UI target ID is documented in
docs/MCP.md, and docs/MCP.md + schemas/*.schema.json are bundled in both StoryModeEngine.Studio.csproj and StoryModeEngine.Mcp.csproj.