Foundryvtt MCP
A Model Context Protocol (MCP) server that integrates with FoundryVTT, allowing AI assistants to interact with your tabletop gaming sessions. Query actors, roll dice, generate content, and manage your game world through natural language.
Installation
npx foundryvtt-mcpAsk AI about Foundryvtt MCP
Powered by Claude Β· Grounded in docs
I know everything about Foundryvtt MCP. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Reviews
Documentation
FoundryVTT MCP Server
A Model Context Protocol (MCP) server that integrates with FoundryVTT, allowing AI assistants to interact with your tabletop gaming sessions through natural language.
Features
- Dice Rolling β standard RPG notation with any formula
- Data Querying β search and inspect actors, items, scenes, journals
- Game State β combat tracking, chat messages, user presence
- Content Generation β NPCs, loot tables, rule lookups
- World Search β full-text search across all game entities
- Live Connection β Socket.IO loads complete world state on connect
- MCP Resources β
foundry://URIs for direct data access - Diagnostics β optional server health monitoring (requires REST API module)
Quick Start
Prerequisites
- Node.js 18+ (or Bun)
- FoundryVTT server running with an active world
- MCP-compatible AI client (Claude Desktop, Claude Code, VS Code, etc.)
Recommended: Create a Dedicated API User
It is recommended to create a separate FoundryVTT user account for the MCP server rather than using your own GM or player account. This provides better security and auditability.
In FoundryVTT:
- Go to Configuration β User Management
- Click Create User
- Set a username (e.g.,
mcp-api) and a strong password - Assign the Assistant GM role (needed to read world data and roll dice)
- Use this account's credentials in your MCP configuration
Benefits:
- Chat messages and actions from the MCP server are clearly attributed to a separate user
- You can revoke access by disabling the API user without affecting your own account
- Limits blast radius if credentials are ever exposed
Installation
Run directly without installing β no clone needed:
bunx foundryvtt-mcp
Or with npx:
npx -y foundryvtt-mcp
Client Configuration
Claude Desktop / Claude Code
Add to your MCP configuration (claude_desktop_config.json or .mcp.json):
{
"mcpServers": {
"foundryvtt": {
"command": "bunx",
"args": ["foundryvtt-mcp"],
"env": {
"FOUNDRY_URL": "http://localhost:30000",
"FOUNDRY_USERNAME": "your_username",
"FOUNDRY_PASSWORD": "your_password"
}
}
}
}
VS Code
Add to your VS Code MCP settings:
{
"servers": {
"foundryvtt": {
"command": "bunx",
"args": ["foundryvtt-mcp"],
"env": {
"FOUNDRY_URL": "http://localhost:30000",
"FOUNDRY_USERNAME": "your_username",
"FOUNDRY_PASSWORD": "your_password"
}
}
}
}
Development Setup
For local development or contributing:
git clone https://github.com/laurigates/foundryvtt-mcp.git
cd foundryvtt-mcp
bun install
bun run setup-wizard
The setup wizard will detect your FoundryVTT server, test connectivity, and generate your .env configuration.
To configure manually, see the Configuration Guide.
Environment Variables
| Variable | Required | Description |
|---|---|---|
FOUNDRY_URL | Yes | FoundryVTT server URL (e.g., http://localhost:30000) |
FOUNDRY_USERNAME | Yes | FoundryVTT user account |
FOUNDRY_PASSWORD | Yes | FoundryVTT user password |
FOUNDRY_USER_ID | No | Bypass username-to-ID resolution |
FOUNDRY_API_KEY | No | REST API module key (enables diagnostics tools) |
LOG_LEVEL | No | debug, info, warn, or error (default: info) |
FOUNDRY_TIMEOUT | No | Request timeout in ms (default: 10000) |
Usage
Ask your AI assistant things like:
- "Roll 1d20+5 for an attack roll"
- "Show me all the NPCs in this scene"
- "What's the current combat initiative order?"
- "Search the world for anything related to dragons"
- "Generate a random NPC merchant"
Available Tools
Data Access
search_actorsβ find characters, NPCs, monstersget_actor_detailsβ detailed character informationsearch_itemsβ find equipment, spells, consumablesget_scene_infoβ current scene detailssearch_journalsβ search notes and handoutsget_journalβ retrieve a specific journal entryget_usersβ list online users and their statusget_combat_stateβ combat state and initiative orderget_chat_messagesβ recent chat history
World
search_worldβ full-text search across all game entitiesget_world_summaryβ overview of the current world staterefresh_world_dataβ reload world data from FoundryVTT
Game Mechanics
roll_diceβ roll dice with any formulalookup_ruleβ game rules and spell descriptions
Content Generation
generate_npcβ create random NPCsgenerate_lootβ create treasure appropriate for level
Diagnostics (requires REST API module)
get_recent_logsβ retrieve filtered FoundryVTT logssearch_logsβ search logs with regex patternsget_system_healthβ server performance and health metricsdiagnose_errorsβ analyze errors with troubleshooting suggestionsget_health_statusβ comprehensive health diagnostics
Available Resources
foundry://actorsβ all actors in the worldfoundry://itemsβ all items in the worldfoundry://scenesβ all scenesfoundry://scenes/currentβ current active scenefoundry://journalsβ all journal entriesfoundry://usersβ online usersfoundry://combatβ active combat statefoundry://world/settingsβ world and campaign settingsfoundry://system/diagnosticsβ system diagnostics (requires REST API module)
Troubleshooting
bunx foundryvtt-mcp test-connection # Test FoundryVTT connectivity
bunx foundryvtt-mcp setup-wizard # Re-run interactive setup
Detailed guide: TROUBLESHOOTING.md
Development
bun run build # Compile TypeScript
bun run dev # Development mode with hot reload
bun test # Unit tests (Vitest)
bun run test:e2e # E2E tests (Playwright)
bun run lint # Lint code (Biome)
See Development Guide for project structure, adding tools, testing, and building.
Roadmap
See Feature Tracker for completed and planned features.
Contributing
See CONTRIBUTING.md.
License
MIT License β see LICENSE for details.
Support
- Issues: GitHub Issues
- Discord: FoundryVTT Discord #api-development
- Docs: FoundryVTT API
Acknowledgments
- FoundryVTT team for the excellent VTT platform
- Anthropic for the Model Context Protocol
- The tabletop gaming community for inspiration and feedback
