Skip to main content

Unified Context Engine

Project description

Unified Context Engine (UCE)

UCE builds a deterministic knowledge graph of a codebase in Neo4j and exposes reasoning tools over that graph. It works across repositories, supports multiple languages, and continuously updates when files change.

This package is pip-installable and CLI-friendly.

What UCE Does

  • Ingests source code, schema, requirements, and policies into a Neo4j graph.
  • Tracks files, functions, classes, methods, tables, columns, requirements, and policies.
  • Provides deterministic impact analysis and risk assessment.
  • Keeps the graph up-to-date via a file watcher.
  • Exposes reasoning tools through an MCP server.

Supported Languages

UCE uses Tree-sitter and supports:

  • Python
  • TypeScript
  • JavaScript
  • Go
  • Java
  • C
  • C++

Prerequisites

  1. Install Python 3.10+. On Windows, Python 3.10 is recommended for Tree-sitter wheels.
  2. Install and start Neo4j Desktop or Neo4j Server.
  3. Note your Bolt URI, username, and password. The typical default is bolt://localhost:7687 with user neo4j.

Quickstart (Detailed)

1. Install UCE

pip install uce-engine

2. Create config.yaml

Create config.yaml in the repo you want to analyze.

Example:

project_root: .

languages:
  - python
  - typescript
  - javascript
  - go
  - java
  - c
  - cpp

paths:
  code:
    - core
    - ingestion
    - runtime
    - server
    - reasoning
  schema: []
  requirements:
    - artifacts/requirements
  policies:
    - artifacts/policies
  identifiers: # optional: limit identifier usage indexing to these paths
    - server

ignore:
  - .git
  - .next
  - __pycache__
  - node_modules
  - venv
  - dist
  - build
  - coverage
  - .idea
  - .vscode
  - ui
  - views
  - public
  - assets
  - styles
  - css
  - scss
  - .env
  - .DS_Store
  - ".log"
  - ".tmp"
  - ".bak"
  - ".swp"
  - ".swo"
  - ".pyc"
  - ".class"
  - ".o"
  - ".so"
  - ".dll"
  - ".exe"
  - ".dylib"
  - ".zip"
  - ".tar"
  - ".gz"
  - ".7z"
  - ".rar"

aliases:
  "@/": src/

neo4j:
  uri: bolt://localhost:7687
  user: neo4j
  password: testpassword

3. Understand the key config.yaml fields

  • project_root: The root folder for this repository. Relative paths are resolved from here.
  • languages: Which language parsers to enable.
  • paths.code: One or more folders that contain code.
  • paths.code can include multiple folders. Use . if you want to scan the entire repo.
  • paths.schema: Schema files or folders (SQL, JSON, YAML, etc.).
  • paths.requirements: Folders with requirement docs.
  • paths.policies: Folders with policy docs.
  • paths.identifiers: Optional list of folders where identifier usage indexing is enabled.
  • paths.identifiers can also point at a single file. If empty, identifier indexing is disabled.
  • ignore: Substring filters applied to relative paths. If a path contains a token, it is skipped.
  • aliases: Import alias mapping for resolving internal imports.
  • neo4j.uri, neo4j.user, neo4j.password: Connection settings.

4. Create .env (optional but recommended)

UCE can load environment variables from a .env file.

Defaults:

  • UCE looks for .env next to config.yaml.
  • You can override this location with UCE_DOTENV_PATH.

Templates:

  • In the repo, use .env.example as a starting point.
  • When installed from PyPI, the template is bundled at core/.env.example inside the package. Do not commit .env to source control; it contains secrets.

Common variables:

  • NEO4J_URI, NEO4J_USERNAME, NEO4J_PASSWORD
  • LLM_PROVIDER, OPENAI_API_KEY
  • NEO4J_TRANSPORT_MODE, NEO4J_MCP_HTTP_URL

5. Run UCE (CLI)

From anywhere:

uce --config path/to/config.yaml

What happens:

  1. Loads configuration.
  2. Connects to Neo4j.
  3. Builds or updates the graph.
  4. Starts the file watcher.
  5. Launches the MCP server.

LLM Ingestion (End-to-End)

If you want LLM-based requirements or policies ingestion, you also need the Neo4j MCP server running.

1. Set required .env values

LLM_PROVIDER=openai
OPENAI_API_KEY=your_key_here
NEO4J_TRANSPORT_MODE=http
NEO4J_MCP_HTTP_URL=http://127.0.0.1:8000/mcp/

2. Start the Neo4j MCP server

neo4j-mcp --transport http --server-host 127.0.0.1 --server-port 8000 --server-path /mcp/

3. Run UCE

uce --config path/to/config.yaml

Stdio MCP (optional)

If you prefer stdio, set:

NEO4J_TRANSPORT_MODE=stdio
NEO4J_MCP_COMMAND=neo4j-mcp --transport stdio

Then run uce --config path/to/config.yaml.

Run (Library)

from run import run_uce

run_uce("path/to/config.yaml")

Identifier Indexing (Optional)

If you want identifier usage (variable names, type names, field names) indexed into the graph, set paths.identifiers in config.yaml or UCE_IDENTIFIER_PATHS in .env. If it is empty, identifier indexing is disabled.

MCP Tools

UCE exposes reasoning tools via MCP:

  • impact_analysis
  • explain_change
  • risk_assessment
  • count_functions_in_file (AST-lite helper)
  • find_identifier_usage (AST-lite helper)

These tools query the graph (no ingestion logic).

What Nodes Are In The Graph

  • File
  • Function
  • Class
  • Method
  • Table
  • Column
  • Requirement
  • Policy
  • Identifier (optional, AST-lite usage index)

If you want additional node types (e.g., Dependencies, Endpoints, Services), add them in ingestion and reasoning layers.

License

MIT

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

uce_engine-0.1.7.tar.gz (46.8 kB view details)

Uploaded Source

Built Distribution

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

uce_engine-0.1.7-py3-none-any.whl (51.2 kB view details)

Uploaded Python 3

File details

Details for the file uce_engine-0.1.7.tar.gz.

File metadata

  • Download URL: uce_engine-0.1.7.tar.gz
  • Upload date:
  • Size: 46.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for uce_engine-0.1.7.tar.gz
Algorithm Hash digest
SHA256 65b5017bc8e35a7bed281f64abf4e2c0d476996d078fe6ce3d16d2b1ecd58c64
MD5 c4bbabc20c9c91f7782251c475ea5094
BLAKE2b-256 1343f76bc67a8b9717a45d9d5874a06b95871f74c627c4d3a4aebdedc260ced4

See more details on using hashes here.

File details

Details for the file uce_engine-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: uce_engine-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 51.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for uce_engine-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 39a29e4b7b3352b7dfdb9fa42e36919072081ec1b4b41767a416f427c49feb05
MD5 45a9a316bfa4af177f5916481f3f6aff
BLAKE2b-256 0c7eecf57d976b6537cf85b171fbb172310bb6ce231f69d61d163376554da9fd

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