mcp-server-if 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mcp_server_if-0.1.0/.gitignore +44 -0
- mcp_server_if-0.1.0/LICENSE +21 -0
- mcp_server_if-0.1.0/PKG-INFO +199 -0
- mcp_server_if-0.1.0/README.md +174 -0
- mcp_server_if-0.1.0/deps/glulxe/.git +1 -0
- mcp_server_if-0.1.0/deps/glulxe/.gitignore +2 -0
- mcp_server_if-0.1.0/deps/glulxe/LICENSE +21 -0
- mcp_server_if-0.1.0/deps/glulxe/Makefile +75 -0
- mcp_server_if-0.1.0/deps/glulxe/README.md +299 -0
- mcp_server_if-0.1.0/deps/glulxe/accel.c +692 -0
- mcp_server_if-0.1.0/deps/glulxe/debugger.c +1770 -0
- mcp_server_if-0.1.0/deps/glulxe/exec.c +1373 -0
- mcp_server_if-0.1.0/deps/glulxe/files.c +89 -0
- mcp_server_if-0.1.0/deps/glulxe/float.c +300 -0
- mcp_server_if-0.1.0/deps/glulxe/funcs.c +312 -0
- mcp_server_if-0.1.0/deps/glulxe/gestalt.c +97 -0
- mcp_server_if-0.1.0/deps/glulxe/gestalt.h +25 -0
- mcp_server_if-0.1.0/deps/glulxe/glkop.c +1526 -0
- mcp_server_if-0.1.0/deps/glulxe/glulxdump.c +974 -0
- mcp_server_if-0.1.0/deps/glulxe/glulxe.h +409 -0
- mcp_server_if-0.1.0/deps/glulxe/heap.c +481 -0
- mcp_server_if-0.1.0/deps/glulxe/iosstart.h +54 -0
- mcp_server_if-0.1.0/deps/glulxe/iosstart.m +660 -0
- mcp_server_if-0.1.0/deps/glulxe/macstart.c +74 -0
- mcp_server_if-0.1.0/deps/glulxe/main.c +212 -0
- mcp_server_if-0.1.0/deps/glulxe/opcodes.h +177 -0
- mcp_server_if-0.1.0/deps/glulxe/operand.c +693 -0
- mcp_server_if-0.1.0/deps/glulxe/osdepend.c +373 -0
- mcp_server_if-0.1.0/deps/glulxe/profile-analyze.py +1157 -0
- mcp_server_if-0.1.0/deps/glulxe/profile.c +454 -0
- mcp_server_if-0.1.0/deps/glulxe/search.c +266 -0
- mcp_server_if-0.1.0/deps/glulxe/serial.c +1373 -0
- mcp_server_if-0.1.0/deps/glulxe/string.c +893 -0
- mcp_server_if-0.1.0/deps/glulxe/unixautosave.c +808 -0
- mcp_server_if-0.1.0/deps/glulxe/unixstrt.c +325 -0
- mcp_server_if-0.1.0/deps/glulxe/unixstrt.h +14 -0
- mcp_server_if-0.1.0/deps/glulxe/vm.c +415 -0
- mcp_server_if-0.1.0/deps/remglk/.git +1 -0
- mcp_server_if-0.1.0/deps/remglk/.gitignore +3 -0
- mcp_server_if-0.1.0/deps/remglk/LICENSE +21 -0
- mcp_server_if-0.1.0/deps/remglk/Makefile +46 -0
- mcp_server_if-0.1.0/deps/remglk/README.txt +33 -0
- mcp_server_if-0.1.0/deps/remglk/cgdate.c +280 -0
- mcp_server_if-0.1.0/deps/remglk/cgunicod.c +567 -0
- mcp_server_if-0.1.0/deps/remglk/cgunigen.c +12194 -0
- mcp_server_if-0.1.0/deps/remglk/docs.html +401 -0
- mcp_server_if-0.1.0/deps/remglk/gi_blorb.c +770 -0
- mcp_server_if-0.1.0/deps/remglk/gi_blorb.h +99 -0
- mcp_server_if-0.1.0/deps/remglk/gi_debug.c +48 -0
- mcp_server_if-0.1.0/deps/remglk/gi_debug.h +196 -0
- mcp_server_if-0.1.0/deps/remglk/gi_dispa.c +1568 -0
- mcp_server_if-0.1.0/deps/remglk/gi_dispa.h +111 -0
- mcp_server_if-0.1.0/deps/remglk/glk.h +469 -0
- mcp_server_if-0.1.0/deps/remglk/glkstart.c +24 -0
- mcp_server_if-0.1.0/deps/remglk/glkstart.h +115 -0
- mcp_server_if-0.1.0/deps/remglk/jsonvalidate.py +24 -0
- mcp_server_if-0.1.0/deps/remglk/main.c +612 -0
- mcp_server_if-0.1.0/deps/remglk/remglk.h +341 -0
- mcp_server_if-0.1.0/deps/remglk/rgauto.c +1104 -0
- mcp_server_if-0.1.0/deps/remglk/rgblorb.c +40 -0
- mcp_server_if-0.1.0/deps/remglk/rgdata.c +2700 -0
- mcp_server_if-0.1.0/deps/remglk/rgdata.h +277 -0
- mcp_server_if-0.1.0/deps/remglk/rgdata_int.h +55 -0
- mcp_server_if-0.1.0/deps/remglk/rgevent.c +437 -0
- mcp_server_if-0.1.0/deps/remglk/rgfref.c +554 -0
- mcp_server_if-0.1.0/deps/remglk/rggestal.c +136 -0
- mcp_server_if-0.1.0/deps/remglk/rgmisc.c +219 -0
- mcp_server_if-0.1.0/deps/remglk/rgschan.c +99 -0
- mcp_server_if-0.1.0/deps/remglk/rgstream.c +1952 -0
- mcp_server_if-0.1.0/deps/remglk/rgstyle.c +59 -0
- mcp_server_if-0.1.0/deps/remglk/rgwin_blank.c +36 -0
- mcp_server_if-0.1.0/deps/remglk/rgwin_blank.h +14 -0
- mcp_server_if-0.1.0/deps/remglk/rgwin_buf.c +621 -0
- mcp_server_if-0.1.0/deps/remglk/rgwin_buf.h +63 -0
- mcp_server_if-0.1.0/deps/remglk/rgwin_graph.c +203 -0
- mcp_server_if-0.1.0/deps/remglk/rgwin_graph.h +26 -0
- mcp_server_if-0.1.0/deps/remglk/rgwin_grid.c +500 -0
- mcp_server_if-0.1.0/deps/remglk/rgwin_grid.h +52 -0
- mcp_server_if-0.1.0/deps/remglk/rgwin_pair.c +182 -0
- mcp_server_if-0.1.0/deps/remglk/rgwin_pair.h +31 -0
- mcp_server_if-0.1.0/deps/remglk/rgwindow.c +1942 -0
- mcp_server_if-0.1.0/deps/win_compat.h +26 -0
- mcp_server_if-0.1.0/hatch_build.py +187 -0
- mcp_server_if-0.1.0/pyproject.toml +98 -0
- mcp_server_if-0.1.0/src/mcp_server_if/__init__.py +12 -0
- mcp_server_if-0.1.0/src/mcp_server_if/__main__.py +6 -0
- mcp_server_if-0.1.0/src/mcp_server_if/config.py +103 -0
- mcp_server_if-0.1.0/src/mcp_server_if/py.typed +0 -0
- mcp_server_if-0.1.0/src/mcp_server_if/server.py +412 -0
- mcp_server_if-0.1.0/src/mcp_server_if/session.py +299 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
.Python
|
|
7
|
+
build/
|
|
8
|
+
develop-eggs/
|
|
9
|
+
dist/
|
|
10
|
+
downloads/
|
|
11
|
+
eggs/
|
|
12
|
+
.eggs/
|
|
13
|
+
lib/
|
|
14
|
+
lib64/
|
|
15
|
+
parts/
|
|
16
|
+
sdist/
|
|
17
|
+
var/
|
|
18
|
+
wheels/
|
|
19
|
+
*.egg-info/
|
|
20
|
+
.installed.cfg
|
|
21
|
+
*.egg
|
|
22
|
+
|
|
23
|
+
# Virtual environments
|
|
24
|
+
.venv/
|
|
25
|
+
venv/
|
|
26
|
+
ENV/
|
|
27
|
+
|
|
28
|
+
# IDE
|
|
29
|
+
.idea/
|
|
30
|
+
.vscode/
|
|
31
|
+
*.swp
|
|
32
|
+
*.swo
|
|
33
|
+
|
|
34
|
+
# Build artifacts (but not deps/ - those are submodules)
|
|
35
|
+
src/mcp_server_if/bin/
|
|
36
|
+
|
|
37
|
+
# Testing
|
|
38
|
+
.pytest_cache/
|
|
39
|
+
.coverage
|
|
40
|
+
htmlcov/
|
|
41
|
+
|
|
42
|
+
# OS
|
|
43
|
+
.DS_Store
|
|
44
|
+
Thumbs.db
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 David A Roberts
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mcp-server-if
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: MCP server for playing Glulx interactive fiction games
|
|
5
|
+
Project-URL: Homepage, https://github.com/davidar/mcp-server-if
|
|
6
|
+
Project-URL: Repository, https://github.com/davidar/mcp-server-if
|
|
7
|
+
Project-URL: Issues, https://github.com/davidar/mcp-server-if/issues
|
|
8
|
+
Author-email: David A Roberts <d@vidr.cc>
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: claude,glulx,interactive-fiction,mcp,text-adventure
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Games/Entertainment :: Role-Playing
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Requires-Dist: httpx>=0.25.0
|
|
23
|
+
Requires-Dist: mcp>=1.0.0
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
# mcp-server-if
|
|
27
|
+
|
|
28
|
+
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.
|
|
29
|
+
|
|
30
|
+
## Features
|
|
31
|
+
|
|
32
|
+
- Play Glulx (.ulx) and Blorb (.gblorb) interactive fiction games
|
|
33
|
+
- Automatic game state persistence (save/restore between sessions)
|
|
34
|
+
- Download games directly from the IF Archive
|
|
35
|
+
- Optional journaling mode for reflective playthroughs
|
|
36
|
+
- Works with Claude Desktop, Claude Code, and other MCP clients
|
|
37
|
+
- Bundled glulxe interpreter (no manual compilation required)
|
|
38
|
+
|
|
39
|
+
## Installation
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# Using uvx (recommended)
|
|
43
|
+
uvx mcp-server-if
|
|
44
|
+
|
|
45
|
+
# Or install with pip
|
|
46
|
+
pip install mcp-server-if
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The package includes a pre-compiled `glulxe` binary. No additional setup required.
|
|
50
|
+
|
|
51
|
+
## Configuration
|
|
52
|
+
|
|
53
|
+
### Environment Variables
|
|
54
|
+
|
|
55
|
+
| Variable | Description | Default |
|
|
56
|
+
|----------|-------------|---------|
|
|
57
|
+
| `IF_GAMES_DIR` | Directory to store games | `~/.mcp-server-if/games` |
|
|
58
|
+
| `IF_GLULXE_PATH` | Override path to glulxe binary | Bundled binary |
|
|
59
|
+
| `IF_REQUIRE_JOURNAL` | Require journal reflections | `false` |
|
|
60
|
+
|
|
61
|
+
### Command Line Arguments
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
mcp-server-if --help
|
|
65
|
+
|
|
66
|
+
Options:
|
|
67
|
+
--games-dir PATH Directory to store games
|
|
68
|
+
--glulxe-path PATH Path to glulxe binary (overrides bundled)
|
|
69
|
+
--require-journal Require journal reflections between turns
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Usage with Claude Desktop
|
|
73
|
+
|
|
74
|
+
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):
|
|
75
|
+
|
|
76
|
+
```json
|
|
77
|
+
{
|
|
78
|
+
"mcpServers": {
|
|
79
|
+
"interactive-fiction": {
|
|
80
|
+
"command": "uvx",
|
|
81
|
+
"args": ["mcp-server-if"]
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Usage with Claude Code
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
claude mcp add interactive-fiction -- uvx mcp-server-if
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Available Tools
|
|
94
|
+
|
|
95
|
+
### `play_if`
|
|
96
|
+
Play a turn of interactive fiction.
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
play_if(game="zork", command="go north")
|
|
100
|
+
play_if(game="zork", command="", journal="...reflection...") # with journaling
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### `list_games`
|
|
104
|
+
List available games and their save state status.
|
|
105
|
+
|
|
106
|
+
### `download_game`
|
|
107
|
+
Download a game from the IF Archive or any URL.
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
download_game(name="advent", url="advent.ulx")
|
|
111
|
+
download_game(name="bronze", url="https://example.com/Bronze.gblorb")
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### `reset_game`
|
|
115
|
+
Reset a game to start fresh (clears save state, preserves journal).
|
|
116
|
+
|
|
117
|
+
### `read_journal`
|
|
118
|
+
Read the playthrough journal for a game.
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
read_journal(game="zork", recent=10) # last 10 entries
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### `search_journal`
|
|
125
|
+
Search journal entries by keyword.
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
search_journal(game="zork", query="treasure")
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Supported Game Formats
|
|
132
|
+
|
|
133
|
+
- `.ulx` - Raw Glulx game files
|
|
134
|
+
- `.gblorb` - Blorb containers with Glulx games (may include graphics/sound)
|
|
135
|
+
|
|
136
|
+
Find games at the [IF Archive](https://ifarchive.org/indexes/if-archive/games/glulx/).
|
|
137
|
+
|
|
138
|
+
## Journaling Mode
|
|
139
|
+
|
|
140
|
+
Enable with `--require-journal` or `IF_REQUIRE_JOURNAL=true`. In this mode:
|
|
141
|
+
|
|
142
|
+
1. After playing your first command, subsequent turns require a journal entry
|
|
143
|
+
2. Journal entries must be at least 100 words
|
|
144
|
+
3. Entries are saved to `{game}/journal.jsonl`
|
|
145
|
+
4. Use `read_journal` and `search_journal` to review your playthrough
|
|
146
|
+
|
|
147
|
+
This encourages thoughtful, reflective gameplay rather than rushing through.
|
|
148
|
+
|
|
149
|
+
## How It Works
|
|
150
|
+
|
|
151
|
+
1. Games are stored in `~/.mcp-server-if/games/{name}/`
|
|
152
|
+
2. Each game directory contains:
|
|
153
|
+
- `game.ulx` or `game.gblorb` - the game file
|
|
154
|
+
- `state/` - autosave data (persists between sessions)
|
|
155
|
+
- `metadata.json` - session metadata
|
|
156
|
+
- `journal.jsonl` - playthrough journal (if enabled)
|
|
157
|
+
|
|
158
|
+
3. The server uses glulxe's RemGlk mode for JSON-based I/O
|
|
159
|
+
4. Game state is automatically saved after each turn
|
|
160
|
+
|
|
161
|
+
## Building from Source
|
|
162
|
+
|
|
163
|
+
If installing from source (not from PyPI), glulxe will be compiled during installation. This requires:
|
|
164
|
+
|
|
165
|
+
- C compiler (gcc or clang)
|
|
166
|
+
- make
|
|
167
|
+
- git (for submodules)
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
git clone --recursive https://github.com/davidar/mcp-server-if.git
|
|
171
|
+
cd mcp-server-if
|
|
172
|
+
pip install .
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## Troubleshooting
|
|
176
|
+
|
|
177
|
+
### "glulxe binary not found"
|
|
178
|
+
|
|
179
|
+
This shouldn't happen with pip/uvx installs. If it does:
|
|
180
|
+
- Try reinstalling: `pip install --force-reinstall mcp-server-if`
|
|
181
|
+
- Or set `IF_GLULXE_PATH` to a manually installed glulxe
|
|
182
|
+
|
|
183
|
+
### "Game file not found"
|
|
184
|
+
|
|
185
|
+
Use `list_games` to see available games, or `download_game` to get new ones.
|
|
186
|
+
|
|
187
|
+
### Save/restore commands don't work
|
|
188
|
+
|
|
189
|
+
In-game save/restore triggers file dialogs that aren't supported. Use the automatic autosave system instead - your game state persists between sessions automatically.
|
|
190
|
+
|
|
191
|
+
## License
|
|
192
|
+
|
|
193
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
194
|
+
|
|
195
|
+
## Credits
|
|
196
|
+
|
|
197
|
+
- [glulxe](https://github.com/erkyrath/glulxe) - The Glulx VM interpreter by Andrew Plotkin
|
|
198
|
+
- [RemGlk](https://github.com/erkyrath/remglk) - Remote Glk library for JSON I/O
|
|
199
|
+
- [MCP](https://modelcontextprotocol.io/) - Model Context Protocol by Anthropic
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# mcp-server-if
|
|
2
|
+
|
|
3
|
+
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.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Play Glulx (.ulx) and Blorb (.gblorb) interactive fiction games
|
|
8
|
+
- Automatic game state persistence (save/restore between sessions)
|
|
9
|
+
- Download games directly from the IF Archive
|
|
10
|
+
- Optional journaling mode for reflective playthroughs
|
|
11
|
+
- Works with Claude Desktop, Claude Code, and other MCP clients
|
|
12
|
+
- Bundled glulxe interpreter (no manual compilation required)
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
# Using uvx (recommended)
|
|
18
|
+
uvx mcp-server-if
|
|
19
|
+
|
|
20
|
+
# Or install with pip
|
|
21
|
+
pip install mcp-server-if
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
The package includes a pre-compiled `glulxe` binary. No additional setup required.
|
|
25
|
+
|
|
26
|
+
## Configuration
|
|
27
|
+
|
|
28
|
+
### Environment Variables
|
|
29
|
+
|
|
30
|
+
| Variable | Description | Default |
|
|
31
|
+
|----------|-------------|---------|
|
|
32
|
+
| `IF_GAMES_DIR` | Directory to store games | `~/.mcp-server-if/games` |
|
|
33
|
+
| `IF_GLULXE_PATH` | Override path to glulxe binary | Bundled binary |
|
|
34
|
+
| `IF_REQUIRE_JOURNAL` | Require journal reflections | `false` |
|
|
35
|
+
|
|
36
|
+
### Command Line Arguments
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
mcp-server-if --help
|
|
40
|
+
|
|
41
|
+
Options:
|
|
42
|
+
--games-dir PATH Directory to store games
|
|
43
|
+
--glulxe-path PATH Path to glulxe binary (overrides bundled)
|
|
44
|
+
--require-journal Require journal reflections between turns
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Usage with Claude Desktop
|
|
48
|
+
|
|
49
|
+
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):
|
|
50
|
+
|
|
51
|
+
```json
|
|
52
|
+
{
|
|
53
|
+
"mcpServers": {
|
|
54
|
+
"interactive-fiction": {
|
|
55
|
+
"command": "uvx",
|
|
56
|
+
"args": ["mcp-server-if"]
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Usage with Claude Code
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
claude mcp add interactive-fiction -- uvx mcp-server-if
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Available Tools
|
|
69
|
+
|
|
70
|
+
### `play_if`
|
|
71
|
+
Play a turn of interactive fiction.
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
play_if(game="zork", command="go north")
|
|
75
|
+
play_if(game="zork", command="", journal="...reflection...") # with journaling
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### `list_games`
|
|
79
|
+
List available games and their save state status.
|
|
80
|
+
|
|
81
|
+
### `download_game`
|
|
82
|
+
Download a game from the IF Archive or any URL.
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
download_game(name="advent", url="advent.ulx")
|
|
86
|
+
download_game(name="bronze", url="https://example.com/Bronze.gblorb")
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### `reset_game`
|
|
90
|
+
Reset a game to start fresh (clears save state, preserves journal).
|
|
91
|
+
|
|
92
|
+
### `read_journal`
|
|
93
|
+
Read the playthrough journal for a game.
|
|
94
|
+
|
|
95
|
+
```
|
|
96
|
+
read_journal(game="zork", recent=10) # last 10 entries
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### `search_journal`
|
|
100
|
+
Search journal entries by keyword.
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
search_journal(game="zork", query="treasure")
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Supported Game Formats
|
|
107
|
+
|
|
108
|
+
- `.ulx` - Raw Glulx game files
|
|
109
|
+
- `.gblorb` - Blorb containers with Glulx games (may include graphics/sound)
|
|
110
|
+
|
|
111
|
+
Find games at the [IF Archive](https://ifarchive.org/indexes/if-archive/games/glulx/).
|
|
112
|
+
|
|
113
|
+
## Journaling Mode
|
|
114
|
+
|
|
115
|
+
Enable with `--require-journal` or `IF_REQUIRE_JOURNAL=true`. In this mode:
|
|
116
|
+
|
|
117
|
+
1. After playing your first command, subsequent turns require a journal entry
|
|
118
|
+
2. Journal entries must be at least 100 words
|
|
119
|
+
3. Entries are saved to `{game}/journal.jsonl`
|
|
120
|
+
4. Use `read_journal` and `search_journal` to review your playthrough
|
|
121
|
+
|
|
122
|
+
This encourages thoughtful, reflective gameplay rather than rushing through.
|
|
123
|
+
|
|
124
|
+
## How It Works
|
|
125
|
+
|
|
126
|
+
1. Games are stored in `~/.mcp-server-if/games/{name}/`
|
|
127
|
+
2. Each game directory contains:
|
|
128
|
+
- `game.ulx` or `game.gblorb` - the game file
|
|
129
|
+
- `state/` - autosave data (persists between sessions)
|
|
130
|
+
- `metadata.json` - session metadata
|
|
131
|
+
- `journal.jsonl` - playthrough journal (if enabled)
|
|
132
|
+
|
|
133
|
+
3. The server uses glulxe's RemGlk mode for JSON-based I/O
|
|
134
|
+
4. Game state is automatically saved after each turn
|
|
135
|
+
|
|
136
|
+
## Building from Source
|
|
137
|
+
|
|
138
|
+
If installing from source (not from PyPI), glulxe will be compiled during installation. This requires:
|
|
139
|
+
|
|
140
|
+
- C compiler (gcc or clang)
|
|
141
|
+
- make
|
|
142
|
+
- git (for submodules)
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
git clone --recursive https://github.com/davidar/mcp-server-if.git
|
|
146
|
+
cd mcp-server-if
|
|
147
|
+
pip install .
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Troubleshooting
|
|
151
|
+
|
|
152
|
+
### "glulxe binary not found"
|
|
153
|
+
|
|
154
|
+
This shouldn't happen with pip/uvx installs. If it does:
|
|
155
|
+
- Try reinstalling: `pip install --force-reinstall mcp-server-if`
|
|
156
|
+
- Or set `IF_GLULXE_PATH` to a manually installed glulxe
|
|
157
|
+
|
|
158
|
+
### "Game file not found"
|
|
159
|
+
|
|
160
|
+
Use `list_games` to see available games, or `download_game` to get new ones.
|
|
161
|
+
|
|
162
|
+
### Save/restore commands don't work
|
|
163
|
+
|
|
164
|
+
In-game save/restore triggers file dialogs that aren't supported. Use the automatic autosave system instead - your game state persists between sessions automatically.
|
|
165
|
+
|
|
166
|
+
## License
|
|
167
|
+
|
|
168
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
169
|
+
|
|
170
|
+
## Credits
|
|
171
|
+
|
|
172
|
+
- [glulxe](https://github.com/erkyrath/glulxe) - The Glulx VM interpreter by Andrew Plotkin
|
|
173
|
+
- [RemGlk](https://github.com/erkyrath/remglk) - Remote Glk library for JSON I/O
|
|
174
|
+
- [MCP](https://modelcontextprotocol.io/) - Model Context Protocol by Anthropic
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
gitdir: ../../.git/modules/deps/glulxe
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 1999-2023, Andrew Plotkin
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Unix Makefile for Glulxe.
|
|
2
|
+
|
|
3
|
+
# To use this, you must set three variables. GLKINCLUDEDIR must be the
|
|
4
|
+
# directory containing glk.h, glkstart.h, and the Make.library file.
|
|
5
|
+
# GLKLIBDIR must be the directory containing the library.a file.
|
|
6
|
+
# And GLKMAKEFILE must be the name of the Make.library file. Two
|
|
7
|
+
# sets of values appear below; uncomment one of them and change the
|
|
8
|
+
# directories appropriately.
|
|
9
|
+
|
|
10
|
+
GLKINCLUDEDIR = ../cheapglk
|
|
11
|
+
GLKLIBDIR = ../cheapglk
|
|
12
|
+
GLKMAKEFILE = Make.cheapglk
|
|
13
|
+
|
|
14
|
+
#GLKINCLUDEDIR = ../glkterm
|
|
15
|
+
#GLKLIBDIR = ../glkterm
|
|
16
|
+
#GLKMAKEFILE = Make.glkterm
|
|
17
|
+
|
|
18
|
+
#GLKINCLUDEDIR = ../xglk
|
|
19
|
+
#GLKLIBDIR = ../xglk
|
|
20
|
+
#GLKMAKEFILE = Make.xglk
|
|
21
|
+
|
|
22
|
+
#GLKINCLUDEDIR = ../remglk
|
|
23
|
+
#GLKLIBDIR = ../remglk
|
|
24
|
+
#GLKMAKEFILE = Make.remglk
|
|
25
|
+
|
|
26
|
+
#GLKINCLUDEDIR = ../gtkglk/src
|
|
27
|
+
#GLKLIBDIR = ../gtkglk
|
|
28
|
+
#GLKMAKEFILE = ../Make.gtkglk
|
|
29
|
+
|
|
30
|
+
# Also set an appropriate OS config in OPTIONS, below.
|
|
31
|
+
# -DOS_MAC for MacOS
|
|
32
|
+
# -DOS_WINDOWS for Windows
|
|
33
|
+
# -DOS_UNIX for Unix/Linux
|
|
34
|
+
# For OS_UNIX, you probably also want to set a random number generator
|
|
35
|
+
# option. These are unfortunately not very standardized across Unixes.
|
|
36
|
+
# We recommend -DUNIX_RAND_GETRANDOM on Linux and -DUNIX_RAND_ARC4
|
|
37
|
+
# on NetBSD.
|
|
38
|
+
# (MacOS always uses ARC4, in case you were wondering.)
|
|
39
|
+
|
|
40
|
+
# Pick a C compiler.
|
|
41
|
+
CC = cc
|
|
42
|
+
#CC = gcc
|
|
43
|
+
|
|
44
|
+
OPTIONS = -g -Wall -Wmissing-prototypes -Wno-unused -DOS_MAC
|
|
45
|
+
|
|
46
|
+
# Locate the libxml2 library. You only need these lines if you are using
|
|
47
|
+
# the VM_DEBUGGER option. If so, uncomment these and set appropriately.
|
|
48
|
+
#XMLLIB = -L/usr/local/lib -lxml2
|
|
49
|
+
#XMLLIBINCLUDEDIR = -I/usr/local/include/libxml2
|
|
50
|
+
|
|
51
|
+
include $(GLKINCLUDEDIR)/$(GLKMAKEFILE)
|
|
52
|
+
|
|
53
|
+
CFLAGS = $(OPTIONS) -I$(GLKINCLUDEDIR) $(XMLLIBINCLUDEDIR)
|
|
54
|
+
LIBS = -L$(GLKLIBDIR) $(GLKLIB) $(LINKLIBS) -lm $(XMLLIB)
|
|
55
|
+
|
|
56
|
+
OBJS = main.o files.o vm.o exec.o funcs.o operand.o string.o glkop.o \
|
|
57
|
+
heap.o serial.o search.o accel.o float.o gestalt.o osdepend.o \
|
|
58
|
+
profile.o debugger.o
|
|
59
|
+
|
|
60
|
+
all: glulxe
|
|
61
|
+
|
|
62
|
+
glulxe: $(OBJS) unixstrt.o unixautosave.o
|
|
63
|
+
$(CC) $(OPTIONS) -o glulxe $(OBJS) unixstrt.o unixautosave.o $(LIBS)
|
|
64
|
+
|
|
65
|
+
glulxdump: glulxdump.o
|
|
66
|
+
$(CC) -o glulxdump glulxdump.o
|
|
67
|
+
|
|
68
|
+
$(OBJS) unixstrt.o unixautosave.o: glulxe.h unixstrt.h
|
|
69
|
+
|
|
70
|
+
exec.o operand.o: opcodes.h
|
|
71
|
+
gestalt.o: gestalt.h
|
|
72
|
+
|
|
73
|
+
clean:
|
|
74
|
+
rm -f *~ *.o glulxe glulxdump profile-raw
|
|
75
|
+
|