Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

MCP Interface

In addition to the WebSocket protocol, the RPFM Server exposes a Model Context Protocol (MCP) interface at /mcp. This allows AI assistants (such as Claude, Cursor, or any MCP-compatible client) to interact with RPFM using the standard MCP specification.

Transport

The MCP endpoint uses Streamable HTTP transport:

POST http://127.0.0.1:45127/mcp

All MCP clients share one RPFM session, separate from the WebSocket ones, whatever MCP version they use: two MCP clients see the same selected game and open packs. The session is kept as long as it has open packs or unfinished jobs. Otherwise, the server removes it after 5 minutes without tool calls, and the next tool call starts a new one, with nothing loaded.

The MCP session starts with the settings in RPFM’s settings.json, and can’t change them.

How It Differs from WebSocket

AspectWebSocket (/ws)MCP (/mcp)
ProtocolJSON-RPC 2.0MCP (JSON-RPC 2.0)
TransportWebSocketStreamable HTTP
Interaction modelCall methodsCall named tools
Slow operationsReturn a job ID, followed by job.updated notificationsWait up to 45 seconds for the job, then return its state
Session control?session_id= and session.disconnectOne shared session, removed after 5 minutes of inactivity if it has no open packs or unfinished jobs
Intended clientsCustom scripts, GUIsAI assistants and MCP-compatible tools

Every tool calls one method, with the same params and result, so the Methods reference also documents the tools. The tools only cover what’s useful to an assistant: methods made for the UI, like the ones returning whole decoded files, have no tool.

Connecting

Claude Desktop

Add the server to your claude_desktop_config.json:

{
  "mcpServers": {
    "rpfm": {
      "url": "http://127.0.0.1:45127/mcp"
    }
  }
}

Claude Code

claude mcp add --transport http rpfm http://127.0.0.1:45127/mcp

Other MCP Clients

Any MCP client that supports Streamable HTTP transport can connect. Point it to http://127.0.0.1:45127/mcp.

Results and Errors

Tools return their result as structured content, and their params and results are described by JSON schemas in tools/list.

A tool that fails returns a tool error instead of ending the MCP session. Its content has the same code, message and data.kind as a WebSocket error, like pack_not_found or schema_not_loaded.

Jobs

Slow tools (set_game, generate_dependencies_cache, rebuild_dependencies, run_diagnostics, run_search, update_schemas, update_schema_from_assembly_kit, optimize_pack, run_lua_tests) run as jobs. They wait up to 45 seconds and return the state of their job:

  • If it finished, the state includes the result of the tool.
  • If it failed, the tool returns its error, like any other tool that fails.
  • If it’s still running, call wait_for_job with its job ID, as many times as needed. It ends like the tool that started the job.

Other tools called meanwhile wait for the job to end before running, except during run_diagnostics: a running check stops for them, and starts again after them.

Resources

The server also exposes reference data as MCP resources, readable without tool calls:

URIContent
rpfm://gamesKeys of the supported games.
rpfm://enums/PFHFileTypeValid pack types.
rpfm://enums/CompressionFormatValid compression formats.
rpfm://enums/SupportedFormatsValid video formats.
rpfm://reference/initializationHow to set up a session.
rpfm://reference/path_conventionsCommon file paths inside packs.

Typical Workflow

  1. Set the game: set_game with the game key. This loads the schema and the dependencies.
  2. Open a pack: open_pack with the path of the pack, or new_pack. Both return the pack’s key.
  3. Browse files: list_files with the pack as source.
  4. Read data: table_info and table_rows for DB and Loc tables, read_file for anything else.
  5. Modify data: edit_table for tables, write_file for anything else.
  6. Save: save_pack.

Example: Editing a DB Table

Call set_game:

{ "game": "warhammer_3" }

Call open_pack:

{ "paths": ["/path/to/my_mod.pack"] }

The result contains the pack’s key, a UUID like 0b4c5a62-7d3e-4f1a-9c2b-8e6d5f4a3b21, used by the next calls as pack. It never changes while the pack is open, even if it’s saved under another name. session_status lists the keys of all open packs, with their names and paths.

Call table_rows, to get the rows of a unit:

{
  "file": { "source": { "pack": "0b4c5a62-7d3e-4f1a-9c2b-8e6d5f4a3b21" }, "path": "db/land_units_tables/my_mod" },
  "columns": ["key", "num_men"],
  "filters": [{ "column": "key", "op": "equals", "value": "my_unit" }]
}

