Skip to main content

context-server

context-server

CI PyPI

Semantic search over a folder of markdown, served as an MCP server for coding agents.

Index once into a SQLite DB (embeddings + BM25). Point Claude Code, Cursor, or any MCP client at serve, and the agent can search that corpus instead of guessing from memory.

One Rust binary. ONNX Runtime is linked in via ort / fastembed — no separate libonnxruntime to ship. SQLite is bundled.

Quick start

pip install context-server
# or: uvx context-server@latest …

context-server index --input ./docs --db context.db
context-server search --db context.db "how do we handle backports"
context-server serve --db context.db

Wheels: Linux x86_64/aarch64 (manylinux_2_39 / glibc 2.39+, e.g. Ubuntu 24.04+) and macOS Apple Silicon.

The first embedding run downloads All-MiniLM-L6-v2 into $XDG_CACHE_HOME/context-server/fastembed/ (or ~/.cache/...; once, tens of MB). Override with FASTEMBED_CACHE_DIR or HF_HOME.

Optional: tell the agent when to use this corpus

context-server index --input ./docs --db context.db \
  --instructions-file ./mcp-instructions.txt
# or: --instructions 'Use semantic_search for questions about …'

That text is stored in the DB and exposed as MCP ServerInfo.instructions when you serve.

Claude Code

claude mcp add --transport stdio --scope user context-server \
  -- uvx --refresh context-server@latest \
  serve --db /absolute/path/to/context.db

--refresh + @latest rechecks PyPI on each start. If Claude rarely surfaces the tools, set "alwaysLoad": true on the server entry in your Claude MCP config.

Cursor

~/.cursor/mcp.json (or project .cursor/mcp.json):

{
  "mcpServers": {
    "context-server": {
      "command": "uvx",
      "args": [
        "--refresh",
        "context-server@latest",
        "serve",
        "--db",
        "/absolute/path/to/context.db"
      ]
    }
  }
}

Reload MCP after editing. Re-index when content changes, then restart the MCP session so serve reloads the DB.

What it indexes

Only .md / .markdown. Chunks on # / ## / ###, keeps the heading path on each chunk, and splits long sections with overlap.

Convert structured sources (YAML, etc.) to prose before indexing. Fenced YAML searches poorly; a short paragraph that keeps names, roles, and relationships together works much better.

Try the sample set:

cargo build --release
./target/release/context-server index --input examples/sample-docs --dry-run
./target/release/context-server index --input examples/sample-docs --db /tmp/sample.db
./target/release/context-server search --db /tmp/sample.db "password reset"

Search

Default mode is hybrid: dense cosine (MiniLM) plus BM25, fused with reciprocal rank fusion. Dense catches paraphrase; BM25 catches exact tokens (usernames, acronyms, IDs).

context-server search --db context.db --mode hybrid "query"   # default
context-server search --db context.db --mode dense "query"
context-server search --db context.db --mode lexical "query"

# Scope to a subtree / heading / metadata tag
context-server search --db context.db --path-prefix teams/ "who owns storage"
context-server search --db context.db --heading Backport "z-stream"
context-server get --db context.db --path teams/storage.md --chunk 0

MCP tools

Tool Role
semantic_search Ranked passages + scores; optional path_prefix / heading / tag filters
list_documents Indexed chunks; optional path_prefix
answer_question Best matching passage(s) — retrieval only; same filters as search
get_document Full chunk by citation (source_path + chunk_index), or all chunks for a path

Search hits cite chunks as source_path#chunk_index. Call get_document to pull the full text for quoting.

Remote database (GCS)

serve and search accept a gs:// URI. The object is cached under $XDG_CACHE_HOME/context-server/dbs/ (or ~/.cache/...). index still writes a local path only.

context-server serve --db 'gs://my-bucket/latest/context.db'

# Project-qualified form also works (gs:// required; stripped for the Storage API)
context-server serve --db \
  'gs://projects/my-gcp-project/buckets/my-bucket/objects/latest/context.db'

Uses Application Default Credentials. If a sibling {object}.sha256 exists (sha256sum format), a matching local cache is reused; otherwise the DB is re-fetched and verified.

CLI

context-server index  --input <path> [--db FILE] [--dry-run] [--batch N]
                      [--instructions TEXT | --instructions-file FILE]
context-server serve  --db <local path | gs://…>
context-server search --db <local path | gs://…> [--limit N] [--mode hybrid|dense|lexical]
                      [--path-prefix P] [--heading H] [--tag T] <query>
context-server get    --db <local path | gs://…> --path FILE [--chunk N]
context-server embed  <text>          # smoke-test embeddings

Build from source

cargo build --release
cargo test

Rust 1.75+, Linux x86_64 is the primary target. You need a C++ stdlib for the linker (libstdc++) and whatever OpenSSL/native-tls needs on your platform.

