Index source repositories into a code graph with CLI, MCP, Web API/UI, and AI analysis workflows
Project description
codecontext (Python)
codecontext indexes source repositories into a SQLite-backed code graph and exposes:
- CLI workflows (
index,query,stats,docs,ai,web,mcp) - MCP-compatible tool server (stdio via
mcp, HTTP viaweb) - Web API/UI for graph/stats/tree exploration
This repository is now Python-first and uses uv for environment and command execution.
Dependency management is defined in pyproject.toml and locked in uv.lock.
Requirements
- Python 3.12+
- uv
Quick Start
uv sync --all-extras
uv run python -m codecontext -version
Common Commands
uv run python -m codecontext index .
uv run python -m codecontext stats
uv run python -m codecontext query entity Parse
uv run python -m codecontext docs -output docs.md
LLM_PROVIDER=mock uv run python -m codecontext docs -ai -output ai-docs.md
LLM_PROVIDER=mock uv run python -m codecontext ai query "what does this repo do"
uv run python -m codecontext web 8080 # Web UI + API + HTTP MCP at /mcp
uv run python -m codecontext mcp # MCP stdio for CLI/editor integrations
When running web, all HTTP surfaces share one port:
- UI:
GET / - Web API:
GET /api/* - MCP HTTP:
POST /mcp
LLM Providers
Supported providers:
ollama(default)openaiazuremock(useful for local tests)
Environment variables:
# Provider selection
export LLM_PROVIDER=ollama
export LLM_MODEL=llama2
# Common settings
export LLM_TEMPERATURE=0.7
export LLM_MAX_TOKENS=2000
export LLM_TIMEOUT_SECONDS=30
# Ollama
export OLLAMA_BASE_URL=http://localhost:11434
# OpenAI
export OPENAI_API_KEY=...
export OPENAI_MODEL=gpt-4o-mini
# Azure OpenAI
export AZURE_OPENAI_ENDPOINT=...
export AZURE_OPENAI_KEY=...
export AZURE_OPENAI_DEPLOYMENT=...
export AZURE_OPENAI_API_VERSION=2024-02-15-preview
Development
uv run pytest -q
uv run pytest -q tests/test_web_api.py tests/test_mcp_tools.py
Cross-Platform Development (Linux + Windows)
Use this quick checklist to ensure the project is installable and usable on both platforms:
- Sync and run tests:
uv sync --all-extras
uv run pytest -q
- Build distributables and verify local install:
uv build
python -m pip install dist/*.whl
codecontext -version
- Validate core command paths:
codecontext index .
codecontext stats
codecontext web 8080
Backend note:
- Non-Windows default backend:
falkordblite - Windows default backend:
sqlite(thefalkordblitedependency is not available on win32)
CI enforces this on both Linux and Windows via .github/workflows/test-cli.yml.
Publish Public Package (PyPI)
This repository publishes Python packages through GitHub Actions with:
- Primary path:
.github/workflows/release.yml(builds, creates release, uploads artifacts, and publishes)- all versions (stable and prerelease) publish to PyPI
- Fallback path:
.github/workflows/publish-pypi.yml(auto on release event or manual run by tag)
One-time setup
-
Create project on PyPI:
- Create an account on PyPI.
- Create a project named
ossr-codecontext.
-
Configure Trusted Publishing on PyPI:
- Publisher type: GitHub
- Repository: your org/user + repo name
- Workflow:
release.yml - Environment: leave empty unless you use one
-
Ensure the package metadata in
pyproject.tomlis public-ready:name,version,description,readme,requires-python,authors- add
license,classifiers,urlsif needed
Package naming note:
- PyPI distribution name:
ossr-codecontext - CLI command:
codecontext - Python import package:
codecontext
Release flow
- Run the Release workflow manually with a version like
v1.2.3orv1.2.3-beta.1. - The workflow builds and attaches artifacts to the GitHub Release.
- Publishing occurs in the same release workflow run:
- stable and prerelease -> PyPI
If release-event automation is blocked by repository token policy, run publish-pypi.yml manually and pass the release tag.
If a release job is re-run for the same version, existing files on PyPI are skipped. In normal use, publish a new version for each release.
Verify install
Install from PyPI:
pip install ossr-codecontext
Notes
- Default graph database:
.codecontext.db - Override with
-graph /path/to/graph.db - Startup helper script:
./codecontext_startup.sh
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ossr_codecontext-0.0.0a19.tar.gz.
File metadata
- Download URL: ossr_codecontext-0.0.0a19.tar.gz
- Upload date:
- Size: 46.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a39f0b456328766060ec04e7d15abba3a9ddb26d385709c0d893cabdf6998dd9
|
|
| MD5 |
b2cfc4ba437ecd3d779b168840e068cc
|
|
| BLAKE2b-256 |
2011cff3825a7bc8fa304ae2f9aafdda8f9ee662ad3fb3f1f33c68f14fb4f103
|
Provenance
The following attestation bundles were made for ossr_codecontext-0.0.0a19.tar.gz:
Publisher:
release.yml on RandomCodeSpace/codecontext
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ossr_codecontext-0.0.0a19.tar.gz -
Subject digest:
a39f0b456328766060ec04e7d15abba3a9ddb26d385709c0d893cabdf6998dd9 - Sigstore transparency entry: 1101951855
- Sigstore integration time:
-
Permalink:
RandomCodeSpace/codecontext@78554eeb0121a9b4934bc66afc469b24a39b50ae -
Branch / Tag:
refs/heads/main - Owner: https://github.com/RandomCodeSpace
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@78554eeb0121a9b4934bc66afc469b24a39b50ae -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file ossr_codecontext-0.0.0a19-py3-none-any.whl.
File metadata
- Download URL: ossr_codecontext-0.0.0a19-py3-none-any.whl
- Upload date:
- Size: 45.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f1cef403a5302584c78852d11094e03c16b206ee95c8326a7601e40efa57456f
|
|
| MD5 |
bb246c05a10862e5779b9e22e15fdda7
|
|
| BLAKE2b-256 |
a30ced304cccba137aa1148bbe0a71af8b5d08bdafc2b65b5d5c06a2defbe755
|
Provenance
The following attestation bundles were made for ossr_codecontext-0.0.0a19-py3-none-any.whl:
Publisher:
release.yml on RandomCodeSpace/codecontext
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ossr_codecontext-0.0.0a19-py3-none-any.whl -
Subject digest:
f1cef403a5302584c78852d11094e03c16b206ee95c8326a7601e40efa57456f - Sigstore transparency entry: 1101951857
- Sigstore integration time:
-
Permalink:
RandomCodeSpace/codecontext@78554eeb0121a9b4934bc66afc469b24a39b50ae -
Branch / Tag:
refs/heads/main - Owner: https://github.com/RandomCodeSpace
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@78554eeb0121a9b4934bc66afc469b24a39b50ae -
Trigger Event:
workflow_dispatch
-
Statement type: