foundry-cli
MCP server for managing Foundry VTT journal content (entries, categories, pages) and listing actors, enabling AI-assisted world-building via natural language commands.
README
foundry-cli
CLI and MCP server for managing Foundry VTT world content via Socket.io. Targets Foundry v14.
Scope
This tool manages the journal layer of a Foundry world: journal entries, their categories, and their pages. It also lists actors. It is intentionally narrow — no scene management, no compendium access, no system-specific mechanics.
The primary use case is AI-assisted world-building: an LLM writes lore entries via the MCP server while a GM reviews them in the Foundry UI in real time.
Setup
Requirements: Python 3.12+, uv, a running Foundry v14 instance with an active world.
git clone <repo>
cd foundry-cli
cp .env.example .env # fill in credentials
.env keys:
| Key | Description |
|---|---|
FOUNDRY_URL |
Base URL of the Foundry instance, e.g. https://foundry.example.com |
FOUNDRY_BASIC_USER |
HTTP Basic Auth username (if Foundry is behind a proxy) |
FOUNDRY_BASIC_PASS |
HTTP Basic Auth password |
FOUNDRY_WORLD |
The world name that must be active |
FOUNDRY_GM_USER |
Foundry user to authenticate as (must have GM role) |
FOUNDRY_GM_PASSWORD |
Password for that user |
CLI usage
uv run python foundry.py [COMMAND] --help
Actors
foundry actor list [--json]
Journals
foundry journal list [--json]
foundry journal upsert --title NAME [--folder FOLDER] [--public]
foundry journal delete --title NAME
Categories
Categories are named tabs that group pages within a journal. Create them before assigning pages.
foundry journal category list --journal NAME [--json]
foundry journal category upsert --journal NAME --name NAME
foundry journal category delete --journal NAME --name NAME
Pages
foundry journal page list --journal NAME [--json]
foundry journal page upsert --journal NAME --title NAME
[--category NAME] [--level 1-6]
[--before TITLE | --after TITLE]
[--public]
[--content HTML | --content-file PATH | stdin]
foundry journal page reorder --journal NAME # titles from stdin, one per line
foundry journal page delete --journal NAME --title NAME
Content input — exactly one of:
--content '<p>HTML</p>'— inline string--content-file path/to/page.html— read from file- stdin — pipe HTML directly:
cat page.html | foundry journal page upsert ...
Positioning — --before TITLE / --after TITLE insert the page relative to an existing page within the same category. All pages in the category are reindexed with clean sort values.
Level — controls sidebar indentation (1 = top-level, 2 = indented beneath the preceding level-1 page).
--public — sets OBSERVER ownership so players can see the entry/page. Default is INHERIT (follows the parent journal).
All upsert operations are idempotent — matched by name, safe to re-run.
Example workflow
# Create journal and categories
foundry journal upsert --title "Ravens — Lore"
foundry journal category upsert --journal "Ravens — Lore" --name "Settlements"
foundry journal category upsert --journal "Ravens — Lore" --name "NPCs"
# Add pages
echo "<p>A walled city on the northern coast.</p>" | \
foundry journal page upsert \
--journal "Ravens — Lore" --title "Thornwall" \
--category "Settlements" --level 1
echo "<p>The merchant district.</p>" | \
foundry journal page upsert \
--journal "Ravens — Lore" --title "Thornwall — Docks Quarter" \
--category "Settlements" --level 2 --after "Thornwall"
# Reorder pages
printf "Thornwall\nThornwall — Docks Quarter\nThornwall — Temple Quarter\n" | \
foundry journal page reorder --journal "Ravens — Lore"
MCP server
The MCP server exposes the same operations as tools so LLMs can manage journal content directly.
uv run python foundry_mcp.py
Register in an MCP client config:
{
"mcpServers": {
"foundry": {
"command": "uv",
"args": ["run", "python", "/path/to/foundry_mcp.py"]
}
}
}
Available tools: actor_list, journal_list, journal_upsert, journal_delete, category_list, category_upsert, category_delete, page_list, page_upsert, page_reorder, page_delete.
Testing
Tests run against a real Foundry instance spun up via Docker Compose. The test fixture starts the container, waits for the world to become active, then runs against it.
uv run pytest
The Docker environment lives in docker/. Tests create journals with a _pytest_ prefix and clean up on teardown.
Architecture vs foundryvtt-mcp
foundryvtt-mcp is a JavaScript MCP server that runs inside Foundry as a module, calling the Foundry API directly from within the same process.
This project takes the opposite approach:
| foundry-cli | foundryvtt-mcp | |
|---|---|---|
| Runtime | External Python process | Foundry module (in-process JS) |
| Protocol | Socket.io modifyDocument |
Direct Foundry API calls |
| Install footprint | Nothing installed in Foundry | Requires a Foundry module |
| Interface | CLI + MCP server | MCP server only |
| Scope | Journals and actors | Broader (scenes, actors, items, …) |
Why Socket.io instead of a Foundry module?
- No Foundry module to maintain across Foundry version updates — the Socket.io wire protocol is stable.
- Works with a remote or hosted Foundry instance without SSH or file system access.
- The CLI is useful on its own for scripting and automation, independent of any AI tooling.
Trade-offs: The Socket.io modifyDocument API is not officially documented for external use, so it may break across major Foundry versions. Operations are limited to what that API surface exposes — complex queries or compendium access require a different approach.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。