Metadata-Version: 2.5
Name: seraph-mcp
Version: 0.2.1
Summary: Query-adaptive, evolution-aware code retrieval
License: MIT License
        
        Copyright (c) 2026 Prethiv Sriman D, Akshith Rajesh, Akhilan VTM, Sanjeev TS — Team floppydisk
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Requires-Python: <3.13,>=3.12
Requires-Dist: bm25s>=0.2.6
Requires-Dist: mcp<2,>=1.2
Requires-Dist: numpy>=1.26
Requires-Dist: pydantic>=2.7
Requires-Dist: pystemmer>=2.2
Requires-Dist: pyyaml>=6.0
Requires-Dist: scikit-learn>=1.5
Requires-Dist: tree-sitter-bash>=0.25
Requires-Dist: tree-sitter-c-sharp>=0.23
Requires-Dist: tree-sitter-c>=0.24
Requires-Dist: tree-sitter-cpp>=0.23
Requires-Dist: tree-sitter-dart>=0.1
Requires-Dist: tree-sitter-fortran>=0.6
Requires-Dist: tree-sitter-go>=0.23
Requires-Dist: tree-sitter-java>=0.23
Requires-Dist: tree-sitter-javascript>=0.23
Requires-Dist: tree-sitter-kotlin>=1.1
Requires-Dist: tree-sitter-lua>=0.5
Requires-Dist: tree-sitter-php>=0.25
Requires-Dist: tree-sitter-python>=0.23
Requires-Dist: tree-sitter-ruby>=0.23
Requires-Dist: tree-sitter-rust>=0.24
Requires-Dist: tree-sitter-scala>=0.26
Requires-Dist: tree-sitter-sql>=0.3
Requires-Dist: tree-sitter-swift>=0.7
Requires-Dist: tree-sitter-typescript>=0.23
Requires-Dist: tree-sitter>=0.23
Provides-Extra: api
Requires-Dist: google-genai>=1.20; extra == 'api'
Requires-Dist: openai>=1.40; extra == 'api'
Provides-Extra: cpu
Requires-Dist: einops>=0.8; extra == 'cpu'
Requires-Dist: faiss-cpu>=1.8; extra == 'cpu'
Requires-Dist: sentence-transformers<6,>=3.4; extra == 'cpu'
Requires-Dist: torch>=2.4; extra == 'cpu'
Requires-Dist: transformers<5,>=4.51; extra == 'cpu'
Provides-Extra: fast
Requires-Dist: huggingface-hub>=0.34; extra == 'fast'
Requires-Dist: model2vec<0.10,>=0.9; extra == 'fast'
Provides-Extra: gemma2
Requires-Dist: einops>=0.8; extra == 'gemma2'
Requires-Dist: faiss-cpu>=1.8; extra == 'gemma2'
Requires-Dist: sentence-transformers<7,>=6.1; extra == 'gemma2'
Requires-Dist: torch>=2.4; extra == 'gemma2'
Requires-Dist: transformers<6,>=5.19; extra == 'gemma2'
Provides-Extra: gpu
Requires-Dist: einops>=0.8; extra == 'gpu'
Requires-Dist: faiss-cpu>=1.8; extra == 'gpu'
Requires-Dist: sentence-transformers<6,>=3.4; extra == 'gpu'
Requires-Dist: torch>=2.4; extra == 'gpu'
Requires-Dist: transformers<5,>=4.51; extra == 'gpu'
Provides-Extra: llm
Requires-Dist: openai>=1.40; extra == 'llm'
Provides-Extra: quality
Requires-Dist: einops>=0.8; extra == 'quality'
Requires-Dist: sentence-transformers<6,>=3.4; extra == 'quality'
Requires-Dist: torch>=2.4; extra == 'quality'
Requires-Dist: transformers<5,>=4.51; extra == 'quality'
Provides-Extra: static
Requires-Dist: huggingface-hub>=0.34; extra == 'static'
Requires-Dist: model2vec<0.10,>=0.9; extra == 'static'
Description-Content-Type: text/markdown

# Seraph

Local code search and Git-aware code intelligence for coding agents. Seraph indexes a local Git checkout into a SQLite database and exposes working-tree search, change impact, task context, repository maps, symbols, dependencies, history, and version comparison over MCP. Source parsing covers Python, JavaScript, TypeScript, Go, C, C++, Java, C#, Rust, PHP, Ruby, Swift, Kotlin, Bash, Dart, Lua, SQL, Fortran, and Scala.

## Install from a checkout

Requires Python 3.12 and Git. With `uv`:

```sh
uv tool install --from . seraph-mcp
```

For development directly from this directory:

```sh
uv sync
uv run seraph-mcp
```

Install the published package from PyPI:

```sh
python -m pip install seraph-mcp
```

## Agent setup

Register a local **stdio MCP server** in your agent with command `seraph-mcp` and no arguments, then reload the MCP connection. Use your agent's own MCP setup UI or command because configuration differs by host. On every Seraph tool call, pass `repo` as the absolute path to the local Git checkout you want searched. Use the active workspace path for that project, or a different repository path when the question is about another checkout.

