twine-mcp
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@twine-mcpList my stories"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
twine-mcp
A locally-run MCP server for Twine interactive story authoring.
Connects to Twine's story library on the file system and exposes tools for story management, passage CRUD, link-graph analysis, plot consistency checking, and AI-optimized narrative intelligence — all callable from Cursor, Claude Desktop, or any MCP-compatible AI client.
Quick start
# Option A: zero-install
npx twine-mcp
# Option B: global install
npm install -g twine-mcp
twine-mcp
# Custom library path
TWINE_LIBRARY="C:/Users/you/Documents/Twine/Stories" npx twine-mcpThe server auto-discovers your Twine story library from:
TWINE_LIBRARYenvironment variableElectron
app-prefs.json(readsstoryLibraryFolderPath)OS default:
~/Documents/Twine/Stories
Related MCP server: nexus-mcp
Cursor setup
Add to your .cursor/mcp.json (or user-level MCP config):
{
"mcpServers": {
"twine": {
"command": "npx",
"args": ["twine-mcp"],
"env": {
"TWINE_LIBRARY": "C:/Users/yourname/Documents/Twine/Stories"
}
}
}
}Claude Desktop setup
Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
{
"mcpServers": {
"twine": {
"command": "npx",
"args": ["twine-mcp"]
}
}
}Companion format (optional)
The companion format adds a toolbar button to the Twine passage editor showing MCP status and setup instructions.
Install:
Open Twine → Story Formats → Add a New Format
Enter the path to
src/companion-format/format.jsas afile://URL:Windows:
file:///C:/Users/you/Documents/Unveil/twine-mcp/twine-mcp/src/companion-format/format.jsmacOS/Linux:
file:///home/you/.../twine-mcp/src/companion-format/format.js
Set it as a proofing format on any story to see the MCP indicator
Tool reference
Recommended AI workflow (cheapest → richest)
1. ping health check, confirm connection
2. summarize_story ~200 tokens, orient to story structure
3. get_story_context configurable bundle with issues list
4. get_story_branches decision tree overview
5. get_narrative_flow full prose in DFS order
6. get_passage_context deep dive on a specific passage
7. get_all_endings audit every ending pathStory management
Tool | Description |
| List all stories with metadata. Supports |
| Full story data. Toggle |
| Create new story file with a Start passage. |
| Delete a story file permanently. |
| Export as Twee 3 source text. |
| Produce a proofing HTML file at a given output path. |
Passage CRUD
Tool | Description |
| All passages with name, tags, word count. |
| Full content + tags + outgoing links. |
| Add a new passage with optional content, tags, position. |
| Edit text, tags, or editor position. |
| Remove a passage. |
| Rename + rewrite all |
| Change the story starting passage. |
Graph & navigation
Tool | Description |
| Full adjacency list or compact counts. |
| Links to non-existent passages. |
| Passages with no outgoing links (not tagged |
| Passages no other passage links to. |
| Circular link paths. |
| Shortest path between two passages (BFS). |
| All passages reachable from start + unreachable list. |
Story analysis
Tool | Description |
| Comprehensive report: broken links, dead ends, orphans, cycles, stats. |
| Word count, reading time, tag usage, branch stats. |
| Full-text + tag search across all passages. |
| Format-aware variable set/read tracking (Harlowe, SugarCube, Chapbook). |
| Rare tags, high-tag passages, untagged passage count. |
Narrative intelligence (AI-optimized)
Tool | Description |
| Cheapest orientation call. ~500 tokens max. |
| Configurable bundle. Supports |
| Prose in DFS order. Supports |
| All terminal passages + upstream paths. |
| Upstream paths + content + outgoing for one passage. |
| Branch points with sub-tree reachability counts. |
Story format awareness
Tool | Description |
| Built-in + user-installed formats. |
| Description, docs URL, and usage in library. |
| Concise syntax reference for Harlowe, SugarCube, Chapbook, Snowman. |
Utility
Tool | Description |
| Health check + library path + story count. |
| Server config. |
| Atomic multi-passage edit in one save. |
MCP Resources
URI | Description |
| Story index |
| Full story data |
| Passage link graph |
| Compact narrative snapshot |
Token efficiency conventions
Every tool follows these conventions to minimize token cost:
fields— select which properties to return (e.g.["name","tags"])compact: true— passage lists return name + 80-char preview onlymax_depth/max_passages— bound traversal outputPassage text is never included in list/graph tools by default
get_story_context(fields=["meta","issues"], compact=true)≈ 200 tokens
How it works
twine-mcp watches ~/Documents/Twine/Stories/*.html with chokidar. Files are parsed using extwee. Writes splice updated <tw-storydata> back into the original HTML — preserving the embedded story format. TwineJS detects file changes on focus and reloads automatically.
Twine has no plugin API or HTTP server — this server operates entirely through the file system. The companion story format adds a cosmetic toolbar button but cannot perform deeper integration.
Development
git clone <repo>
cd twine-mcp
npm install
npm run build # compile TypeScript
npm start # run server
npm test # run tests (vitest)Scope & limitations
Desktop/Electron Twine only (v1 — web/PWA localStorage not supported)
Passage text is treated as opaque source (macros/widgets are not executed)
Format conversion (Harlowe → SugarCube) is guidance only, not automated
compile_storyproduces a proofing HTML; fully playable output requires a story format bundle
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Unveil-gg/TwineMCP'
If you have feedback or need assistance with the MCP directory API, please join our Discord server