Each returned row has the index of the row in the table. Call edit_table to change it:

{
  "pack": "0b4c5a62-7d3e-4f1a-9c2b-8e6d5f4a3b21",
  "path": "db/land_units_tables/my_mod",
  "edits": [{ "op": "update", "index": 4, "values": { "num_men": 120 } }]
}

Call save_pack:

{ "pack": "0b4c5a62-7d3e-4f1a-9c2b-8e6d5f4a3b21" }

To change a vanilla table, copy it into your pack first with copy_files, from the "game_files" source.

Tool Reference

The MCP interface exposes 95 tools. The descriptions below are the first sentence of each tool’s description; tools/list has the full descriptions and the JSON schemas of their params.

Session and jobs

ToolMethodDescription
session_statussession.statusGet the state of the session: the selected game, if its schema and dependencies (vanilla files, Assembly Kit tables, parent packs) are loaded, and the open packs with their keys.
set_gamesession.set_gameSelect the game to work with, like warhammer_3, loading its schema and, by default, its dependencies (vanilla files, Assembly Kit tables, parent packs).
job_statusjob.statusGet the state of a job: queued, running (with its current step), finished (with its result), failed (with its error) or cancelled.
wait_for_jobjob.waitWait for a job to end, up to timeout_secs (60 by default), and return its state, or its error if it failed.
cancel_jobjob.cancelCancel a job that hasn’t started yet.

Packs

ToolMethodDescription
pack_infopack.infoGet the details of an open pack: type, format version, compression, encryption flags, the packs it depends on, and its MyMod mode.
pack_settingspack.settingsGet the settings of an open pack, like its diagnostics ignore rules (diagnostics_files_to_ignore), files to ignore when importing, or if it has autosaves disabled.
update_pack_settingspack.update_settingsChange settings of an open pack.
new_packpack.newCreate a new empty pack.
open_packpack.openOpen one or more packs from disk, merged into a single one.
open_vanilla_packspack.open_vanillaOpen all the vanilla packs of the selected game, merged into a single one, to browse them like any open pack.
close_packpack.closeClose an open pack.
close_all_packspack.close_allClose all open packs.
save_packpack.saveSave an open pack to disk, to its current path or to a new path.
update_packpack.updateChange properties of an open pack: type, compression, encryption and timestamp flags, the packs it depends on, and its MyMod mode.

Files

ToolMethodDescription
list_filesfiles.listList the files of an open pack, the game files, the parent packs, or the Assembly Kit tables, sorted by path.
read_filefile.readRead a file of an open pack, the game files or the parent packs: as text for scripts, XML, JSON and other text files; as decoded JSON for structured formats (portrait settings, unit variants, models, etc.); or as raw base64 bytes, best for images and other binary files.
write_filefile.writeReplace the contents of a file of an open pack: text for text files, decoded JSON in the format read_file returns, or raw base64 bytes (which also creates the file if it doesn’t exist).
list_animpackanimpack.listList the files inside an AnimPack of an open pack, the game files or the parent packs.
add_to_animpackanimpack.addCopy files of an open pack into an AnimPack of an open pack.
extract_from_animpackanimpack.extractCopy files of an AnimPack of any source into an open pack.
delete_from_animpackanimpack.deleteDelete files from an AnimPack of an open pack.
create_filefiles.createCreate a new empty file in an open pack: a DB table (with the version of the game files by default), a Loc table, a text file or an AnimPack.
add_files_from_diskfiles.add_from_diskAdd files and folders from disk to an open pack, under a folder of the pack.
copy_filesfiles.copyCopy files and folders from an open pack, the game files, the parent packs or the Assembly Kit tables into an open pack, keeping their paths.
delete_filesfiles.deleteDelete files and folders from an open pack.
rename_filesfiles.renameRename or move files and folders of an open pack.
duplicate_filesfiles.duplicateCopy files of an open pack in the same pack, adding a number to their names.
extract_filesfiles.extractExtract files and folders of an open pack, the game files or the parent packs to a folder on disk, optionally with tables as TSV.

Tables

