MCP server for playing interactive fiction games (Glulx and Z-machine)
Project description
mcp-server-if
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcp_server_if-0.2.0.tar.gz.
File metadata
- Download URL: mcp_server_if-0.2.0.tar.gz
- Upload date:
- Size: 11.9 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1de3555526b7410acb42694d855a3d6770998ff761a2b11639231640b02593df
|
|
| MD5 |
db9301fa9e44d7578adc9fef4aad8613
|
|
| BLAKE2b-256 |
80ba485b9ca5adfbf64648ed06fc80c243143a13c4206a8d310d4bb7ed898276
|
Provenance
The following attestation bundles were made for mcp_server_if-0.2.0.tar.gz:
Publisher:
publish.yml on davidar/mcp-server-if
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mcp_server_if-0.2.0.tar.gz -
Subject digest:
1de3555526b7410acb42694d855a3d6770998ff761a2b11639231640b02593df - Sigstore transparency entry: 907871784
- Sigstore integration time:
-
Permalink:
davidar/mcp-server-if@b72341ec727e1d525cbf46e14ae3eea5a2396d6c -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/davidar
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b72341ec727e1d525cbf46e14ae3eea5a2396d6c -
Trigger Event:
release
-
Statement type:
File details
Details for the file mcp_server_if-0.2.0-py3-none-win_amd64.whl.
File metadata
- Download URL: mcp_server_if-0.2.0-py3-none-win_amd64.whl
- Upload date:
- Size: 1.5 MB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2a41d82f35eb13891bfa54986b0e67893ddcb96be03ac927901d286992f1568
|
|
| MD5 |
7d9e61916efac72da93b387c0e0f6cd6
|
|
| BLAKE2b-256 |
6e0f8ac011d332c4ef62bcfa32883bb1e386b5dcb7c0e7891846fdd2778167da
|
Provenance
The following attestation bundles were made for mcp_server_if-0.2.0-py3-none-win_amd64.whl:
Publisher:
publish.yml on davidar/mcp-server-if
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mcp_server_if-0.2.0-py3-none-win_amd64.whl -
Subject digest:
d2a41d82f35eb13891bfa54986b0e67893ddcb96be03ac927901d286992f1568 - Sigstore transparency entry: 907871791
- Sigstore integration time:
-
Permalink:
davidar/mcp-server-if@b72341ec727e1d525cbf46e14ae3eea5a2396d6c -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/davidar
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b72341ec727e1d525cbf46e14ae3eea5a2396d6c -
Trigger Event:
release
-
Statement type:
File details
Details for the file mcp_server_if-0.2.0-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: mcp_server_if-0.2.0-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 682.9 kB
- Tags: Python 3, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
16be86f269d2d6b8a19f9b2e658d663e056a22a52b1629dec2e8faf29f20de19
|
|
| MD5 |
dfae6e75efd687c1ca697b025b81ed78
|
|
| BLAKE2b-256 |
a795d6cb55c4d156e5ff17ab2da5571db1ee9488ddc0e1bd44cc770f960862e9
|
Provenance
The following attestation bundles were made for mcp_server_if-0.2.0-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:
Publisher:
publish.yml on davidar/mcp-server-if
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mcp_server_if-0.2.0-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
16be86f269d2d6b8a19f9b2e658d663e056a22a52b1629dec2e8faf29f20de19 - Sigstore transparency entry: 907871792
- Sigstore integration time:
-
Permalink:
davidar/mcp-server-if@b72341ec727e1d525cbf46e14ae3eea5a2396d6c -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/davidar
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b72341ec727e1d525cbf46e14ae3eea5a2396d6c -
Trigger Event:
release
-
Statement type:
File details
Details for the file mcp_server_if-0.2.0-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.
File metadata
- Download URL: mcp_server_if-0.2.0-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 660.5 kB
- Tags: Python 3, manylinux: glibc 2.27+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b96dda55b7449a4aa576c19ae6a6dcda43c6de8fb0524369fd5853a28af96725
|
|
| MD5 |
a9bb7ff573cb24a0012b64ed9be83f84
|
|
| BLAKE2b-256 |
c85effb67dd15956510f1572f0e854bdc3d5d077abb1cb680f6ba8f83c3630ff
|
Provenance
The following attestation bundles were made for mcp_server_if-0.2.0-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl:
Publisher:
publish.yml on davidar/mcp-server-if
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mcp_server_if-0.2.0-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl -
Subject digest:
b96dda55b7449a4aa576c19ae6a6dcda43c6de8fb0524369fd5853a28af96725 - Sigstore transparency entry: 907871794
- Sigstore integration time:
-
Permalink:
davidar/mcp-server-if@b72341ec727e1d525cbf46e14ae3eea5a2396d6c -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/davidar
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b72341ec727e1d525cbf46e14ae3eea5a2396d6c -
Trigger Event:
release
-
Statement type:
File details
Details for the file mcp_server_if-0.2.0-py3-none-macosx_13_0_x86_64.whl.
File metadata
- Download URL: mcp_server_if-0.2.0-py3-none-macosx_13_0_x86_64.whl
- Upload date:
- Size: 505.7 kB
- Tags: Python 3, macOS 13.0+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd06fc95b8d6f18684540c6bbbe4643a03d7034aaab5469270c2b60dde5007d2
|
|
| MD5 |
e7f0b6b4a06a1b294d5ce0e55e664089
|
|
| BLAKE2b-256 |
676562f680711578fc325f222c47410ca461fd43676bae281706fa4578c1a17e
|
Provenance
The following attestation bundles were made for mcp_server_if-0.2.0-py3-none-macosx_13_0_x86_64.whl:
Publisher:
publish.yml on davidar/mcp-server-if
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mcp_server_if-0.2.0-py3-none-macosx_13_0_x86_64.whl -
Subject digest:
cd06fc95b8d6f18684540c6bbbe4643a03d7034aaab5469270c2b60dde5007d2 - Sigstore transparency entry: 907871788
- Sigstore integration time:
-
Permalink:
davidar/mcp-server-if@b72341ec727e1d525cbf46e14ae3eea5a2396d6c -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/davidar
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b72341ec727e1d525cbf46e14ae3eea5a2396d6c -
Trigger Event:
release
-
Statement type:
File details
Details for the file mcp_server_if-0.2.0-py3-none-macosx_13_0_arm64.whl.
File metadata
- Download URL: mcp_server_if-0.2.0-py3-none-macosx_13_0_arm64.whl
- Upload date:
- Size: 505.8 kB
- Tags: Python 3, macOS 13.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0223f9e2b73b0f72690ec5bdd4fa5f6b88dd41763f3821445ede8830939aec51
|
|
| MD5 |
d10ad8abdb8a047383f8a29cdddb1e8c
|
|
| BLAKE2b-256 |
597a488de80a78b178daec1be3a31747de26e48470ca5048ddd7f499bbe87e07
|
Provenance
The following attestation bundles were made for mcp_server_if-0.2.0-py3-none-macosx_13_0_arm64.whl:
Publisher:
publish.yml on davidar/mcp-server-if
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mcp_server_if-0.2.0-py3-none-macosx_13_0_arm64.whl -
Subject digest:
0223f9e2b73b0f72690ec5bdd4fa5f6b88dd41763f3821445ede8830939aec51 - Sigstore transparency entry: 907871789
- Sigstore integration time:
-
Permalink:
davidar/mcp-server-if@b72341ec727e1d525cbf46e14ae3eea5a2396d6c -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/davidar
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b72341ec727e1d525cbf46e14ae3eea5a2396d6c -
Trigger Event:
release
-
Statement type: