Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

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 via web)
  • 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)
  • openai
  • azure
  • mock (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:

  1. Sync and run tests:
uv sync --all-extras
uv run pytest -q
  1. Build distributables and verify local install:
uv build
python -m pip install dist/*.whl
codecontext -version
  1. Validate core command paths:
codecontext index .
codecontext stats
codecontext web 8080

Backend note:

  • Default backend: cogdb (cross-platform, works on Windows, Linux, and macOS)
  • Alternative backend: sqlite (use -backend sqlite to switch)

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

  1. Create project on PyPI:

    • Create an account on PyPI.
    • Create a project named ossr-codecontext.
  2. Configure Trusted Publishing on PyPI:

    • Publisher type: GitHub
    • Repository: your org/user + repo name
    • Workflow: release.yml
    • Environment: leave empty unless you use one
  3. Ensure the package metadata in pyproject.toml is public-ready:

    • name, version, description, readme, requires-python, authors
    • add license, classifiers, urls if needed

Package naming note:

  • PyPI distribution name: ossr-codecontext
  • CLI command: codecontext
  • Python import package: codecontext

Release flow

  1. Run the Release workflow manually with a version like v1.2.3 or v1.2.3-beta.1.
  2. The workflow builds and attaches artifacts to the GitHub Release.
  3. 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

Metadata

Release files for ossr-codecontext 0.0.0a21

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ossr-codecontext 0.0.0a21
File Size Uploaded
ossr_codecontext-0.0.0a21.tar.gz 43.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ossr-codecontext 0.0.0a21
File Interpreter ABI Platform
ossr_codecontext-0.0.0a21-py3-none-any.whl Python 3 none any Details

Total release size: 86.6 kB

Release files / ossr_codecontext-0.0.0a21.tar.gz

Download URL ossr_codecontext-0.0.0a21.tar.gz
Size 43.3 kB
Tags Source
SHA-256 checksum
How to use checksums
393bbdf7c9157c849f05cdc2b9ea63e92d229bcc887f758956619b280bdabdb8
BLAKE2b-256 checksum
How to use checksums
6333215214a754f7a7dae2b83427f0aff5c986079fd8c8c8ec36b41a386a34f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 14, 2026.

Transparency log

Release files / ossr_codecontext-0.0.0a21-py3-none-any.whl

Download URL ossr_codecontext-0.0.0a21-py3-none-any.whl
Size 43.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c35c967959b415009f243f89017196115d42e71c42088b6bba243536cd079f1a
BLAKE2b-256 checksum
How to use checksums
f47039f3473a72101c817462d961d358f932d62a00f9a9684e20c906c311ea88
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 14, 2026.

Transparency log
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page