Skip to main content

MCP server for playing Glulx interactive fiction games

Project description

mcp-server-if

An MCP (Model Context Protocol) server for playing Glulx interactive fiction games. Enables AI assistants like Claude to play text adventure games through a standardized interface.

Features

  • Play Glulx (.ulx) and Blorb (.gblorb) interactive fiction 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 glulxe interpreter (no manual compilation required)

Installation

# Using uvx (recommended)
uvx mcp-server-if

# Or install with pip
pip install mcp-server-if

The package includes a pre-compiled glulxe binary. 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_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

  • .ulx - Raw Glulx game files
  • .gblorb - Blorb containers with Glulx games (may include graphics/sound)

Find games at the IF Archive.

Journaling Mode

Enable with --require-journal or IF_REQUIRE_JOURNAL=true. In this mode:

  1. After playing your first command, subsequent turns require a journal entry
  2. Journal entries must be at least 100 words
  3. Entries are saved to {game}/journal.jsonl
  4. Use read_journal and search_journal to review your playthrough

This encourages thoughtful, reflective gameplay rather than rushing through.

How It Works

  1. Games are stored in ~/.mcp-server-if/games/{name}/

  2. Each game directory contains:

    • game.ulx or game.gblorb - the game file
    • state/ - autosave data (persists between sessions)
    • metadata.json - session metadata
    • journal.jsonl - playthrough journal (if enabled)
  3. The server uses glulxe's RemGlk mode for JSON-based I/O

  4. Game state is automatically saved after each turn

Building from Source

If installing from source (not from PyPI), glulxe will be compiled during installation. This requires:

  • C compiler (gcc or clang)
  • make
  • git (for submodules)
git clone --recursive https://github.com/davidar/mcp-server-if.git
cd mcp-server-if
pip install .

Troubleshooting

"glulxe binary not found"

This shouldn't happen with pip/uvx installs. If it does:

  • Try reinstalling: pip install --force-reinstall mcp-server-if
  • Or set IF_GLULXE_PATH to 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

  • glulxe - The Glulx VM interpreter by Andrew Plotkin
  • RemGlk - Remote Glk library for JSON I/O
  • MCP - Model Context Protocol by Anthropic

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_server_if-0.1.0.tar.gz (261.6 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

mcp_server_if-0.1.0-py3-none-win_amd64.whl (306.1 kB view details)

Uploaded Python 3Windows x86-64

mcp_server_if-0.1.0-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (253.5 kB view details)

Uploaded Python 3manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

mcp_server_if-0.1.0-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (247.5 kB view details)

Uploaded Python 3manylinux: glibc 2.27+ ARM64manylinux: glibc 2.28+ ARM64

mcp_server_if-0.1.0-py3-none-macosx_13_0_x86_64.whl (170.2 kB view details)

Uploaded Python 3macOS 13.0+ x86-64

mcp_server_if-0.1.0-py3-none-macosx_13_0_arm64.whl (173.5 kB view details)

Uploaded Python 3macOS 13.0+ ARM64

File details

Details for the file mcp_server_if-0.1.0.tar.gz.

File metadata

  • Download URL: mcp_server_if-0.1.0.tar.gz
  • Upload date:
  • Size: 261.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mcp_server_if-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d10dd6e82bba658d74221255dbb6c507c3eb3899e4ebe4746355ef014b8cbb77
MD5 3d2d8f562a66c95eaae1f4d70b0c886f
BLAKE2b-256 da355f719d3c85c9f5517145a340dde6e05cb8bf1ac70798a5b03973622d1036

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_server_if-0.1.0.tar.gz:

Publisher: publish.yml on davidar/mcp-server-if

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mcp_server_if-0.1.0-py3-none-win_amd64.whl.

File metadata

  • Download URL: mcp_server_if-0.1.0-py3-none-win_amd64.whl
  • Upload date:
  • Size: 306.1 kB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mcp_server_if-0.1.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 2c1bf7e5559272b44aece17e7e7d0fb309612460838218d93e455657421a9244
MD5 29be6f4a49a5159d123c741ff5deaba1
BLAKE2b-256 df5858533c62a5372a73fe4fa90372b43451c63586d7e229e3cce51e610cc3bd

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_server_if-0.1.0-py3-none-win_amd64.whl:

Publisher: publish.yml on davidar/mcp-server-if

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mcp_server_if-0.1.0-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for mcp_server_if-0.1.0-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 dec8b8bbcf64a58e5ddc2c6f25569dfd142f57fe1834c41d82dc81d2bdf529b6
MD5 75b7c5e7210dd276f7848a3246ae8896
BLAKE2b-256 dcbe5b63a94625f188923bd30047af876a41e403abc087e77d4c161e527cc90e

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_server_if-0.1.0-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: publish.yml on davidar/mcp-server-if

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mcp_server_if-0.1.0-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for mcp_server_if-0.1.0-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 8d3c32d0dec4e4926029fec40fc53818e0b474278e89dcd2deb276c3bc510abf
MD5 434add3338fb6707af4309b6ac50d34d
BLAKE2b-256 96e04b96bdea88d7d47db1396b953034b955faa2b6240aedb28af12b4c732797

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_server_if-0.1.0-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl:

Publisher: publish.yml on davidar/mcp-server-if

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mcp_server_if-0.1.0-py3-none-macosx_13_0_x86_64.whl.

File metadata

File hashes

Hashes for mcp_server_if-0.1.0-py3-none-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 ef10571d61109dcd5c88ef67dd6d4582f87ef610fdbc29ab2939a51c99684bdf
MD5 4f94807397b97ce9e1ca0258a975f0d0
BLAKE2b-256 82f2160d13c078f37fcd7519ff3043cf4d8281699dd57c1511e9168b718d96ae

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_server_if-0.1.0-py3-none-macosx_13_0_x86_64.whl:

Publisher: publish.yml on davidar/mcp-server-if

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mcp_server_if-0.1.0-py3-none-macosx_13_0_arm64.whl.

File metadata

File hashes

Hashes for mcp_server_if-0.1.0-py3-none-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 9fdb05e7c84405a12f82df14750d5890c4282d5cc48742e1e468d3bad040b131
MD5 cf468c532b497a2e51a839ddaf828e71
BLAKE2b-256 b7b5bf0c0dcb981e51cded61b2776b108ec01ce252dd89882c75079611b44859

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_server_if-0.1.0-py3-none-macosx_13_0_arm64.whl:

Publisher: publish.yml on davidar/mcp-server-if

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page