Skip to main content

Code Property Graph MCP server for DayZ Enforce Script

Project description

enforce-cpg — Code Property Graph for Enforce Script

enforce-cpg

A Code Property Graph (CPG) MCP server for DayZ Enforce Script.

It parses Enforce Script (.c) source across a vanilla/base layer and any number of mod layers, builds a graph of declarations, inheritance, overrides, and calls, and exposes that graph over the Model Context Protocol so an AI coding assistant (e.g. Claude Code) can answer real DayZ-modding questions: "what overrides Speak on Animal?", "who calls this method?", "what breaks if I change this field?" — across a real, multi-mod, load-order-dependent codebase, without ever crashing on a bad file or an unresolved reference.

Install

pip install enforce-cpg        # or: uvx enforce-cpg --version

No compiler needed — the Enforce grammar ships as prebuilt wheels (tree-sitter-enforce).

Or, from a local checkout:

uv sync
uv run enforce-cpg --version

Configure

Point enforce-cpg at your vanilla scripts and mod source trees with an enforce-cpg.toml file (see enforce-cpg.example.toml):

[project]
name = "my-server"
db_path = ".enforce-cpg/index.db"

# ORDERED: earlier = loaded first = base precedence. This IS your -mod= order.
[[sources]]
name = "vanilla"
kind = "core"
path = "/path/to/vanilla_scripts"

[[sources]]
name = "MyMod"
kind = "mod"
path = "/path/to/MyMod/Scripts"

Load-order warning: the order of [[sources]] in this file is the override precedence used to resolve Animal.Speak-style method stacks — it must mirror your server's real -mod= load order. A source listed earlier is treated as the base that later sources override; get this wrong and resolve_method / get_inheritance will report the wrong override winner.

Build (or rebuild) the index:

uv run enforce-cpg index --config enforce-cpg.toml --full

Tools

Once registered with an MCP client, enforce-cpg exposes 12 tools:

Tool Description
reindex Rebuild the code property graph index. full=true forces a from-scratch rebuild; otherwise only changed files are re-indexed.
find_symbol Find declarations of a symbol by name (optionally filtered by kind).
find_references Find references to a symbol by name (optionally filtered by kind; declaration sites excluded by default).
find_callers Find callers of a class method, transitively up to the given depth.
resolve_method Resolve a method call to its override stack across the source layers (core -> mods), in resolution order, flagging cut chains.
get_inheritance Get the inheritance chain for a class, optionally scoped to a method.
impact_of_change Estimate the blast radius of changing a class member.
get_overview Get a structural overview of a file or a class.
audit_overrides Corpus-wide override audit: every modded layer that overrides without super, silently disabling earlier layers.
mod_surface Every method a given source overrides that another source also defines — the mod's footprint on the shared hierarchy.
doctor Setup + index-health report: sources resolved, per-source parse coverage, missing-vanilla warning, diagnostics, unresolved hotspots.
ingest Register a source from an extracted directory (always) or a .pbo (de-rapified if a tool is available), copied under .enforce-cpg/sources/ with the [[sources]] entry added.

The same surface is available on the CLI (enforce-cpg find-symbol, … audit, … mod-surface --source <name>, … doctor, … ingest <path> --name <n> --kind core|mod, …).

Every tool degrades honestly instead of crashing: an unresolved symbol or a missing argument returns {"results": [], "note": "..."} rather than an exception, so a single bad query never takes down the server.

Register with Claude Code

claude mcp add enforce-cpg -- uvx enforce-cpg-mcp

The server reads its config from the ENFORCE_CPG_CONFIG environment variable (defaults to enforce-cpg.toml in the working directory), so set that to your project's config path when registering.

License

enforce-cpg is licensed under the Attribution Assurance License (AAL), an OSI-approved open-source license. The full license text is in LICENSE; the required attribution notice is in NOTICE.

Attribution notice (must be displayed per the AAL's attribution clause):

enforce-cpg — © 2026 tommyz4 — https://github.com/tommyz4/enforce-cpg

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

enforce_cpg-0.2.0.tar.gz (253.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

enforce_cpg-0.2.0-py3-none-any.whl (32.9 kB view details)

Uploaded Python 3

File details

Details for the file enforce_cpg-0.2.0.tar.gz.

File metadata

  • Download URL: enforce_cpg-0.2.0.tar.gz
  • Upload date:
  • Size: 253.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for enforce_cpg-0.2.0.tar.gz
Algorithm Hash digest
SHA256 8c9c42eb81714d7d6365d555ce90591a6d8c94b751833e278fa1d45512d28d10
MD5 7725287309e021c3f4449c5f4846d551
BLAKE2b-256 8262ae2c3bea2156f0d1ae62d5b048e4ccc77cf5f2222953777a66d87e17bf3f

See more details on using hashes here.

File details

Details for the file enforce_cpg-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: enforce_cpg-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 32.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for enforce_cpg-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5fbed426ce35ac84dd4e89ca3f87be7df6cbeee1e9b11355e2367427820dbc3b
MD5 b13c313a95223183cb7c14abf81c74b0
BLAKE2b-256 2641aedc6d37254643c923f0770bf7a6d766feaf4e95eca36fdb3bf538eedb5c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page