nwn-dm-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@nwn-dm-mcp log in as DM, check server status, and see who's in-world"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
nwn-dm-mcp
A protocol-level Neverwinter Nights: Enhanced Edition DM client, exposed as an MCP server for DM presence, chat, and (server-side bridged) DM actions.
Status: login solved; MCP server v1 built and verified. The session layer (key exchange, encrypted transport, login, frame layer) is reversed and reproduced live by an independent Python client - the full login construction is cracked and gate-verified (see AUTH.md; SPIKE.md is the original dissection). The MCP server below wraps that session core and was tested end-to-end against a disposable test server: connect, in-world hold, status/who, chat send, bridge writes, disconnect, with the server log corroborating the join and both auth factors.
Layout
SPIKE.md- protocol findings from the first spike.AUTH.md- the login construction and its gate evidence.src/nwn_dm_mcp/- the package:protocol.py(wire constructions),session.py(managed DM session),poll.py(cleartext server polling),bridge.py(SQLite action queue),server.py(the MCP server),hydrogen.py(LibHydrogen wrapper).tests/- a bridge row-shape test and a JSON-RPC test client that drives the server over stdio.prototype/- the spike code the package was distilled from.captures/- pcap of a real DM login against a test server (kept out of the public tree; may contain account identifiers).
Related MCP server: cozyvtt-mcp
MCP server
The server speaks MCP as newline-delimited JSON-RPC 2.0, hand-rolled - zero runtime dependencies beyond Python 3.10+ and the LibHydrogen build below. Two transports share one tool surface:
stdio (default) - for a client on the same host.
HTTP (
--http) - POST-based JSON-RPC for hosting the server next to the game server and reaching it over a private network (for example a tailnet). Every request must carry a bearer token from theNWN_MCP_TOKENenvironment variable (Authorization: Bearer <token>, constant-time comparison); with no token configured the HTTP transport refuses to start. Bind only a private-network interface (--bind/NWN_MCP_BIND, default 127.0.0.1;NWN_MCP_PORT, default 8765).GET /healthis the only unauthenticated route.
Run (stdio)
pip install .
HYDROGEN_LIB=/path/to/libhydrogen-old.so nwn-dm-mcpor, from a checkout without installing:
PYTHONPATH=src HYDROGEN_LIB=... python3 -m nwn_dm_mcpRun (HTTP, hosted)
NWN_MCP_TOKEN=<token> NWN_MCP_BIND=<private-interface-ip> \
HYDROGEN_LIB=... PYTHONPATH=src \
python3 -m nwn_dm_mcp --http --http-port 8765Clients POST JSON-RPC messages to / or /mcp with the
Authorization: Bearer <token> header; notifications are
accepted with an empty 202 response.
Configuration (arguments to dm_connect, or environment)
Setting | Env var | Notes |
Server host |
| no default |
Server port |
| default 5122; any port the operator configures |
Account name |
| default |
Public CD key id |
| public info (cleartext polls) |
DM password file |
| default |
CD key file |
| default |
Settings-flood file |
| required - see below |
Bridge DB |
| SQLite world DB for bridge tools |
LibHydrogen |
| pre-overhaul build (see Build note) |
HTTP bearer token |
| required for |
HTTP bind address |
| default 127.0.0.1; private interface only |
HTTP port |
| default 8765 |
The settings flood is a one-time capture of the real client's post-login settings-sync frames (hex, one frame per line). It is operator-supplied runtime data, not shipped: without the replay the server never sends the character message and the session never reaches in-world state (AUTH.md SS6). Which flood elements are load-bearing has not been bisected yet.
Tools
Wire-side (the held DM session):
dm_connect- log in fresh and hold the in-world session.dm_disconnect- end the session (the server reaps it after ~75-95 s; an immediate same-key reconnect may be refused).dm_status- state, uptime, server name/module, frame counts.dm_who- fresh cleartext poll (server name, module, build, BNXR count byte: 1 idle / 2 with one session in-world) plus this session's own presence. A named player roster is not yet exposed by the reversed protocol surface.dm_say- DM chat (wire message 9/14). Caveat: server-side delivery is not yet witness-verified - the test server logs no client chat, and CD-key auth prevents a fabricated witness client (AUTH.md SS7).
Bridge-side (rows in the world DB's bridge_action_queue,
executed or refused by a server-side consumer on its heartbeat):
dm_jump(target_tag or locationarea_tag:x:y:z),dm_spawn(resref),dm_freeze(target_tag),dm_inspect(target_tag).With no bridge DB configured, these tools say so plainly and queue nothing.
The queue contract is the in-module one: rows are inserted with status
pending; the consumer moves them todoneorrefusedwith a reason inresult. The currently deployed consumer implements inhabitant verbs (speak/move/follow/wait/ attack); DM verbs ride the same queue and await a DM-action consumer module-side.
Tests
python3 tests/test_bridge.py # row shape
python3 tests/test_http.py # HTTP auth + surface
python3 tests/test_session_messages.py # frame message walk
PYTHONPATH=src python3 tests/mcp_test_client.py smoke
PYTHONPATH=src NWN_BRIDGE_DB=/tmp/x.sqlite3 \
python3 tests/mcp_test_client.py bridge
# full wire flow (needs a test server + operator config):
PYTHONPATH=src HYDROGEN_LIB=... NWN_TEST_HOST=... \
NWN_TEST_ACCOUNT=... NWN_TEST_PUBLIC_ID=... \
NWN_TEST_PASS_FILE=... NWN_TEST_CDKEY_INI=... \
NWN_TEST_FLOOD_FILE=... \
python3 tests/mcp_test_client.py e2eBuild note
The protocol needs LibHydrogen's pre-overhaul hydro_kx_XX
API (commit 850c6bd, 2019-11-22); current libhydrogen is not
wire-compatible. src/nwn_dm_mcp/hydrogen.py documents the build.
Available Tools
9 toolsdm_connectB
Connect the DM session to a NWN:EE server and log in (fresh BNCS/BNVS), replay the settings flood, and hold the in-world session open. Credentials come from arguments or environment, never from the repo.
Inputs: host, port, account, bridge_db, +4 more.
dm_disconnectA
Disconnect the DM session. The server reaps the vanished session after ~75-95 s.
Inputs: no named parameters.
dm_freezeB
Queue a server-side bridge action: freeze the creature with target_tag (param may carry a duration). Writes one 'pending' row to bridge_action_queue.
Inputs: target_tag (required), param, actor_tag.
dm_inspectB
Queue a server-side bridge action: inspect the object with target_tag; the consumer records what it finds in the row's result. Writes one 'pending' row to bridge_action_queue.
Inputs: target_tag (required), actor_tag.
dm_jumpA
Queue a server-side bridge action: jump the DM/actor to a target_tag or a location 'area_tag:x:y:z'. Writes one 'pending' row to bridge_action_queue.
Inputs: location, actor_tag, target_tag.
dm_sayB
Send a DM chat message (wire message 9/14, per AUTH.md SS7). Note: server-side delivery of client chat is not yet witness-verified - the test server logs no client chat and key auth prevents a fabricated witness.
Inputs: text (required).
dm_spawnA
Queue a server-side bridge action: spawn a template resref (optionally at a location, with a tag). Writes one 'pending' row to bridge_action_queue.
Inputs: resref (required), location, actor_tag, target_tag.
dm_statusA
Report session state, uptime, server name/module, frame counters, and bridge configuration.
Inputs: no named parameters.
dm_whoB
Who is on the server: a fresh cleartext poll (server name, module, BNXR count byte) plus this DM session's own presence. A named player roster is not yet exposed by the reversed protocol surface.
Inputs: host, port, account, public_id.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 9 tools
Each tool maps to a distinct action (connect, disconnect, say, jump, spawn, freeze, inspect), and the four bridge-queue tools are differentiated by their action payloads. The only mild overlap is dm_status vs dm_who, since both report server/session information, though the descriptions clarify that one is session state and the other is a presence poll.
All nine tools use the same dm_ prefix followed by a single lowercase snake_case verb/noun, giving a fully predictable pattern. Query-style names (dm_status, dm_who) sit naturally alongside action names without breaking the convention.
Nine tools is well within the sweet spot and each one earns its place: session lifecycle, queries, chat, and four distinct bridge actions. Nothing appears redundant or padded.
Session lifecycle and basic DM actions are covered, but the bridge-queue tools are write-only — there is no tool to read the queue, poll a pending action's result (dm_inspect explicitly writes results to a row the agent cannot fetch), or cancel an action. Common DM operations like kick/kill, give item, or possess target are also absent.
Maintenance
Related MCP Connectors
Remote MCP server for D&D: read and update your CharGen campaigns, generate NPCs and art.
Dungeons & Dragons (D&D) and TTRPG companion: SessionKeeper sessions, NPCs, wiki, DM prep.
Create AI Characters and generate their DM and comment replies from any MCP client.
Official remote MCP server for Archivist AI TTRPG campaign memory: characters, sessions, and more.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables a minimal multiplayer text TRPG with DM, human, and agent roles, shared room event logs, staged turns, and server-side d20 checks.-
- AlicenseAqualityBmaintenanceEnables an AI agent to act as a DM/KP in a CozyVTT campaign by narrating over chat, rolling server-authoritative dice, moving tokens, switching maps, managing initiative, and accessing character sheets through MCP.411MIT
- AlicenseNot gradedqualityCmaintenanceConnects MCP-capable clients to hosted tabletop campaigns so users can ask plain-language questions about their campaigns, sessions, and codex entries (NPCs, locations, items, lore, religions, groups) and submit notes, recaps, events, and DM-reviewable proposals. Access is scoped per user through database row-level security, so it only ever exposes what the website would show that account, with AI-written content staying non-canon until a DM approves it.MIT
- AlicenseNot gradedqualityBmaintenanceGives AI agents controlled access to an existing, live SQLite database that another application owns, with permission-gated schema, read, structured write, backup, and diagnostics tools. Structured writes with mandatory filters, row limits counting cascades, and request idempotency keep a mistaken but authorized agent from causing unrecoverable damage.1Apache 2.0