Skip to main content

CI

CapyIdx

CapyIdx indexes source repositories into SQLite and provides deterministic symbol lookup and code reconstruction. It is designed to be embedded in tools that need repository-aware code context. It has incremental re-indexing feature that re-indexes only modified or deleted (deteles indexes of deleted file) files. It looks for files which are modified and after a set interval(default=5 sec) it re-indexes them.

Capyidx comes with in-built mcp server for codex.

Installation

python -m pip install capyidx

For development:

python -m pip install -e ".[dev]"

The core package uses Tree-sitter for source parsing and tiktoken for chunk size calculations. Optional integrations can be installed with extras:

python -m pip install "capyidx[openai]"
python -m pip install "capyidx[ollama]"
python -m pip install "capyidx[local-embeddings]"
python -m pip install "capyidx[vector]"

Basic usage

Indexing is asynchronous. The convenience API waits for the initial pass to finish:

import asyncio
from capyidx import index_repo, lookup_symbol


async def main() -> None:
    repo = "/path/to/git/repository"
    await index_repo(repo)

    result = await lookup_symbol(repo, "MyClass", detail="body")
    for match in result.matches:
        print(match.name, match.path, match.start_line, match.end_line)

    if result.selected is not None:
        print(result.selected.code)


asyncio.run(main())

Use index_repo_iter when progress updates are needed:

from capyidx import index_repo_iter

async for update in index_repo_iter("/path/to/git/repository"):
    print(update.status, update.progress, update.desc)

Pass watch=True to continue indexing changed files after the initial pass. The watcher uses watchdog(recommended) when installed and otherwise falls back to polling.

Codex CLI MCP integration

CapyIdx includes an MCP server for Codex CLI. Install it from PyPI:

pip install capyidx

From the repository you want Codex to inspect, register CapyIdx once:

cd /path/to/your/repository
codex mcp add capyidx \
  --env CAPYIDX_REPO="$PWD" \
  -- capyidx-mcp

Not adding any repository path to environment variable would make capyidx use the current working directory of codex.

Start Codex in that repository:

codex

Then ask(example):

Use the CapyIdx MCP server. Call lookup_symbol for "any function/class", then call get_symbol on the returned symbol_id.

CapyIdx indexes the repository automatically and provides symbol lookup, source reconstruction, and line-range retrieval through MCP.

Query workflows

  • lookup_symbol returns matching symbol metadata and reconstructs a unique exact match.
  • reconstruct_symbol reconstructs a previously selected symbol by ID.
  • resolve_lookup reconstructs every match for a name.
  • open_lookup reuses one database connection for multiple queries.

Use detail="signature" for declaration-only results, and use filter_paths to restrict lookup to selected path prefixes.

Examples

The examples/ directory contains runnable scripts for the main workflows:

# Index a repository and look up a symbol.
python examples/sample.py /path/to/repository MyClass --detail signature

# Reuse one lookup session for several symbol queries.
python examples/query_session.py /path/to/repository MyClass OtherClass

# Keep the index updated while files change.
python examples/watch_repository.py /path/to/repository

sample.py also demonstrates ambiguous matches, resolve_lookup, filter_paths, and max_lines.

Current scope

The public convenience API currently builds the chunk/symbol index and exposes deterministic symbol retrieval. FTS, code-snippet, embedding, and LanceDB backends are present as lower-level components but are not automatically wired into index_repo yet.

Indexes are stored under ~/.capyidx/.codebase_index by default. Set CAPYIDX_HOME to use a different data directory.

Development checks

python -m compileall -q src tests
pytest
python -m build

The repository's CI runs these checks on Python 3.10, 3.11, and 3.12.

Metadata

Release files for capyidx 0.1.4

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

Source distribution (sdist)

Source distribution for capyidx 0.1.4
File Size Uploaded
capyidx-0.1.4.tar.gz 90.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for capyidx 0.1.4
File Interpreter ABI Platform
capyidx-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 197.3 kB

Release files / capyidx-0.1.4.tar.gz

Download URL capyidx-0.1.4.tar.gz
Size 90.5 kB
Tags Source
SHA-256 checksum
How to use checksums
fcfd9f4283f0492bc4013179ff015037cd067a4cac474205a60a4060710e0fee
BLAKE2b-256 checksum
How to use checksums
4e4d6ae202f270515d28de98fdce2ebf06c52631c2bfca05d8f7d90531de4b76
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.19

Release files / capyidx-0.1.4-py3-none-any.whl

Download URL capyidx-0.1.4-py3-none-any.whl
Size 106.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2789183f2a9f7bf01f97a7f24cf88f9a90384042fdab9e467bb24751f27d82b9
BLAKE2b-256 checksum
How to use checksums
25594941f0aef49133f162c11c28b251c72fae6cf5a7305a34b72bc15a00e947
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.19

Release history Release notifications | RSS feed

This release

0.1.4 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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