foundryvtt-mcp

v3.1.0
@g33ks/foundryvtt-mcp Checked 1 day ago Published 10 days ago

Model Context Protocol server for FoundryVTT integration

A Model Context Protocol (MCP) server that lets an AI assistant such as Claude read and run a Foundry Virtual Tabletop world with you: look things up, keep notes, place tokens and scenery, run combat, roll dice. It is not tied to a game system: it works through FoundryVTT's own documents and each system's data as it is (see Compatibility). Your AI client starts a small relay program. Every relay hands its requests to one background process, which logs in to FoundryVTT with an account of its own, the way a player's browser does, and keeps the world in memory.

Summary extracted from the README.

FoundryVTT MCP Server

Test Security npm License: MIT

A Model Context Protocol (MCP) server that lets an AI assistant such as Claude read and run a Foundry Virtual Tabletop world with you: look things up, keep notes, place tokens and scenery, run combat, roll dice. It is not tied to a game system: it works through FoundryVTT's own documents and each system's data as it is (see Compatibility).

How it works

Each AI client starts a small relay; the relays share one background process, which keeps the connection to FoundryVTT and runs an invisible browser where the companion module serves what only a FoundryVTT page can do.

Your AI client starts a small relay program. Every relay hands its requests to one background process, which logs in to FoundryVTT with an account of its own, the way a player's browser does, and keeps the world in memory. For what only a real FoundryVTT page can do (capturing the canvas, native dice rolls, compendium documents, uploads), that process runs an invisible browser where the companion module FoundryVTT MCP Bridge connects to it. Details: Architecture.

What it does

More than a hundred tools, in these groups (full list):

  • Actors and items: search, details, inventory, attribute changes, owned items, active effects, on a world actor or on one token.
  • Tokens: place, move (with pathfinding around walls), remove, vision, status conditions.
  • Scenes: create, activate, lighting, weather, fog of war.
  • Canvas: walls and doors, lights, sounds, map notes, drawings, templates, regions, tiles, free grid cells, the images and sounds available.
  • Combat: start, initiative, turns, end, current state.
  • Journals: search, read, create, and edit pages safely (version check, local copies, overwrite detection).
  • Chat and dice: read and send messages; roll dice, with FoundryVTT's own engine when the REST API module's key is set and locally otherwise.
  • World: summary and search, folders, macros, playlists, roll tables, users and roles, ownership, settings.
  • Compendiums, rules and generators: compendium search, rule lookup in journals and compendiums, quick NPC and loot generators.
  • Companion module: canvas capture, rolls posted to chat by FoundryVTT, document schemas, compendium content and imports, an actor's prepared data, targets, pings, pause, file uploads.
  • Events and diagnostics: a live activity log to follow the game, the connector's health, server logs.

Writes are off until you allow them; while they are off, every tool that changes the world is refused. See Security.

Requirements

  • Node.js 22 or newer, with npm.
  • FoundryVTT v13 or v14 with a world you can open as its Gamemaster, on this computer or on a server. Tried with v14 builds 369 and 370; v13 is accepted by the companion module and handled by the code, but not tried (see Compatibility).
  • A Chromium-based browser on this computer: Google Chrome, Microsoft Edge, Brave, Vivaldi or Chromium. You never see it open.
  • An MCP client: Claude desktop or Claude Code (others that start servers over stdio should work).

Quick start

1. Install the companion module, create the connector's account

  1. On FoundryVTT's Setup screen: Add-on Modules → Install Module, paste this Manifest URL, then Install:

    https://raw.githubusercontent.com/G33ks/foundryvtt-mcp/main/foundry-module/module.json
    
  2. Launch your world as its Gamemaster. Game Settings → User Management → Create Additional User: name it, for example, mcp-api, give it a long password used nowhere else and the Assistant GM role.

  3. Game Settings → Manage Modules: check FoundryVTT MCP Bridge, then Save Module Settings.

2. Install the connector

npm install -g @g33ks/foundryvtt-mcp
foundryvtt-mcp --version

In Windows PowerShell, if npm or foundryvtt-mcp is refused (running scripts is disabled), type npm.cmd and foundryvtt-mcp.cmd instead. The package is @g33ks/foundryvtt-mcp, not the unscoped foundryvtt-mcp.

3. Run init

foundryvtt-mcp init

It asks for FoundryVTT's address (the one you open in your browser), the account from step 1 and whether the AI may change the world (no by default). It checks each answer against your FoundryVTT, writes the configuration file, and prints what to give your MCP client. It needs an interactive terminal: on Windows, PowerShell or Command Prompt (in Git Bash, prefix it with winpty). You can allow writes later: see Configuration.

4. Add the connector to your MCP client

  • Claude desktop: Settings → Developer → Edit Config, add the foundryvtt entry init printed under "mcpServers", save, then quit Claude desktop completely (also from the notification area or menu bar) and start it again.
  • Claude Code: run the claude mcp add foundryvtt … command init printed, then start a new session.

5. First try

With your world launched in FoundryVTT:

  1. foundryvtt-mcp init --check should end with All checks passed.
  2. Ask your AI client: "Show the FoundryVTT connector's health status." It should show the FoundryVTT connection, the module bridge and the GM session connected. The first call can take a few seconds.

When something fails, the message says why; TROUBLESHOOTING.md explains each one. Every step in detail, updates and uninstalling: Installation.

Known limitations

  • Close a journal page in FoundryVTT before the AI writes to it. An open editor's autosave can overwrite the AI's change; the connector detects it and keeps a copy, but cannot prevent it.
  • Write stored fields only. A value the game system computes is accepted and saved, but has no effect in play; get_document_schema tells them apart.
  • search_compendium needs the separate REST API module. Without it, use search_compendium_content, which goes through the companion module.
  • watch_events does not see the connector's own changes, only those of other users.
  • One connector per computer: two would compete for the companion module's port.
  • Some changes stay yours: the connector does not promote anyone to Gamemaster nor change the world's permission settings.
  • After FoundryVTT restarts, launch the world again. The connector waits for it and reconnects by itself.
  • After an update, restart your MCP client: a client started earlier keeps the previous list of tools.
  • A deletion can, rarely, go unanswered: FoundryVTT deletes the document, but its answer never reaches the connector. It has not been reproduced on demand. The connector then reads the document back: the tool succeeds with a note when the document is gone, and reports the timeout otherwise. If such an error still happens, note the time, call refresh_world_data, and keep the connector's log lines from that time (where the log is).
  • Before companion module 0.7.0, a combat created by start_combat may not show in the combat tracker. Some game systems define a combat's own data in code that only the browsers load; without the module 0.7.0, the connector creates the combat on the server without that data, and open browsers reject it until each user reloads FoundryVTT (F5); later updates then show live. With the module 0.7.0 or later, the combat is created in the module's browser session and shows at once.

Documentation

Contributing and support

Origins

Started by Lauri Gates as laurigates/foundryvtt-mcp, continued in RN0000/foundryvtt-mcp, then forked as duckpuppy/foundryvtt-mcp, from which this repository was forked; it now continues independently. Thanks to everyone who built the earlier versions; their work is kept in the history and in the changelog.

License

MIT.