Skip to main content

Semantic codebase indexer and MCP server for Claude Code

Project description

Sema

Sema

PyPI version Python versions VS Code Marketplace License: MIT

Experimental — sema is under active development. APIs and index formats may change between versions. See the disclaimer.

Stop wasting tokens — on navigating your codebase, and on rewriting code that already exists. Speed up Claude Code and OpenAI Codex on large codebases.

Sema is a semantic code indexer and MCP server. It indexes your entire codebase locally — every function, class, and method — and gives your AI assistant a search API so it never reads files blindly again, plus a reuse guard so it stops reinventing helpers you already have.

That same index also powers the sema VS Code extension — a Cursor-style chat panel for your codebase. Talk to it through the Claude Code and Codex you already run locally (no re-login), or your own Anthropic / OpenAI API keys — switching provider and model within a single conversation, and toggling the index on to hand the chat exactly the code it needs.

Works with Claude Claude Code CLI, VS Code Claude Code VS Code, Codex OpenAI Codex CLI, and Codex Codex VS Code. Plus sema's own VS Code VS Code extension — a Cursor-style chat panel that talks to your codebase through the Claude Code and Codex you already run locally, or your own API keys.

Features

  • 🔍 Semantic searchsearch_code() finds code by meaning and returns signatures only (~150 tokens), never whole files.
  • ♻️ Reuse guardcheck_reuse() tells your assistant whether a function already exists before it writes a new one, so it reuses instead of reinventing. 98% reuse-vs-build accuracy in a 50-example eval on real code.
  • 🕸️ Impact analysisimpact_analysis() maps the call graph in both directions, so the AI sees the blast radius before a refactor.
  • 📁 Multi-project — one sema init --root <dir> serves every indexed repo under a directory; no re-registration when you switch projects.
  • 🔒 Local & offline — embeddings run on your machine (SBERT, ~80MB). No API keys, no internet, no code leaves your laptop.
  • 🧩 VS Code extension — a Cursor-style chat panel: chat with Claude Code / Codex / Anthropic / OpenAI, switching provider and model in one session, with the index as context — plus search, reuse, and index management. Get it on the Marketplace →

Why sema

Every Claude Code and Codex session starts cold. On a large project, your AI assistant burns 10,000–25,000 tokens just navigating — running find, reading full files, building a mental model from scratch — before it can help with anything.

Sema gives it a search index instead. Instead of reading a dozen files to answer "how does auth work?", the AI runs one search_code() and fetches only the exact function bodies it needs — typically 4–11× fewer tokens. Index once. Your AI searches forever.

That's the reading half of the token bill. Sema goes after the writing half too: before your assistant adds a new helper, check_reuse() searches the index for an existing one and answers reuse / review / safe-to-build — so it extends what's already there instead of shipping a fourth function that does the same thing.

See the benchmarks for measured token savings on real open-source repos.

Quick start

# 1. Install — provides the `sema` command
pip install sema-mcp        # or: uv tool install sema-mcp

# 2. Index your project and register with your AI assistant
cd your-project
sema index .
sema init --claude     # or: sema init --codex

# 3. Reload VS Code, then type /mcp to confirm sema is connected

Requires Python 3.11+. On PyPI the package is sema-mcp (the name sema was taken), but the command and import stay sema. Working on sema itself? Install from source.

Then add a CLAUDE.md (or AGENTS.md for Codex) so your assistant calls sema before reading files — see Claude Code setup or OpenAI Codex setup.

Requires Python 3.11+. No Docker, no external APIs, no GPU — everything runs on your machine.

How it works

sema index . uses tree-sitter to parse every function, class, and method, embeds each one locally with SBERT (all-MiniLM-L6-v2), and stores the vectors plus full source in an embedded ChromaDB. A local MCP server then exposes search tools to Claude/Codex over stdio. search_code() returns signatures only; get_code() returns full bodies on demand.

The same index powers the rest of the toolset: check_reuse() (does this already exist?), impact_analysis() (call graph and blast radius), and multi-project serving — all fully offline.

See Architecture for the full picture.

sema for VS Code

VS Marketplace Version Installs

Prefer a UI? The sema VS Code extension is on the VS Code Marketplace — a Cursor-style chat panel for your codebase, backed by the same local index. Chat through the Claude Code and Codex you already have installed (or your own API keys), and switch provider and model mid-session:

  • 💬 Chat with your code through four providers — Claude Code and Codex running locally (reuse your existing login, no API key; they read the repo and, in Agent mode, edit it), or the Anthropic and OpenAI APIs with your own key.
  • 🧭 Ask / Agent modes, a reasoning-effort selector, streamed thinking and tool activity, and per-session memory — just like the terminal apps, and prompts pass straight through (no wrapper persona).
  • 🔎 Semantic index toggle — inject sema's retrieved context (RAG) on demand; the same search_code / check_reuse power the panel.
  • 🛠️ Manage panel — index status, one-click re-index / register / watch / doctor, and live token usage + estimated cost for the session.
  • ⚡ Search and Reuse from the command palette, with index freshness in the status bar.

Install: search "sema" in the Extensions view, run code --install-extension MasihMoloodian.sema-codebase-chat, or open the Marketplace listing. Prefer to build from source? See the extension guide.

Documentation

Full docs live in docs/:

Installation Requirements, pip install, and install from source
sema for VS Code sema's own VS Code extension — chat panel, search, reuse, and index management
Claude Code setup · Codex setup · VS Code workspace Register sema with your assistant
Working with multiple projects Serve many repos from one registration
CLI reference Every sema command
MCP tools The tools your AI assistant calls
Supported languages AST-aware vs text-aware indexing
Configuration Config file, env vars, .gitignore
Managing sema Update, remove, and when to re-index
Troubleshooting Fixes for common issues
Benchmarks · FAQ · Roadmap Background and details
Contributing Development setup and how to extend sema

Contributing

Contributions are welcome — sema is intentionally small and easy to extend. See Contributing for development setup and how to add a new language.

License

MIT License — free to use, modify, and distribute. See LICENSE.

Copyright (c) 2026 Masih Moloodian

Contact

Masih Moloodian · masihmoloodian@gmail.com

Issues and feature requests: github.com/masihmoloodian/sema/issues

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

sema_mcp-0.1.2.tar.gz (46.4 kB view details)

Uploaded Source

Built Distribution

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

sema_mcp-0.1.2-py3-none-any.whl (58.4 kB view details)

Uploaded Python 3

File details

Details for the file sema_mcp-0.1.2.tar.gz.

File metadata

  • Download URL: sema_mcp-0.1.2.tar.gz
  • Upload date:
  • Size: 46.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for sema_mcp-0.1.2.tar.gz
Algorithm Hash digest
SHA256 e6bdc44d15b491a35e12e360deb7999f594f923af0d6a42748cffc5c22d1550f
MD5 bb3ccfad47ad7304b69fed849bee837a
BLAKE2b-256 a12fd1e1b0b0d50b31461dc706f41c012f6dd1b3c5a32aaaae75f0c4d85cccb6

See more details on using hashes here.

File details

Details for the file sema_mcp-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: sema_mcp-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 58.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for sema_mcp-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 49f59112cd119316af089bc6a070a636533ff3b0ffecb0bdb311a80f7c0fe123
MD5 8474387bf535c6132c2919a2b5ed0e9b
BLAKE2b-256 72c9e382437bb7c627526092cd46dbc023a94dc53c9637dfb6fc7a2cc164f0b3

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