Server If
FreeNot checkedEnables AI assistants to play interactive fiction games (Glulx and Z-machine) through the Model Context Protocol, with automatic save/restore and optional journ
About
Enables AI assistants to play interactive fiction games (Glulx and Z-machine) through the Model Context Protocol, with automatic save/restore and optional journaling mode.
README
An MCP (Model Context Protocol) server for playing interactive fiction games. Enables AI assistants like Claude to play text adventure games through a standardized interface.
Features
- Play Glulx (.ulx, .gblorb) and Z-machine (.z3-.z8, .zblorb) games
- Automatic game state persistence (save/restore between sessions)
- Download games directly from the IF Archive
- Optional journaling mode for reflective playthroughs
- Works with Claude Desktop, Claude Code, and other MCP clients
- Bundled interpreters (glulxe for Glulx, bocfel for Z-machine)
Installation
# Using uvx (recommended)
uvx mcp-server-if
# Or install with pip
pip install mcp-server-if
The package includes pre-compiled interpreters. No additional setup required.
Configuration
Environment Variables
| Variable | Description | Default |
|---|---|---|
IF_GAMES_DIR |
Directory to store games | ~/.mcp-server-if/games |
IF_GLULXE_PATH |
Override path to glulxe binary | Bundled binary |
IF_BOCFEL_PATH |
Override path to bocfel binary | Bundled binary |
IF_REQUIRE_JOURNAL |
Require journal reflections | false |
Command Line Arguments
mcp-server-if --help
Options:
--games-dir PATH Directory to store games
--glulxe-path PATH Path to glulxe binary (overrides bundled)
--require-journal Require journal reflections between turns
Usage with Claude Desktop
Add to your Claude Desktop configuration (~/Library/Application Support/Claude/claude_desktop_config.json on macOS or %APPDATA%\Claude\claude_desktop_config.json on Windows):
{
"mcpServers": {
"interactive-fiction": {
"command": "uvx",
"args": ["mcp-server-if"]
}
}
}
Usage with Claude Code
claude mcp add interactive-fiction -- uvx mcp-server-if
Available Tools
play_if
Play a turn of interactive fiction.
play_if(game="zork", command="go north")
play_if(game="zork", command="", journal="...reflection...") # with journaling
list_games
List available games and their save state status.
download_game
Download a game from the IF Archive or any URL.
download_game(name="advent", url="advent.ulx")
download_game(name="bronze", url="https://example.com/Bronze.gblorb")
reset_game
Reset a game to start fresh (clears save state, preserves journal).
read_journal
Read the playthrough journal for a game.
read_journal(game="zork", recent=10) # last 10 entries
search_journal
Search journal entries by keyword.
search_journal(game="zork", query="treasure")
Supported Game Formats
Glulx (modern, uses glulxe interpreter):
.ulx- Raw Glulx game files.gblorb- Blorb containers with Glulx games
Z-machine (classic Infocom format, uses bocfel interpreter):
.z3,.z4,.z5,.z7,.z8- Z-code game files.zblorb- Blorb containers with Z-machine games
Find games at the IF Archive: Glulx games, Z-code games.
Journaling Mode
Enable with --require-journal or IF_REQUIRE_JOURNAL=true. In this mode:
- After playing your first command, subsequent turns require a journal entry
- Journal entries must be at least 100 words
- Entries are saved to
{game}/journal.jsonl - Use
read_journalandsearch_journalto review your playthrough
This encourages thoughtful, reflective gameplay rather than rushing through.
How It Works
Games are stored in
~/.mcp-server-if/games/{name}/Each game directory contains:
- The game file (
.ulx,.gblorb,.z5, etc.) state/- autosave data (persists between sessions)metadata.json- session metadatajournal.jsonl- playthrough journal (if enabled)
- The game file (
The server selects the appropriate interpreter based on file format:
- Glulx games → glulxe
- Z-machine games → bocfel
Both interpreters use RemGlk for JSON-based I/O
Game state is automatically saved after each turn
Development
Requires uv, a C compiler (gcc or clang), a C++ compiler (g++ or clang++), make, and git.
git clone --recursive https://github.com/davidar/mcp-server-if.git
cd mcp-server-if
uv sync --group dev
uv run pytest -v
uv sync compiles the bundled interpreters (glulxe and bocfel) from source automatically. If binaries are missing after a fresh clone, run uv sync --reinstall-package mcp-server-if to force recompilation.
Troubleshooting
"glulxe binary not found"
This shouldn't happen with pip/uvx installs. If it does:
- Try reinstalling:
pip install --force-reinstall mcp-server-iforuv sync --reinstall-package mcp-server-if - Or set
IF_GLULXE_PATHto a manually installed glulxe
"Game file not found"
Use list_games to see available games, or download_game to get new ones.
Save/restore commands don't work
In-game save/restore triggers file dialogs that aren't supported. Use the automatic autosave system instead - your game state persists between sessions automatically.
License
MIT License - see LICENSE for details.
Credits
Install Server If in Claude Desktop, Claude Code & Cursor
unyly install mcp-server-ifInstalls into Claude Desktop, Claude Code, Cursor & VS Code — handles npx, uvx and build-from-source repos for you.
First time? Get the CLI: curl -fsSL https://unyly.org/install | sh
Or configure manually
Run in your terminal:
claude mcp add mcp-server-if -- uvx mcp-server-ifFAQ
Is Server If MCP free?
Yes, Server If MCP is free — one-click install via Unyly at no cost.
Does Server If need an API key?
No, Server If runs without API keys or environment variables.
Is Server If hosted or self-hosted?
Self-hosted: the server runs locally on your machine via the install command above.
How do I install Server If in Claude Desktop, Claude Code or Cursor?
Open Server If on unyly.org, pick your client tab (Claude Desktop, Claude Code, Cursor) and press Install — the config is generated automatically, no JSON editing.
Related MCPs
Fetch
Web content fetching and conversion for efficient LLM usage.
AWS KB Retrieval
Retrieval from AWS Knowledge Base using Bedrock Agent Runtime.
by modelcontextprotocolSpring AI MCP Server
Provides auto-configuration for setting up an MCP server in Spring Boot applications.
llm-analysis-assistant
A very streamlined mcp client that supports calling and monitoring stdio/sse/streamableHttp, and can also view request responses through the /logs page. It also
by xuzexin-hzCompare Server If with
Not sure what to pick?
Find your stack in 60 seconds
Author?
Embed badge for your README
Browse similar
All ai MCPs