On Fedora/RHEL, if the linker wants -lstdc++ but only libstdc++.so.6 exists:

mkdir -p .linker && ln -sfn /usr/lib64/libstdc++.so.6 .linker/libstdc++.so
export RUSTFLAGS="-L native=$(pwd)/.linker"

Linux wheels (same image CI uses — Ubuntu 24.04 / glibc 2.39):

./scripts/build-wheel.sh
VERSION=2026.716.1 ./scripts/build-wheel.sh   # optional override

Releasing

CalVer YYYY.MMDD.N (e.g. 2026.716.1) so versions work for both Cargo and PyPI. Run the Release workflow on main (Actions UI or CLI); it picks the next version, builds wheels, publishes to PyPI, then creates the matching git tag and GitHub Release (with wheels attached).

gh workflow run release.yml --repo context-server/context-server

Design notes

Under the hood: fastembed All-MiniLM-L6-v2 (384-d, L2-normalized), rusqlite with float32 blobs, rmcp over stdio. Each index run replaces the DB contents.

More detail and roadmap: PLAN.md.

License

MIT — see LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

context_server-2026.718.3.tar.gz (271.1 kB view details)

Uploaded Source

Built Distributions

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

context_server-2026.718.3-py3-none-manylinux_2_39_x86_64.whl (17.5 MB view details)

Uploaded Python 3manylinux: glibc 2.39+ x86-64

context_server-2026.718.3-py3-none-manylinux_2_39_aarch64.whl (17.9 MB view details)

Uploaded Python 3manylinux: glibc 2.39+ ARM64

context_server-2026.718.3-py3-none-macosx_11_0_arm64.whl (13.5 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

Details for the file context_server-2026.718.3.tar.gz.

File metadata

  • Download URL: context_server-2026.718.3.tar.gz
  • Upload date:
  • Size: 271.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for context_server-2026.718.3.tar.gz
Algorithm Hash digest
SHA256 0675c567708933a240c010bd234c6e5a54ed7ad4ee2a5334a404d379676a6f25
MD5 81a5330c5b88c495ea744cf1f02b767a
BLAKE2b-256 9e768f292bcb05a15a645ac9e7f042d8c1e198b657d435d13b97ade758ef4adb

See more details on using hashes here.

File details

Details for the file context_server-2026.718.3-py3-none-manylinux_2_39_x86_64.whl.

File metadata

  • Download URL: context_server-2026.718.3-py3-none-manylinux_2_39_x86_64.whl
  • Upload date:
  • Size: 17.5 MB
  • Tags: Python 3, manylinux: glibc 2.39+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for context_server-2026.718.3-py3-none-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 a14a6e42fc4d3752b56565f76f8d9252b74f444f6589d3d671f79a0dfa677b72
MD5 dfb872d5057dbce01a0de43f6b396415
BLAKE2b-256 463dc325fae156f2b0b184499efa851305f76e252d04da32daba44a445cae23f

See more details on using hashes here.

File details

Details for the file context_server-2026.718.3-py3-none-manylinux_2_39_aarch64.whl.

File metadata

  • Download URL: context_server-2026.718.3-py3-none-manylinux_2_39_aarch64.whl
  • Upload date:
  • Size: 17.9 MB
  • Tags: Python 3, manylinux: glibc 2.39+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for context_server-2026.718.3-py3-none-manylinux_2_39_aarch64.whl
Algorithm Hash digest
SHA256 b9f8b64a75f8d6511bebca0fcc5e8c8013aa4eb74a2019f3d572e50cba03fc05
MD5 ad6f800050cf607d92a9513e07ebe130
BLAKE2b-256 ddaf82373e1778c45e6c29ebc4772960d84f545e4ecdabc1c1689544c9a3749e

See more details on using hashes here.

File details

Details for the file context_server-2026.718.3-py3-none-macosx_11_0_arm64.whl.

File metadata

  • Download URL: context_server-2026.718.3-py3-none-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 13.5 MB
  • Tags: Python 3, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for context_server-2026.718.3-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d6aa4bdbebf76b9904c2026c90ebe390e72cb4c5eadc4f29de02b76d5d35413f
MD5 904e8e9e67c4e7742e6d861753882ebe
BLAKE2b-256 f45287b90a30d60f6629d4dc6d6f418d03ba3affca182ca1dcb474f992c40c85

See more details on using hashes here.

Release history Release notifications | RSS feed

2026.823.1

4 files

2026.822.1

4 files

2026.820.1

4 files

2026.718.4

4 files

This release

2026.718.3 This release

4 files

2026.718.2

4 files

2026.718.1

4 files

2026.717.3

4 files

2026.717.2

4 files

2026.717.1

4 files

2026.716.3

4 files

2026.716.2

4 files

2026.716.1

4 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