Skip to main content

Lightweight MCP server for semantic search over organizational markdown

Project description

context-server

A lightweight MCP server for semantic search over markdown knowledge bases.

One Rust binary. ONNX Runtime is statically linked (via ort / fastembed) — no separate libonnxruntime.so to ship. SQLite is bundled. Built for AI coding agents (Claude Code, Cursor, etc.).

Features

  • Index markdown into a local SQLite vector database
  • Chunk by ## / ### headings (hierarchy kept in each chunk); oversized sections are split with overlap
  • Hybrid search: dense embeddings (All-MiniLM-L6-v2) + BM25, fused with reciprocal rank fusion
  • MCP tools: semantic_search, list_documents, answer_question
  • CLI for index / search / embed smoke tests

Input contract: feed searchable prose (markdown). Structured data (YAML, etc.) should be converted to markdown before indexing — raw YAML in code fences searches poorly.

Requirements

  • Rust 1.75+ (edition 2021)
  • Linux x86_64 (primary target today)
  • At build/link time: a C++ standard library (libstdc++) and OpenSSL development headers if your platform needs them for native-tls

On Fedora/RHEL, if the linker cannot find -lstdc++ (only libstdc++.so.6 is installed):

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

Install

pip install context-server

Platform wheels: Linux x86_64/aarch64 (manylinux_2_39, glibc 2.39+ / Ubuntu 24.04+) and macOS Apple Silicon.

Build

cargo build --release

The first embedding run downloads the MiniLM model into the local Hugging Face / fastembed cache (~tens of MB, once).

Linux wheels (Podman)

Same Containerfile CI uses (Ubuntu 24.04 / glibc 2.39 — required by current ORT prebuilts):

./scripts/build-wheel.sh   # writes dist/*.whl
VERSION=2026.716.1 ./scripts/build-wheel.sh  # optional CalVer override

Releasing (CalVer)

Versions are CalVer YYYY.MMDD.N (e.g. 2026.716.1) so they are valid for both Cargo SemVer and PyPI. pyproject.toml takes the version from Cargo.toml; release CI rewrites that from the git tag before building.

tag="$(./scripts/next-calver.sh)"
git tag -a "$tag" -m "$tag"
git push origin "$tag"    # triggers Release workflow → PyPI

setuptools-scm is not used (maturin cannot consume it).

Usage

# Preview how documents will be chunked
./target/release/context-server index --input ./docs --dry-run

# Embed and write the database
./target/release/context-server index --input ./docs --db context.db

# CLI search (hybrid by default; also --mode dense|lexical)
./target/release/context-server search --db context.db "how do we handle backports"

# MCP stdio server
./target/release/context-server serve --db context.db

Remote database (GCS)

serve and search accept a remote --db and download it into the local cache ($XDG_CACHE_HOME/context-server/dbs/..., or ~/.cache/...) before opening:

# Short form (globally unique bucket)
context-server serve --db 'gs://vme-cnv-context/latest/cnv.db'

# Project-qualified Google resource name
context-server serve --db \
  'projects/itpc-gcp-hcm-pe-eng-claude/buckets/vme-cnv-context/objects/latest/cnv.db'

Uses Application Default Credentials (gcloud auth application-default login, or GOOGLE_APPLICATION_CREDENTIALS). When a sibling {object}.sha256 exists (sha256sum format), the download is skipped if the local cache already matches; otherwise the DB is re-fetched and verified. index still writes a local path only.

Claude Code

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

Re-index when content changes, then restart the MCP session so serve reloads the DB into memory. For a GCS-backed DB, point --db at the gs:// or projects/.../objects/... URI instead.

If Claude rarely calls the tools (tool search defers MCP tools), add "alwaysLoad": true to the server entry in your Claude MCP config so these tools stay visible every turn.

MCP tools

Tool Description
semantic_search Ranked passages with similarity scores
list_documents Indexed chunk listing
answer_question Top passage for a question (retrieval only, no generative QA)

Architecture

Piece Choice
Embeddings fastembed → All-MiniLM-L6-v2, L2-normalized (model id stored in DB)
Inference ort (static ONNX Runtime)
Storage rusqlite (bundled SQLite), float32 blobs
Search Hybrid: cosine dense + BM25 → reciprocal rank fusion
Chunking ## / ### + split when text exceeds ~900 chars
MCP rmcp stdio

See PLAN.md for design notes and roadmap.

Development

cargo test
cargo build --release

License

MIT — see LICENSE.

Project details


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.716.1.tar.gz (56.6 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.716.1-py3-none-manylinux_2_39_x86_64.whl (17.4 MB view details)

Uploaded Python 3manylinux: glibc 2.39+ x86-64

context_server-2026.716.1-py3-none-manylinux_2_39_aarch64.whl (17.8 MB view details)

Uploaded Python 3manylinux: glibc 2.39+ ARM64

context_server-2026.716.1-py3-none-macosx_11_0_arm64.whl (13.4 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: context_server-2026.716.1.tar.gz
  • Upload date:
  • Size: 56.6 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.716.1.tar.gz
Algorithm Hash digest
SHA256 36352f4c3d1d45ca1840a1344518e98d803c885c3a22542b90091c1fc0e789aa
MD5 61ad2bb7328d30b5c701035cf38f7585
BLAKE2b-256 2101ce949e7272eba4d6f1b4f4fde9e8cdc853b71c36212a90a61e77643e6379

See more details on using hashes here.

File details

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

File metadata

  • Download URL: context_server-2026.716.1-py3-none-manylinux_2_39_x86_64.whl
  • Upload date:
  • Size: 17.4 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.716.1-py3-none-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 be20ffa325e0229a44e0c5593d05d33e91d28e2d85a70ba3c92ef1eccc295428
MD5 83ef22a7af77ac17530ee443d088ebb2
BLAKE2b-256 bfc12fc7200416d9f8ad19c55e76da25450a5d1b25a83e38e28d55b22e87c0fd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: context_server-2026.716.1-py3-none-manylinux_2_39_aarch64.whl
  • Upload date:
  • Size: 17.8 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.716.1-py3-none-manylinux_2_39_aarch64.whl
Algorithm Hash digest
SHA256 dfbc73b6304051b7febca43dc8d10f0e315e93179ffc5ce3dfdb17d750c413b2
MD5 ef4f4fb54dd20ab857aee1614c63d95f
BLAKE2b-256 e1ae6ee209509c473e49d9eafb1d19ff33587078018492537374c0b28ca25c03

See more details on using hashes here.

File details

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

File metadata

  • Download URL: context_server-2026.716.1-py3-none-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 13.4 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.716.1-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3649a4e8733ab9e612d0432185f43005c7225d50b7861a97ff1eb0b354265115
MD5 a0a97d9feb873edf7e807d5123f75803
BLAKE2b-256 4dc962ce3d341c8f9a75215d6aaac96be2e235e4bd77779cbf9d574beab0a77a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page