ToolMethodDescription
table_infotable.infoGet the columns (name, type, key, referenced table without its _tables suffix and column, lookups, default value, file paths, description, if unused) and the row count of a DB or Loc table, from any source.
table_rowstable.rowsRead rows of a DB or Loc table, from any source, as plain values (booleans, numbers and strings).
column_valuestable.column_valuesGet the distinct values of a column of a table, like all the faction keys of factions_tables, from the open packs and the dependencies, sorted.
unused_numberstable.unused_numbersGet numbers no row uses yet in an integer column of a table, like unique_index of main_units_tables, for new rows that need unique ones.
merge_tablestable.mergeMerge tables of the same type of an open pack into a new one.
upgrade_tabletable.upgradeUpdate a table of an open pack to the version it has in the game files, after a game update.
rename_keytable.rename_keyChange a key value of a table in every table of an open pack: the key itself, the columns referencing it, and the loc keys generated from it.
add_key_deletestable.add_key_deletesAdd keys to a key deletes table (db/twad_key_deletes_tables/<file_name>) of an open pack, to delete those keys of a table in the game.
export_tsvtable.export_tsvWrite a table of an open pack, the game files or the parent packs to a TSV file, to edit it in a spreadsheet.
import_tsvtable.import_tsvReplace a table of an open pack with the contents of a TSV file, keeping its GUID.
edit_tabletable.editEdit rows of a DB or Loc table in an open pack: insert, update and delete rows by index, with values given by column name (see table_info for the columns).

Schema

ToolMethodDescription
table_definitionschema.definitionGet the columns of a table as defined in the schema, without needing a file of it.
schema_tablesschema.tablesList the tables of the selected game’s schema whose name starts with a prefix, with the versions it has definitions for, newest first.
patch_columnschema.patch_columnChange how the schema describes a column with a local patch: description, if it’s a key, default value, referenced table and column (is_reference as table;column), if it holds file paths, if it can’t be empty, or if it’s unused.
remove_patchesschema.remove_patchesRemove the local schema patches of a table, or of one of its columns.
update_schemasschema.updateDownload the latest schemas, reload the selected game’s one, and rebuild the dependencies.
update_schema_from_assembly_kitschema.update_from_assembly_kitUpdate the selected game’s schema with the table definitions of its Assembly Kit, and save it.
raw_definitionsschema.raw_definitionsGet the definitions of a table as the schema stores them, to edit them with set_definition.
set_definitionschema.set_definitionAdd a definition to the selected game’s schema, or replace the one with its version, then save and reload the schema.
delete_definitionschema.delete_definitionRemove a definition from the selected game’s schema, then save and reload the schema.
referencing_columnsschema.referencing_columnsGet the columns of other tables referencing each column of a table, according to the schema.
table_patchesschema.patchesGet the patches applied to the columns of a table definition: the local ones made with patch_column, and the ones included in the schema.
missing_definitionsschema.missing_definitionsList the tables of an open pack with rows the schema can’t decode, which need a new definition.
import_patchesschema.import_patchesAdd patches to the selected game’s schema itself, and save it.

Dependencies

ToolMethodDescription
generate_dependencies_cachedependencies.generate_cacheGenerate the dependencies cache of the selected game from its files and Assembly Kit, and load it.
rebuild_dependenciesdependencies.rebuildReload the dependencies of the selected game, like after changing the packs the open packs depend on.
dependency_tablesdependencies.tablesList the tables of the selected game’s files, and the startpos and twad tables of its schema, with the version new tables of each type should use.

References

ToolMethodDescription
find_definitionreferences.definitionFind the row where a value of a referenced table is defined, like the row of factions_tables with a faction key.
find_usagesreferences.usagesFind the rows of other tables referencing a value of a table, like everything using a faction key.
find_locreferences.locFind the row of a Loc file with a key.
row_locsreferences.row_locsGet the loc entries of a row of a DB table, from any source: the loc key of each of its localised columns, like land_units_onscreen_name_my_unit for onscreen_name, with its text, or null if no Loc file has it.
loc_sourcereferences.loc_sourceGet the table, localised column and key values a loc key belongs to, like factions_tables, screen_name and ["wh_main_emp_empire"] for factions_screen_name_wh_main_emp_empire.
reference_valuesreferences.valuesGet the values a reference column of a table can have, with their display text (like the name of each referenced row), from the open packs and the dependencies.
ToolMethodDescription
run_diagnosticsdiagnostics.runCheck the open packs for problems (invalid references, duplicated keys, outdated tables, script errors, etc.), and return a summary by level and type.
list_diagnosticsdiagnostics.listList results of the last run_diagnostics, filtered by level, report type, pack and path prefix, in pages (100 by default; the total of matching results is always returned).
ignore_diagnosticsdiagnostics.ignoreMake the next diagnostics checks of a pack skip results of files under a path, optionally only for some columns and report types.
run_searchsearch.runSearch text (or a regex) in open packs, the game files, the parent packs, the Assembly Kit tables, or the schema’s column names, and return a summary of the matches by file type.
list_search_matchessearch.matchesList matches of the last run_search, filtered by file type and path prefix, in pages (100 by default; the total of matching matches is always returned).
replace_search_matchessearch.replaceReplace matches of the last run_search by ID, or all of them, with a text.
run_lua_testslua.run_testsRun Lua tests against the scripts of all open packs, outside of the game.

