FoundryVTT MCP Server
Provides comprehensive read and write access to a Foundry Virtual Tabletop world, enabling AI assistants to act as Co-GMs by managing actors, items, tokens, combat encounters, canvas placeables (walls, lights, sounds, templates, drawings, notes, tiles), scenes, playlists, macros, roll tables, compendiums, and world settings.
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., "@FoundryVTT MCP ServerRoll a stealth check for the rogue with advantage and show the result in chat."
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.
FoundryVTT MCP Server
A comprehensive, production-grade Model Context Protocol (MCP) server for Foundry Virtual Tabletop (FoundryVTT).
This server empowers AI assistants (Claude Desktop, Claude Code, Oh My Pi, VS Code, Cursor, etc.) to act as fully capable, autonomous Co-GMs and GM assistants inside FoundryVTT. It provides complete read and write access across game mechanics, actors, items, tokens, combat encounters, canvas placeables (walls, lights, sounds, templates, drawings, notes, tiles), playlists, macros, roll tables, compendiums, world settings, and live canvas rendering.
π Key Highlights & Capabilities (111 Tools)
ποΈ Real-Time Event Stream & Activity Log (
watch_events): Zero-polling event awareness via Socket.IOmodifyDocumentand companion bridge pushes. An AI DM agent can long-poll on a cursor-addressed stream (cursor,waitMs,excludeSelf,types,sceneId) to react instantly when players chat, move tokens, advance combat, toggle doors, or select targets.π² Game Mechanics & Interactive Chat: Roll dice with standard or complex drop/keep notation (
4d6kh3,1d20r1). Roll and post interactive, clickable chat cards directly to the Foundry chat log via the companion bridge (roll_and_post).πΊοΈ Full Canvas & Spatial Control: Create, inspect, update, and remove all canvas placeable types:
Scene Regions (v12+):
create_region,delete_region,list_regionswith geometric shapes (rectangle,circle,ellipse,polygon) and automated trigger behaviors.Walls & Doors: standard, doors (open/close/lock), secret doors, windows, ethereal walls, and custom coordinates (
create_wall,list_walls,set_door_state).Ambient Lights: coordinate or grid-cell placement, dim/bright radii, animation effects, color thresholds (
create_light,update_light,delete_light,list_lights).Ambient Sounds: audio tracks, radii, volume, repeat modes (
create_sound,delete_sound,list_sounds).Measured Templates: cone, circle, ray, and rect spell area-of-effect markers with directional rotation and colors (
create_template,delete_template,list_templates).Drawings: freehand and geometrical shapes, stroke/fill styling, and text annotations (
create_drawing,delete_drawing,list_drawings).Map Notes & Pins: landmark markers linked to journal entries or standalone labels (
create_note,delete_note,list_notes).Tiles & Props: place decorative tiles and backgrounds (
create_tile,delete_tile,list_tiles).Canvas Viewport Capture: screenshot the GM canvas viewport with a burned-in coordinate grid overlay (
[col,row]) viacapture_scene.Targeting & Animated Pings: focus player attention with animated camera pings (
ping_canvas) and view/set token targeting reticles (set_target,get_targets).
π§ Token & Actor Control:
A* Pathfinding Movement: tokens navigate around walls and automatically open closed doors along their path (
move_token_pathfind).Token Vision & Lighting: configure sight ranges, vision modes, dim/bright emitted light, and vision detection angles (
update_token_vision).Generalized ActiveEffects: create, update, delete, and inspect mechanical buffs/debuffs with attribute changes (
key,mode,value,priority) and durations (rounds,seconds,turns) on top-level or synthetic unlinked token actors (create_actor_effect,update_actor_effect,delete_actor_effect,list_actor_effects).Status Conditions: apply/remove system-agnostic status conditions (
apply_status_effect).Compendium Actor & Item Import: import entire NPC/monster documents from compendium packs with automatic per-item error recovery (
import_compendium_actor), or import specific items into actor inventories (create_actor_item).System Attribute Mutations: patch actor system data (HP, temporary HP, currency, resources, spell slots) using JSON merge patches (
update_actor_attributes).
βοΈ Combat Encounter Management: Create encounters, seed combatants from tokens, manage initiative orders, advance turns/rounds, track active combatants, pause/unpause the game clock (
set_pause), and end encounters.π World Documents & Organization:
Folders: manage hierarchical folder structures for actors, items, journals, and scenes (
create_folder,list_folders).Macros: inspect, create, and delete script/chat macros (
create_macro,list_macros,delete_macro).Playlists & Audio: create multi-track playlists, control playback (play, pause, stop), and adjust track states (
create_playlist,set_playlist_state,list_playlists).Roll Tables: create tables with automatic sequential range distribution (
1dN), and draw live results (create_roll_table,roll_table,list_roll_tables).Document Ownership & User Roles: configure granular document permissions (
set_document_ownership) and user roles with self-demotion lockout guards (set_user_role).World Settings: safely inspect and update module and system settings with built-in protection against core engine corruption (
get_world_setting,set_world_setting).Asset Uploads: upload images, tokens, and audio directly into Foundry's
Data/storage via native FilePicker or local filesystem (upload_asset).
π«οΈ Scene, Weather & Exploration Management: Switch active scenes, adjust darkness levels, toggle global illumination, set environmental weather effects (
set_scene_weather), and reset Fog of War exploration (reset_fog).π Rules & Compendium Search: Search world documents, compendium packs, and rule text with contextual snippets (
search_compendium_content,lookup_rule).
Related MCP server: Foundry VTT MCP Bridge
ποΈ Architecture
The server employs a hybrid architecture to deliver real-time responsiveness and deep game-engine integration:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β AI Assistant / MCP Client β
β (Claude Desktop, Oh My Pi, VS Code) β
ββββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββ
β MCP (stdio)
ββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββ
β FoundryVTT MCP Server β
ββββββββββββββββββββββββββββ¬ββββββββββββββββββββ¬βββββββββββββββ€
β In-Memory World Cache β A* Pathfinding β Headless GM β
β (Live Socket.IO Sync) β Dice Notation β Browser Sess.β
ββββββββββββββββ¬ββββββββββββ΄ββββββββββ¬ββββββββββ΄βββββββ¬ββββββββ
β Socket.IO (30000) β WS (31415) β auto-login
β (modifyDocument) β (Bridge) β (Chrome/Edge)
ββββββββββββββββΌβββββββββββββββββββββββββββββββΌβββββββββΌββββββββ
β FoundryVTT Game Engine β
β ββββββββββββββββββββββββββ βββββββββββββββββββββββββββ β
β β Active World & Data β β Companion Module β β
β β (Actors, Scenes, β¦) β β (foundryvtt-mcp-bridge) β β
β ββββββββββββββββββββββββββ βββββββββββββββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββSocket.IO Primary Connection: Connects to FoundryVTT as an authenticated user (
mcp-api). Automatically synchronizes and caches the world state, enabling instant lookups and high-frequency document mutations via themodifyDocumentprotocol.Companion Module Bridge (
foundryvtt-mcp-bridge): A lightweight Foundry module running in a browser that executes canvas-bound operations (PIXI canvas screenshot with grid overlay, nativeRollchat card rendering, document schema introspection, and compendium item extraction). It only activates for a GM/Assistant-GM user β Foundry itself restricts pausing the game and uploading files to that tier, and a Player's canvas is fog-of-war-limited.Automatic Headless GM Session: The server drives its own invisible, background browser tab (via
playwright-core, reusing whatever Chrome/Edge is already installed β no download required) that logs in as the samemcp-apiaccount and hosts the module above. This means a human can play the game as a normal Player in their own visible client while the AI has full GM-tier canvas access through this separate, invisible session β no manual second browser tab required. A watchdog polls the bridge's own connectivity independently of the Foundry login state and force-reloads the tab to recover a dropped module WebSocket (the module's own reconnect logic gives up permanently after ~85 minutes) β self-healing without a server restart. Falls back gracefully (canvas-only tools report unavailable) if no browser is found; a manually-opened GM tab still works as before if preferred (setFOUNDRY_HEADLESS_GM_ENABLED=false).Optional REST API Module: Provides server diagnostics, log retrieval, and health reporting when the local REST module is installed.
π Quick Start
1. Prerequisites
Node.js 18+ or Bun
FoundryVTT v11+ / v12+ running an active world
A dedicated Foundry user account with Gamemaster or Assistant GM role
Google Chrome or Microsoft Edge installed (for the automatic headless GM browser session β see below; most desktops already have one)
2. Configure Dedicated Foundry User
In FoundryVTT:
Open Configuration β User Management
Click Create User
Set Username:
mcp-api, Password:mcp(or your choice)Role: Gamemaster (or Assistant GM with write permissions enabled)
Playing as a human while the AI GMs? No extra setup needed. Log into your own Foundry client as a normal Player; the server automatically logs
mcp-apiinto its own invisible background browser session for GM-tier canvas access (screenshots, dice rolls, pausing, uploads). SeeFOUNDRY_HEADLESS_GM_ENABLEDbelow to disable this and use a manually-opened GM browser tab instead.
3. Install the Companion Module (Recommended)
Copy the foundry-module folder from this repo to your FoundryVTT Data/modules/ directory:
# Windows
cp -r foundry-module "%LOCALAPPDATA%/FoundryVTT/Data/modules/foundryvtt-mcp-bridge"
# macOS
cp -r foundry-module "~/Library/Application Support/FoundryVTT/Data/modules/foundryvtt-mcp-bridge"
# Linux
cp -r foundry-module "~/.local/share/FoundryVTT/Data/modules/foundryvtt-mcp-bridge"In FoundryVTT, go to Manage Modules and enable FoundryVTT MCP Bridge.
βοΈ Configuration & Client Setup
Environment Variables
Variable | Required | Default | Description |
| Yes |
| FoundryVTT server URL |
| Yes | β | FoundryVTT user account name |
| Yes | β | FoundryVTT user account password |
| No |
| Enables game-state mutations (walls, actors, tokens, etc.) |
| No |
| Enables WebSocket bridge for canvas screenshots & chat rolls |
| No |
| WebSocket port for the companion module bridge |
| No |
| Auto-launches an invisible GM-tier browser session to host the module bridge β no manual second browser tab needed |
| No |
| Overrides which account the headless session logs in as |
| No |
| Password for the headless session account, if overridden |
| No | β | Explicit Chrome/Edge/Chromium binary path, skipping auto-detection |
| No | β | Local path to Foundry |
| No | β | Optional REST API key for server diagnostics tools |
| No |
| In-memory event log ring buffer capacity |
| No |
| Default long-polling timeout for |
| No |
| Logging verbosity ( |
Claude Desktop Configuration
Add to claude_desktop_config.json:
{
"mcpServers": {
"foundryvtt": {
"command": "node",
"args": ["<PATH_TO_REPO>/dist/index.js"],
"env": {
"FOUNDRY_URL": "http://localhost:30000",
"FOUNDRY_USERNAME": "mcp-api",
"FOUNDRY_PASSWORD": "mcp",
"FOUNDRY_WRITE_ENABLED": "true",
"FOUNDRY_MODULE_BRIDGE_ENABLED": "true",
"FOUNDRY_MODULE_BRIDGE_PORT": "31415"
}
}
}
}Oh My Pi Configuration
Add to ~/.omp/agent/mcp.json (or ~/.omp/mcp.json):
{
"mcpServers": {
"foundryvtt": {
"type": "stdio",
"command": "node",
"args": ["<PATH_TO_REPO>/dist/index.js"],
"env": {
"FOUNDRY_URL": "http://localhost:30000",
"FOUNDRY_USERNAME": "mcp-api",
"FOUNDRY_PASSWORD": "mcp",
"FOUNDRY_WRITE_ENABLED": "true",
"FOUNDRY_MODULE_BRIDGE_ENABLED": "true",
"FOUNDRY_MODULE_BRIDGE_PORT": "31415"
},
"timeout": 60000
}
}
}π οΈ Tool Catalog (111 Tools)
1. Real-Time Event Awareness
watch_eventsβ long-poll a cursor-addressed activity log (cursor,waitMs,limit,kinds,types,actions,sceneId,excludeSelf) capturing document broadcasts and canvas activity without polling.
2. Canvas & Spatial Placeables
create_region/delete_region/list_regionsβ manage Scene Regions (v12+) with geometric shapes (rectangle,circle,ellipse,polygon) and automated behaviors.create_wall/delete_wall/list_walls/set_door_stateβ complete wall and door geometry management.create_light/update_light/delete_light/list_lightsβ ambient lighting control (radii, colors, animations).create_sound/delete_sound/list_soundsβ ambient audio placement on canvas scenes.create_template/delete_template/list_templatesβ spell and effect area-of-effect templates.create_drawing/delete_drawing/list_drawingsβ map shapes, zones, and text annotations.create_note/delete_note/list_notesβ map pins and landmark markers.create_tile/delete_tile/list_tilesβ decorative tiles and map props.capture_sceneβ screenshot the active scene canvas with a grid coordinate overlay burned in.ping_canvasβ emit an animated canvas ping at specific pixel coordinates.find_open_cellsβ scan scenes for unblocked grid cells suitable for token/prop placement.list_scene_assetsβ discover map backgrounds, token art, and audio files with parsed tags and dimensions.upload_assetβ upload image/audio files into Foundry'sData/directory via FilePicker or local filesystem.
3. Tokens & Movement
spawn_tokenβ place actor tokens on scenes with custom size, elevation, and coordinates.delete_tokenβ remove tokens from scenes without deleting the underlying actor.list_tokensβ list placed tokens on active or specific scenes.move_tokenβ teleport a token to exact pixel coordinates.move_token_pathfindβ move tokens using A* obstacle avoidance around walls with automatic door opening.move_tokensβ batch move multiple tokens simultaneously.set_target/get_targetsβ set and inspect token targeting reticles across connected users.update_token_visionβ configure vision ranges, vision modes, dim/bright emitted lights, and angles.apply_status_effectβ toggle simple status conditions (prone,stunned,blinded,invisible, etc.).
4. Actors & Inventory
create_world_actor/create_full_actor/delete_world_actorβ create and delete actor documents.import_compendium_actorβ import entire NPCs/monsters from compendium packs with embedded items and automatic error recovery.search_actorsβ query actors by name and type with cursor pagination support.get_actor_detailsβ retrieve actor system data, statistics, attributes, and health.update_actor_attributesβ patch nested system data using dot paths (attributes.hp.value,currency.gp).get_actor_inventoryβ list owned items with full system properties.create_actor_itemβ create inline items OR import directly from compendium packs (source: { type: 'compendium', compendiumId, itemId }).update_actor_itemβ apply JSON merge patches to owned items.delete_actor_itemβ delete specific items from actor inventories.create_actor_effect/update_actor_effect/delete_actor_effect/list_actor_effectsβ general-purpose ActiveEffects with mechanical changes (key,mode,value,priority) and durations on top-level or synthetic unlinked token actors.
5. Combat Encounters
start_combatβ create encounters and seed combatants from scene tokens.get_combat_stateβ retrieve combatant turn order, HP, AC, and round number.set_initiativeβ set combatant initiative values and re-order turns.next_turnβ advance the turn tracker (handles round increments and skips defeated combatants).set_pauseβ pause or unpause the game clock.end_combatβ terminate active encounters.
6. World Documents & Organization
list_folders/create_folderβ organize actors, items, journals, and scenes in nested folders.list_macros/create_macro/delete_macroβ manage script and chat macro documents.list_playlists/create_playlist/set_playlist_state/delete_playlistβ audio playlist and sound controls.create_roll_table/delete_roll_table/roll_table/list_roll_tablesβ table creation and result rolling.get_world_setting/set_world_settingβ inspect and modify system/module settings with core protection.set_document_ownershipβ configure granular document permissions (none,limited,observer,owner).get_users/set_user_roleβ list connected users and change permission roles with self-demotion lockout guards.create_journal_entry/get_journal/search_journals/delete_journal_entryβ manage session notes and lore.
7. Scene, Weather & Exploration
create_scene/delete_scene/get_scene_info/switch_sceneβ scene creation and player activation.set_scene_weatherβ set or clear weather effects (rain,snow,fog,"").set_scene_lightingβ ambient darkness levels and global illumination settings.reset_fogβ reset Fog of War exploration on active scenes.
8. Game Mechanics & Bridge Tools
roll_diceβ local mathematical dice formula evaluation.roll_and_postβ evaluates formulas via Foundry's native engine and posts interactive chat cards.lookup_ruleβ search world journals and system compendium packs for rules with snippet previews.get_document_schemaβ introspect game system DataModel schemas for actor and item types.search_compendium_contentβ deep search inside compendium pack documents and journal pages.send_chat_message/get_chat_messagesβ post and read messages from the Foundry chat log.generate_npc/generate_lootβ instant procedural generators.
9. Diagnostics & Logging
get_health_status/get_system_healthβ connection and server health metrics.get_recent_logs/search_logsβ inspect server logs and error stack traces.diagnose_errorsβ analyze recent errors into prioritized resolution suggestions.refresh_world_dataβ force a re-fetch of the cached world state snapshot.
π§ͺ Development & Testing
# Install dependencies
npm install
# Compile TypeScript
npm run build
# Run complete unit test suite (733 tests)
npm test
# Run linter and formatting checks
npm run lint
# Start server in development watch mode
npm run devπ License
This project is licensed under the MIT License.
This server cannot be deployed
Maintenance
Related MCP Connectors
Connect any AI to your Foundry VTT world: actors, combat, dice, journals, tokens, compendiums.
Campaign manager for D&D and TTRPG GMs: your AI reads and writes a live typed campaign database.
Use AI models for chat, image, and video generation from Claude Code and other MCP hosts.
Generate AI images, videos, music, SFX & speech in any AI assistant. Results appear inline in chat.
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.1 npm-
- FlicenseNot gradedqualityCmaintenanceEnables AI-powered campaign management for Foundry Virtual Tabletop through natural language, supporting multiple RPG systems with tools for quest creation, character management, combat resolution, and more.-
- AlicenseNot gradedqualityAmaintenanceEnables AI agents to interact with Foundry Virtual Tabletop, supporting reading world data, managing combat, rolling dice, and updating actor attributes via a sidecar architecture.42 npmMIT
- AlicenseAqualityAmaintenanceEnables AI-powered image generation and curation for Foundry VTT tabletop art, letting users create portraits, tokens, handouts, and scene backgrounds from prompts via a local headless ComfyUI workflow.4MIT