Subcore is a Model Context Protocol (MCP) server for RimWorld mod development and codebase analysis. The project is an enhanced fork of realloon/RimSage, overhauled specifically for modded environments.
Subcore reconstructs RimWorld's mod loading pipeline—evaluating XML PatchOperation rules in load order, resolving cross-mod XmlInheritance, indexing decompiled C# assemblies and Harmony patches, and providing exhaustive cross-layer reference lookups for AI agents.
Subcore provides 10 tools tailored for AI agent workflows:
find_refs— Exhaustive reference lookup across all layers simultaneously: vanilla Defs, C# source, mod XML, decompiled mod assemblies, XML patches, and Harmony hooks. Takes a single identifier (defName, C# type, or method).
get_def_details— Inspect full XML for a specificdefNamealong with its override lineage.view="patched": Game runtime truth after XML patches and inheritance resolution.view="merged": Inheritance-resolved XML without patches.view="raw": Authored XML as written in source.
search_defs— Fast indexed search by partialdefNameor in-game label. SupportsdefTypeandmodfilters.
search_patches— Reverse lookup of XMLPatchOperationrules by targetdefName, patching mod (packageId), or operation class (e.g.PatchOperationReplace).search_harmony— Reverse lookup of Harmony patches by target C# class (targetType) or method (targetMethod). Static analysis of mod C# and assemblies.
read_csharp_symbol— Read the source code of a C# class, method, or field by name without needing its file path. Resolves across vanilla code and decompiled mod assemblies.search_source— Regex search with FTS identifier pre-filtering across all source files and Defs. Supports scope (all,vanilla,mods, or a specificpackageId) andloaded_onlyfilters.
list_mods— Overview of active mods in the profile, load order, asset counts, and dependency/compatibility warnings.read_file— Read a specific file by relative path with optional line offsets.list_directory— Browse directory contents within the asset sandbox.
Clone the repository, then in Subcore/ folder, run:
bun installExtract Defs and C# source from your local game installation and decompiled source:
bun run src/scripts/import-defs.ts /path/to/RimWorld
bun run src/scripts/import-csharp.ts /path/to/DecompiledSource(Decompiling RimWorld for mod development is permitted under the RimWorld EULA.)
The program uses a decoupled profile (rimsage.profile.json) to define which mods to index, independent of your player save state.
Generate a profile from your game's active mod list:
bun run import:mods /path/to/RimWorld --from-game-config --out rimsage.profile.jsonOr write rimsage.profile.json manually:
Import mod assets and decompile their assemblies:
bun run import:mods /path/to/RimWorldBuild the SQLite index and patch cache:
bun run buildAdd to your client's MCP settings (e.g. .cursor/mcp.json or claude_desktop_config.json):
{
"mcpServers": {
"subcore": {
"command": "bun",
"args": ["run", "/path/to/Subcore/src/stdio.ts"]
}
}
}Alternatively, start the local HTTP server:
bun run start:http
# Listening on http://localhost:3000/mcpAnd configure your client with the local URL:
{
"mcpServers": {
"subcore": {
"url": "http://localhost:3000/mcp"
}
}
}- Load-Order Accurate: Mods and DLCs are topologically sorted according to
About.xmldependencies and RimWorld's load rules. - Patch Before Inheritance: Faithful to RimWorld's
LoadedModManager, XMLPatchOperationmodifications run against the raw unified Def tree beforeXmlInheritanceresolves templates and abstract parents. - Lineage Tracking: Every Def retains provenance (
defined by ... -> overridden by ... -> effective: ...), showing exact override origins. - Zero Hallucination Routing: Built-in instructions guide AI models to check indexed ground truth (
find_refs,get_def_details,search_harmony) rather than guessing class structures or brute-force searching text.
# Run unit test suite
bun test
# Validate patch evaluation against index
bun run regression:patches
# Scan all patch XML files in workshop folder
bun run regression:patches --workshopMIT
{ "name": "my-mod-project", "base": "all-dlc", // "core-only" | "all-dlc" "mods": [ "brrainz.harmony", "oskarpotocki.vanillafactionsexpanded.core", "mehni.pickupandhaul" ], "autoOrder": true // Topological sort by dependencies }