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 programmatically using the standard MCP specification.

Transport

The MCP endpoint uses Streamable HTTP transport:

POST http://127.0.0.1:45127/mcp

Each MCP connection gets its own RPFM session, just like WebSocket connections.

How It Differs from WebSocket

AspectWebSocket (/ws)MCP (/mcp)
ProtocolCustom JSON messages with id/data envelopeStandard MCP (JSON-RPC 2.0)
TransportWebSocketStreamable HTTP
Interaction modelSend Command, receive ResponseCall named tools, receive JSON results
Session controlManual via ?session_id= and ClientDisconnectingManaged automatically by the MCP transport
Intended clientsCustom scripts, GUIsAI assistants and MCP-compatible tools

Both interfaces expose the same underlying functionality — every MCP tool maps to an internal Command and returns its Response serialized as JSON.

Connecting

Claude Desktop

Add the server to your claude_desktop_config.json:

{
  "mcpServers": {
    "rpfm": {
      "url": "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.

Tool Reference

The MCP interface exposes 145 tools organized by category. Each tool accepts typed JSON arguments and returns the server’s Response serialized as JSON text.

Generic

ToolDescriptionArguments
call_commandCall any IPC command directly (for commands not yet wrapped as named tools)command: JSON string of the Command enum

Pack Lifecycle

ToolDescriptionKey Arguments
new_packCreate a new empty PackFile(none)
open_packfilesOpen one or more PackFilespaths: file paths
save_packfileSave a packpack_key
close_packClose a pack without savingpack_key
save_pack_asSave a pack to a new pathpack_key, path
clean_and_save_pack_asSave a clean copy (use if normal save fails)pack_key, path
trigger_backup_autosaveTrigger a backup autosavepack_key
load_all_ca_pack_filesOpen all vanilla CA PackFiles for the selected game(none)
list_open_packsList all open packs with their keys and metadata(none)

Pack Metadata

ToolDescriptionKey Arguments
set_pack_file_typeSet the pack type (PFHFileType as JSON)pack_key, pack_file_type
change_compression_formatChange compression formatpack_key, format
change_index_includes_timestampToggle timestamp in pack indexpack_key, value
get_pack_file_pathGet the file path of a packpack_key
get_pack_file_nameGet the file name of a packpack_key
get_pack_settingsGet pack settingspack_key
set_pack_settingsSet pack settings (PackSettings as JSON)pack_key, settings
get_dependency_pack_files_listGet dependency pack listpack_key
set_dependency_pack_files_listSet dependency pack listpack_key, list

File Operations

ToolDescriptionKey Arguments
decode_packed_fileDecode a file from a packpack_key, path, source
new_packed_fileCreate a new file inside a packpack_key, path, new_file
add_packed_filesAdd files from disk to a packpack_key, source_paths, destination_paths
add_packed_files_from_pack_fileAdd files from another PackFilepack_key, source_pack_path, container_paths
add_packed_files_from_pack_file_to_animpackAdd files to an AnimPackpack_key, animpack_path, container_paths
add_packed_files_from_animpackAdd files from an AnimPackpack_key, source, animpack_path, container_paths
delete_packed_filesDelete files from a packpack_key, paths
delete_from_animpackDelete files from an AnimPackpack_key, animpack_path, container_paths
extract_packed_filesExtract files to diskpack_key, source_paths, destination_path, export_as_tsv
rename_packed_filesRename files in a packpack_key, renames
save_packed_file_from_viewSave an edited decoded file backpack_key, path, data
save_packed_file_from_external_viewSave a file from an external programpack_key, internal_path, external_path
save_packed_files_to_pack_file_and_cleanSave files and optionally optimizepack_key, files, optimize
get_packed_file_raw_dataGet raw binary data of a filepack_key, value
open_packed_file_in_external_programOpen a file in an external programpack_key, source, container_path
open_containing_folderOpen the pack’s folder in file managerpack_key
clean_cacheClean the decode cachepack_key, paths
folder_existsCheck if a folder exists in a packpack_key, value
packed_file_existsCheck if a file exists in a packpack_key, value
get_packed_files_infoGet info of one or more filespack_key, values
get_rfile_infoGet info of a single filepack_key, value

Game Selection

ToolDescriptionKey Arguments
get_game_selectedGet the currently selected game(none)
set_game_selectedSet the current gamegame_name, rebuild_dependencies

Dependencies

ToolDescriptionKey Arguments
generate_dependencies_cacheGenerate the dependencies cache(none)
rebuild_dependenciesRebuild dependenciesvalue (true = full)
is_there_a_dependency_databaseCheck if a dependency database is loadedvalue
get_table_list_from_dependency_pack_fileGet table names from dependency packs(none)
get_custom_table_listGet custom table names from schema(none)
get_table_version_from_dependency_pack_fileGet table version from dependenciesvalue
get_table_definition_from_dependency_pack_fileGet table definition from dependenciesvalue
get_tables_from_dependenciesGet table data by namevalue
import_dependencies_to_open_pack_fileImport files from dependenciespack_key, paths
get_rfiles_from_all_sourcesGet files from all sourcespaths, lowercase
get_packed_files_names_starting_with_path_from_all_sourcesGet file names under a pathpath
local_art_set_idsGet local art set IDspack_key
dependencies_art_set_idsGet art set IDs from dependencies(none)
ToolDescriptionKey Arguments
global_searchRun a global searchpack_key, search
global_search_replace_matchesReplace specific matchespack_key, search, matches
global_search_replace_allReplace all matchespack_key, search
search_referencesFind all references to a valuepack_key, reference_map, value
get_reference_data_from_definitionGet reference data for columnspack_key, table_name, definition, force
go_to_definitionGo to a reference’s definitionpack_key, table_name, column_name, values
go_to_locGo to a loc key’s locationpack_key, value
get_source_data_from_loc_keyGet source data of a loc keypack_key, value

Schema

ToolDescriptionKey Arguments
save_schemaSave a schema to diskschema
update_current_schema_from_asskitUpdate schema from Assembly Kit(none)
update_schemasUpdate schemas from remote repository(none)
is_schema_loadedCheck if a schema is loaded(none)
get_schemaGet the current schema(none)
definitions_by_table_nameGet definitions for a tablevalue
definition_by_table_name_and_versionGet a definition by name and versionname, version
delete_definitionDelete a definitionname, version
referencing_columns_for_definitionGet columns referencing a tabletable_name, definition
fields_processedGet processed fields from a definitiondefinition
save_local_schema_patchSave local schema patchespatches
remove_local_schema_patches_for_tableRemove patches for a tablevalue
remove_local_schema_patches_for_table_and_fieldRemove patches for a fieldkey, value
import_schema_patchImport a schema patchpatches

Table Operations

ToolDescriptionKey Arguments
merge_filesMerge compatible tables into onepack_key, paths, merged_path, delete_source
update_tableUpdate a table to a newer versionpack_key, value
cascade_editionCascade edit across referenced datapack_key, table_name, definition, changes
get_tables_by_table_nameGet table paths by namepack_key, value
add_keys_to_key_deletesAdd keys to key_deletes tablepack_key, table_file_name, key_table_name, keys
export_tsvExport a table to TSVpack_key, tsv_path, table_path
import_tsvImport a TSV file to a tablepack_key, tsv_path, table_path

Diagnostics

ToolDescriptionKey Arguments
diagnostics_checkRun a full diagnostics checkignored, check_ak_only_refs
diagnostics_updateUpdate diagnostics for changed filesdiagnostics, paths, check_ak_only_refs
add_line_to_pack_ignored_diagnosticsAdd to ignored diagnosticspack_key, value
get_missing_definitionsExport missing table definitionspack_key

Notes

ToolDescriptionKey Arguments
notes_for_pathGet notes under a pathpack_key, value
add_noteAdd a notepack_key, note
delete_noteDelete a notepack_key, path, id

Optimization

ToolDescriptionKey Arguments
optimize_pack_fileOptimize a packpack_key, options
get_optimizer_optionsGet default optimizer options(none)

Updates

ToolDescription
check_updatesCheck for RPFM updates
check_schema_updatesCheck for schema updates
check_lua_autogen_updatesCheck for Lua autogen updates
check_empire_and_napoleon_ak_updatesCheck for Empire/Napoleon AK updates
check_translations_updatesCheck for translation updates
update_lua_autogenUpdate Lua autogen
update_main_programUpdate the program
update_empire_and_napoleon_akUpdate Empire/Napoleon AK files
update_translationsUpdate translations

Settings

ToolDescriptionKey Arguments
settings_get_boolGet a boolean settingvalue (key)
settings_get_i32Get an i32 settingvalue (key)
settings_get_f32Get an f32 settingvalue (key)
settings_get_stringGet a string settingvalue (key)
settings_get_path_bufGet a PathBuf settingvalue (key)
settings_get_vec_stringGet a Vec<String> settingvalue (key)
settings_get_vec_rawGet a raw bytes settingvalue (key)
settings_get_allGet all settings at once(none)
settings_set_boolSet a boolean settingkey, value
settings_set_i32Set an i32 settingkey, value
settings_set_f32Set an f32 settingkey, value
settings_set_stringSet a string settingkey, value
settings_set_path_bufSet a PathBuf settingkey, value
settings_set_vec_stringSet a Vec<String> settingkey, value
settings_set_vec_rawSet a raw bytes settingkey, value
backup_settingsBackup settings to memory(none)
clear_settingsClear all settings(none)
restore_backup_settingsRestore settings from backup(none)

Path Queries

ToolDescription
config_pathGet the config path
assembly_kit_pathGet the Assembly Kit path
backup_autosave_pathGet the backup autosave path
old_ak_data_pathGet the old AK data path
schemas_pathGet the schemas path
table_profiles_pathGet the table profiles path
translations_local_pathGet the translations local path
dependencies_cache_pathGet the dependencies cache path
settings_clear_pathClear a config path

Specialized

ToolDescriptionKey Arguments
open_pack_infoGet pack info and file listpack_key
initialize_my_mod_folderInitialize a MyMod foldername, game, sublime, vscode, gitignore
live_exportLive export a pack for testingpack_key
patch_siege_aiPatch SiegeAI for Warhammer mapspack_key
pack_mapPack map tilespack_key, tile_maps, tiles
generate_missing_loc_dataGenerate missing loc entriespack_key
get_pack_translationGet translation datapack_key, language
build_starpos_get_campaign_idsGet campaign IDs for starpospack_key
build_starpos_check_victory_conditionsCheck victory conditions filepack_key
build_starposBuild starpos (pre-processing)pack_key, campaign_id, process_hlp_spd
build_starpos_postBuild starpos (post-processing)pack_key, campaign_id, process_hlp_spd
build_starpos_cleanupClean up starpos temp filespack_key, campaign_id, process_hlp_spd
update_anim_idsUpdate animation IDspack_key, starting_id, offset
get_anim_paths_by_skeleton_nameGet anim paths by skeletonvalue
export_rigid_to_gltfExport RigidModel to glTFrigid_model, output_path
set_video_formatChange video formatpack_key, path, format

Response Format

All MCP tool responses are JSON-serialized versions of the server’s internal Response enum. The same serialization convention applies — refer to the Responses page for the full list of response types and their payloads.

Typical Workflow

A typical MCP session follows this pattern:

  1. Set the game: set_game_selected with the game key and rebuild_dependencies: true
  2. Open a pack: open_packfiles with the file path(s)
  3. Browse files: open_pack_info to get the pack’s file tree
  4. Read data: decode_packed_file to decode individual files
  5. Modify data: save_packed_file_from_view to save edited data back
  6. Save: save_packfile to write changes to disk

Example: Reading a DB Table

Call set_game_selected:

{ "game_name": "warhammer_3", "rebuild_dependencies": true }

Call open_packfiles:

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

The response contains the pack_key — use it in subsequent calls:

Call decode_packed_file:

{ "pack_key": "the_pack_key", "path": "db/units_tables/data", "source": "PackFile" }

The response will be a DBRFileInfo containing the decoded table data and file metadata.

Common pack_key Pattern

Most tools require a pack_key argument to identify which open pack to operate on. After opening a pack with open_packfiles, the response includes the key. You can also call list_open_packs at any time to see all open packs and their keys.

JSON String Arguments

Some tools accept complex types (like ContainerPath, Definition, GlobalSearch) as JSON strings. These must be passed as a serialized JSON string in the argument field — not as a nested object. For example:

{
  "pack_key": "my_pack",
  "paths": "[{\"File\": \"db/units_tables/data\"}]"
}

Refer to the Shared Types page for the structure of these types.