zmachine-mcp
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
zmachine-mcp
An MCP server for playing Z-Machine text adventure games (Zork, Hitchhiker's Guide, etc.) with AI agents.
Three interfaces expose the same game engine:
MCP — stdio or HTTP transport, so AI assistants like Claude can play text adventures
REST API — programmatic session management and input/output
WebSocket — real-time output streaming
A built-in status page at / shows server health, active sessions, and MCP setup instructions.
Quick Start
npm installPlace your Z-Machine story files (.z3, .z4, .z5, .z7, .z8, .zblorb) in a folder and point to it:
export STORIES=../storiesThen start the server:
# Development (auto-reload, server on :3000, Vite on :5173)
npm run dev
# Production
npm run build && npm startOpen http://localhost:3000 to see the server status page.
Related MCP server: mcp-server-if
MCP Integration
Claude Desktop (stdio)
npm run start:stdioAdd to your Claude Desktop config (claude_desktop_config.json):
{
"mcpServers": {
"zmachine": {
"command": "npx",
"args": ["tsx", "src/server/main.ts", "--stdio"],
"env": {
"STORIES": "/path/to/your/stories"
}
}
}
}HTTP Transport
When running in HTTP mode, the MCP endpoint is available at POST /mcp.
MCP Tools
Tool | Description |
| List available story files |
| Start a new session; returns session ID and opening text |
| Send a command; returns the game's response |
| Get session state and status line |
| End a session |
REST API
Interactive documentation is available at /api/docs when the server is running. The raw OpenAPI spec is at /api/openapi.yml.
Method | Endpoint | Description |
|
| Server status, uptime, active sessions |
|
| List available games |
|
| List all active sessions with their IDs, game, state, and status line |
|
| Create a new game session |
|
| Send input to a session |
|
| End a session |
WebSocket
Connect to ws://localhost:3000/ws?session=<id> for real-time output streaming.
Configuration
Environment Variable | Default | Description |
|
| Path to folder containing Z-Machine story files |
|
| HTTP server port |
| — | Redis connection URL for session persistence |
| — | Set to |
Redis Persistence (optional)
Set REDIS_URL (e.g. redis://localhost:6379) to persist sessions and save data to Redis. Without it, sessions are in-memory only and lost on restart.
Development
npm run dev # Dev server with auto-reload
npm test # Run tests
npm run test:coverage # Tests with coverage report
npm run typecheck # TypeScript type checkingProject Structure
src/
server/
main.ts — Entry point (HTTP or stdio mode)
mcp-server.ts — MCP tool definitions
rest-server.ts — Express REST API
ws-server.ts — WebSocket server
session-manager.ts — Loads stories, manages sessions
game-session.ts — Single game session (wraps Z-Machine VM)
glkote-async.ts — Custom GlkOte for synchronous I/O capture
redis-store.ts — Optional Redis persistence
client/
main.ts — Status page (polls /api/status)
index.css — Status page styles
__tests__/ — Jest test suitesTech Stack
Runtime: Node.js + TypeScript (ESM)
Z-Machine: ifvms + glkote-term
Server: Express 5, WebSocket (ws)
Client: Vanilla TypeScript, Vite
Testing: Jest + ts-jest
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Hosted MCP server connecting AI assistants to 9,000+ apps and 40,000+ actions via Zapier.
MCP server for the Z1N Protocol - on-chain identity for AI agents on Polygon
Make games with AI: one MCP server that connects your agent to Unity, Unreal and Godot editors.
Persistent memory, knowledge graph, task management and more for AI agents via MCP.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables creation and management of structured game worlds for text adventures and RPGs with character creation, world generation, and natural language interaction through AI integration.1MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to play interactive fiction games (Glulx and Z-machine) through the Model Context Protocol, with automatic save/restore and optional journaling mode.MIT
- AlicenseNot gradedqualityCmaintenanceAn MCP server that enables AI agents to act as dynamic dungeon masters for text-based RPGs with dynamically generated rule systems and comprehensive game state management.8 npm14MIT
- AlicenseNot gradedqualityCmaintenanceMCP server that enables AI agents to create, edit, validate, and export single-file HTML text adventure games using JSON story data and MCP tools.8 npmMIT