Spellbook MCP Server
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.
Spellbook
A licence-aware rules library for tabletop game sources. Point it at the PDFs, markdown and SRD checkouts you own. It extracts them page by page, records the licence each page is under, and gives you full-text search, random tables, stat blocks and generators. It also keeps a provenance log of what went where.
It also runs as an MCP server, so an AI assistant can look rules up in your books instead of answering from memory, and is told every time which material it may reuse.

A real Claude Code session against a store holding SRD 5.2.1 and one page of table notes, replayed at 1.5x, then a CLI search on the same store.
This work includes material from the System Reference Document 5.2.1 ("SRD 5.2.1") by Wizards of the Coast LLC, available at https://www.dndbeyond.com/srd. The SRD 5.2.1 is licensed under the Creative Commons Attribution 4.0 International License, available at https://creativecommons.org/licenses/by/4.0/legalcode.
The software is MIT. Your books are not. Spellbook never ships, downloads or shares source material. The store it builds stays on your machine, and it holds copyrighted text. Do not commit it, publish it or serve it to anyone else.
Licence classes
Every page is in one of three classes. The class decides what you may do with it:
Class | What it is | What you may take |
| Open licence text (OGL Open Game Content, CC BY, an SRD, public domain) | The text, verbatim, with the credit the licence asks for |
| Pages whose numbers you may use but whose prose you may not | Numbers and mechanics, never the wording |
| Everything else: books you own for reading | Ideas only. Every result starts with the marker |
Classes come from a licence reading of each source. A source nobody has read is reference until someone does.
The reading lives in overrides.json, plus an optional catalog. overrides.json here is a one-entry template:
replace it with your own readings, including the page ranges a mixed book splits into.
Related MCP server: D&D Knowledge Navigator
Install
Python 3.10 or newer.
pip install -r requirements.txt(pypdf for PDF bookmarks; pytest for the tests).Poppler's
pdftotextandpdfinfoon your PATH, for PDFs. On Windows use the poppler build; on Linux and macOS use thepoppler-utilsorpopplerpackage.
Quick start
python spellbook.py ingest ~/books --no-catalog # extract a folder (local paths only; URLs are refused)
python spellbook.py status # what the store holds, by class
python spellbook.py search "retainer morale" # full text: words ANDed, "a phrase", prefix*
python spellbook.py show basic-fantasy 50 # one page, with its licence history
python spellbook.py tables && python spellbook.py tables --list
python spellbook.py roll "wandering monster" # roll a detected table
python spellbook.py blocks && python spellbook.py blocks --list --kind monster
python spellbook.py generate room --level 2 # a generator procedure from procedures.json
python spellbook.py cite --doc basic-fantasy --page 50 --into data/hirelings.yaml --use facts
python spellbook.py lint ./my-game # banned names (from overrides.json) in your filesThe store defaults to $SPELLBOOK_STORE, else ~/.spellbook/store. Pass --store to use another. Run
python spellbook.py <command> --help for every option.
The store
docs/<slug>/meta.json the document record and its licence history
docs/<slug>/raw/0001.txt one file per page, reading order
docs/<slug>/layout/0001.txt one file per page, pdftotext -layout (PDF only)
docs/<slug>/outline.json PDF bookmarks, when present
library.sqlite documents and an FTS5 page index
provenance.ndjson every ingest, reclass and cite, append-only
tables.ndjson / blocks.ndjson detected random tables and stat blocksThe MCP server
spellbook_mcp.py serves the read commands over stdio:
spellbook_search, spellbook_show, spellbook_topics, spellbook_tables, spellbook_table,
spellbook_roll, spellbook_blocks, spellbook_block, spellbook_generate, spellbook_lint and
spellbook_status.
Output passes through unchanged, so the class and the reference marker always reach the model.
Arguments are validated, and none can add a command-line flag.
tablesandblocksonly ever list; they never rebuild an index.
One write tool, spellbook_cite, records provenance. It is offered only when SPELLBOOK_MCP_WRITE=1, and
spellbook cite itself enforces the licence:
copyneeds a copy page;factsneeds a copy or facts page;a reference page takes
ideaonly, with a note;a quote must occur verbatim on the page.
Claude Code, read and write:
claude mcp add spellbook --scope user -e SPELLBOOK_MCP_WRITE=1 -- python /path/to/spellbook_mcp.pyAny MCP client, read-only:
{"mcpServers": {"spellbook": {"command": "python", "args": ["/path/to/spellbook_mcp.py"],
"env": {"SPELLBOOK_STORE": "/path/to/store"}}}}Contributing
Issues and pull requests are welcome. Good first areas:
importers for more formats;
table and stat-block detection for more systems;
generator procedures.
Run the tests before you open a pull request:
python -m pytest -q. They build their own fixtures and need no books.Never commit extracted text, a store, or a page of any book. Fixtures are written by hand.
Keep the licence classes strict: a change that could let reference text reach a
copyorfactsresult needs a test that proves it cannot.
Licence
MIT, credited to Mattlock of Schedule 3 Wizards. See LICENSE. The licence covers this software only. It grants
nothing in any book you ingest.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
Related MCP Connectors
D&D and TTRPG campaign manager for GMs: your AI reads and writes a live, typed campaign database.
Connect any AI to your Foundry VTT world: actors, combat, dice, journals, tokens, compendiums.
Mess in, magic out: your D&D and TTRPG notes become a private world store any AI app can read.
Discord D&D note taker: search and cite your TTRPG session recaps, quests, NPCs and transcripts.
Related MCP Servers
- FlicenseNot gradedqualityNot gradedmaintenanceIntegrates with FoundryVTT tabletop gaming sessions, allowing AI assistants to query game data, roll dice, generate content (NPCs, loot, encounters), manage combat, and provide tactical suggestions through natural language.6 npm-
- AlicenseNot gradedqualityDmaintenanceConnects AI assistants to Dungeons & Dragons 5e game information via the Model Context Protocol, enabling queries for spells, monsters, equipment, and more.56MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI assistants to manage D&D Beyond characters, access campaigns, and look up spells, monsters, items, and more through a reverse-engineered API.MIT
- AlicenseNot gradedqualityBmaintenanceConnects AI assistants to TTRPG campaign data for managing characters, sessions, locations, factions, items, quests, and more.4MIT