Notes

ToolMethodDescription
list_notesnotes.listGet the notes (comments) attached to a file or folder of an open pack, or all of them.
add_notenotes.addAttach a note (comment, with an optional link) to a file or folder of an open pack, or replace one by passing its id.
delete_notenotes.deleteDelete a note of an open pack.

Translations

ToolMethodDescription
list_translationstranslations.listGet the translation of the texts of an open pack to a language, reusing vanilla and previous translations.
generate_vanilla_textstranslations.generate_vanillaGenerate the vanilla texts of a language from the game’s locale packs, so translations to and from it can reuse them.

Tools

ToolMethodDescription
optimizer_optionstools.optimizer_optionsGet the optimizer options as the server’s settings have them, by name.
patch_siege_aitools.patch_siege_aiPatch the siege maps of an open pack so the AI can use them.
pack_maptools.pack_mapAdd the tiles and tile maps of a map exported by Terry to an open pack.
generate_missing_locstools.generate_missing_locsAdd empty loc entries for the localised columns of the tables of the open packs that don’t have them yet.
update_anim_idstools.update_anim_idsOffset the animation ids of an open pack from a starting id, like after a game update moves them.
anims_by_skeletontools.anims_by_skeletonGet the paths of the animations using a skeleton, in the open packs and the dependencies.
export_gltftools.export_gltfExport a RigidModel of any source to a glTF file, with its textures.
set_video_formattools.set_video_formatChange the format of a ca_vp8 video of an open pack: CaVp8 or Ivf.
live_exporttools.live_exportExport the scripts and UI files of an open pack to the game’s data folder, to test them without saving the pack.
init_mymodtools.init_mymodCreate the folder of a new MyMod in the MyMods folder of the settings, with optional editor configs for Lua scripting and a git repository.
startpos_campaignsstartpos.campaignsGet the campaigns a startpos can be built for, and the one the pack’s last startpos was built for.
start_startposstartpos.startStart building a startpos for a campaign with the tables of an open pack: prepares the Assembly Kit and launches the game.
finish_startposstartpos.finishFinish building a startpos after the game was closed: imports it into the pack, or cancels the build with cancel: true.
validate_startposstartpos.validateCheck the tables a campaign’s startpos is built from: broken references and data that make the game’s build fail, hang or drop rows.
generate_startposstartpos.generateGenerate the startpos of a campaign from the tables of an open pack and the game’s files, without launching the game, and add it to the pack.
extract_startpos_tablesstartpos.extract_tablesExtract the start_pos tables and victory objectives of a campaign from its startpos (the pack’s, or the game’s) and add them to the pack.
keep_startpos_campaignstartpos.keep_campaignRemove the rows of an open pack’s start_pos tables that don’t belong to a campaign, as the Assembly Kit does before building a startpos, so tables holding several campaigns don’t break the build.
compare_startpos_tablesstartpos.compare_tablesCompare the tables extracted from a campaign’s startpos with the tables it’s built from, to find what the build loses or changes.
optimize_packtools.optimizeRemove data of an open pack that’s identical to vanilla or unneeded (duplicated rows, unchanged rows and files, empty tables, etc.).

Updates

ToolMethodDescription
check_updateupdates.checkCheck if there is an update of RPFM (program), the schemas, the Lua type definitions (lua_autogen), the Empire and Napoleon Assembly Kit data (old_assembly_kit), or the community translations.
apply_updateupdates.applyDownload the update of the Lua type definitions (lua_autogen), the Empire and Napoleon Assembly Kit data (old_assembly_kit), the community translations, or RPFM itself (program, which replaces its files and needs a restart: only do it if the user asks).