Seraph runs on the user's machine. Each tool accepts `repo`, the absolute path to the local Git checkout to search. The agent should pass the active workspace path on every call; if asked about another checkout, pass that checkout's path. The index is stored at `<repo>/.seraph/index.sqlite` and ignored by Git.

## MCP tools

- `search_code`: retrieve relevant code from the selected checkout.
- `search_at_version`: retrieve code from a commit, branch, or tag.
- `search_history`: search indexed Git versions.
- `find_symbol`: locate a function, class, or method.
- `find_dependencies`: walk call, import, and inheritance relationships.
- `get_working_tree_status`: see staged, unstaged, and untracked source changes.
- `search_worktree`: search current on-disk source, including uncommitted edits and untracked files.
- `change_impact`: find statically resolved callers, importers, and related tests for symbols or changed paths.
- `prepare_change_context`: bundle task-relevant code, a repo map, change impact, and Git history in one bounded response.
- `get_repo_map`: get a compact file-to-symbol overview; select `scope="worktree"` for current on-disk files, expand a subtree with `path_prefix`, or raise `max_files` and `max_chars`.
- `compare_versions`: compare symbols, dependencies, and commits.
- `index_repository`: explicitly index a Git version; searches index automatically when needed.
- `retrieval_status`: show the active search tier, what each tier needs, and whether the user has chosen.
- `set_retrieval_tier`: switch between `lite`, `fast` and `quality` after the user agrees.

The default retrieval setup is local and needs no API key. Benchmark/evaluation code and submission assets are intentionally excluded from this slim distribution.

`prepare_change_context` uses the active retrieval configuration for both `HEAD` and working-tree searches. Its character cap preserves at least one ranked code result while compacting the repo map and impact details. Search responses report the active retrieval mode. Explicit requests for implementations or tests search a wider candidate list and prioritize the requested kind; broad behavior questions keep the retrieval order.

Working-tree tools overlay changed supported source files on indexed `HEAD`; the overlay itself is temporary.

When a repository already has a Seraph index, the first request after upgrading backfills files using newly added language support. Cross-file graph links are statically resolved where the language syntax and import path can be mapped; dynamic dispatch and framework-specific loading can remain unresolved.

### Search tiers

Keyword search (BM25 over code-aware tokens) is the default and needs no model, no API key and no network, so `pip install seraph-mcp` stays small and search works immediately. It is exact about names but blind to paraphrases: asking "how do we stop hammering the API" will not find `RateLimiter`. Each user can choose a stronger tier; nothing is downloaded until they do.

| Tier | What runs | Download | First search | Install |
|---|---|---|---|---|
| `lite` (default) | BM25 | none | instant | `seraph-mcp` |
| `fast` | BM25 + potion-code-16M static embeddings (numpy, no Torch) | about 62 MB | about a second | `seraph-mcp[fast]` |
| `quality` | BM25 + BGE-Code-v1 (1.5B) | about 6 GB | tens of seconds while the repository is embedded | `seraph-mcp[quality]` |

```sh
seraph models status                        # active tier and what each one needs
seraph setup                                # interactive choice
seraph setup --tier fast --install          # install packages, download the model, verify it, save the choice
seraph setup --tier quality --install --json
seraph models enable --model fast           # or: quality, static:<hf id>, or an embedder name such as qwen3-emb-0.6b
seraph models disable                       # back to lite
```

The choice is saved in `~/.config/seraph/config.yaml` (`SERAPH_CONFIG` points elsewhere) and applies to every repository. Weights download once into the Hugging Face cache; embeddings cache under `~/.cache/seraph`. The `fast` and `quality` extras install together in one environment.

Agents can do the same over MCP: `retrieval_status` reports the active tier and whether the user has chosen, and `set_retrieval_tier` switches it with no restart. The server instructions tell the agent to ask the user first and never pick for them. The `quality` download is too long for a tool call, so the tool returns the terminal command instead. Search responses also carry a `retrieval_hint` when a query barely overlaps the repository's vocabulary, and a `notice` when a chosen tier cannot load, in which case search falls back to keywords instead of failing.

When a query's vocabulary barely overlaps the repository, keyword hits are coincidences, so the semantic view takes over; otherwise keyword search stays in front and the semantic view breaks ties. Tune that with `retrieval.dense_router` and `retrieval.dense_router_threshold`.

`quality` needs `transformers<5` because BGE-Code-v1 ships remote code that is not compatible with v5. EmbeddingGemma-2 needs Transformers 5, so it has its own extra and cannot share an environment with `quality`, `cpu` or `gpu`:

```sh
python -m pip install 'seraph-mcp[gemma2]'
```

Choose `embeddinggemma-2` in Seraph's model configuration. The selected model weights download on first use and are then cached locally.

## CLI

```sh
seraph --repo /path/to/repo index
seraph --repo /path/to/repo search "where is request authentication checked?"
seraph --repo /path/to/repo symbol authenticate_request
seraph --repo /path/to/repo deps authenticate_request
seraph --repo /path/to/repo compare <old-commit> <new-commit>
```

## License

Released under the MIT License.
