# Context+

> An MCP server that turns a large codebase into a searchable, hierarchical feature graph

- Category: Retrieval & Knowledge (RAG) / Code Indexing & Search
- Language: TypeScript
- Licence: MIT
- Repository: https://github.com/forloopcodes/contextplus
- Website: https://contextplus.vercel.app
- Canonical page: https://ai-tldr.dev/tools/contextplus/

## In short

Context+ is a Model Context Protocol server that gives AI coding agents a semantic view of a codebase instead of making them read whole files. It combines retrieval over embeddings, Tree-sitter AST parsing, spectral clustering and Obsidian-style wikilinks to turn a large repository into what the project calls a searchable, hierarchical feature graph. It sits in the Code Indexing & Search category of the Retrieval & Knowledge (RAG) tools and is open-source, written in TypeScript and licensed MIT.

## Overview

Context+ is a Model Context Protocol server that gives AI coding agents a semantic view of a codebase instead of making them read whole files. It combines retrieval over embeddings, Tree-sitter AST parsing, spectral clustering and Obsidian-style wikilinks to turn a large repository into what the project calls a searchable, hierarchical feature graph.

The server exposes 17 MCP tools in five groups. Discovery tools return a structural AST tree of the project, a file's skeleton of signatures and line ranges, meaning-based code and identifier search, and clusters of semantically related files. Analysis tools trace every place a symbol is used and run native linters and compilers. Code-ops tools route writes through a validating `propose_commit` step, version-control tools let you list and undo AI changes through shadow restore points that never touch git history, and a memory graph stores typed, decaying relations between concepts, files and symbols.

It is written in TypeScript, runs over stdio, and is published to npm as `contextplus`, so it starts with `bunx` or `npx` without a separate install. Embeddings come from a local Ollama server by default, or from any OpenAI-compatible endpoint such as OpenAI, Gemini, Groq or vLLM. Embeddings are cached on disk in `.mcp_data/`, and a realtime tracker refreshes changed files and functions incrementally.

## What it does

- Structural discovery: `get_context_tree` and `get_file_skeleton` return AST trees, symbol line ranges and API surfaces without reading full file bodies
- Semantic search by meaning with `semantic_code_search` and `semantic_identifier_search`, plus `semantic_navigate`, which groups related files into labeled clusters via spectral clustering
- Impact analysis with `get_blast_radius`, and `run_static_analysis` that runs native linters and compilers for TypeScript, Python, Rust and Go
- Safe writes: `propose_commit` validates changes and creates a shadow restore point, and `undo_change` rolls back an AI edit without affecting git
- A memory graph with typed edges, semantic search with neighbor traversal, and decay-based pruning of stale links
- Multi-language AST parsing across 43 file extensions, gitignore-aware traversal and an `--include` flag for indexing gitignored sub-projects in monorepos

## Getting started

Context+ runs straight from npm, so setup is mostly adding it to your editor's MCP config. By default it uses a local Ollama server for embeddings.

1. Start an embedding model

   Ollama is the default embedding provider and needs no extra configuration beyond a running server with an embedding model.

```bash
ollama pull nomic-embed-text
ollama serve
```

2. Generate the MCP config for your agent

   The `init` subcommand writes the config file into the current directory. Supported targets are `claude`, `cursor`, `vscode`, `windsurf` and `opencode`.

```bash
npx -y contextplus init claude
bunx contextplus init cursor
```

3. Or add it to the config by hand

   For Claude Code, Cursor and Windsurf, register the server under `mcpServers` (Claude Code reads `.mcp.json`).

```json
{
  "mcpServers": {
    "contextplus": {
      "command": "bunx",
      "args": ["contextplus"],
      "env": {
        "OLLAMA_EMBED_MODEL": "nomic-embed-text",
        "OLLAMA_CHAT_MODEL": "gemma2:27b",
        "OLLAMA_API_KEY": "YOUR_OLLAMA_API_KEY"
      }
    }
  }
}
```

4. Switch to an OpenAI-compatible provider (optional)

   Set `CONTEXTPLUS_EMBED_PROVIDER` to `openai` and point it at any endpoint that implements the OpenAI Embeddings API, for example OpenAI itself.

```json
{
  "mcpServers": {
    "contextplus": {
      "command": "npx",
      "args": ["-y", "contextplus"],
      "env": {
        "CONTEXTPLUS_EMBED_PROVIDER": "openai",
        "OPENAI_API_KEY": "sk-...",
        "OPENAI_EMBED_MODEL": "text-embedding-3-small"
      }
    }
  }
}
```

5. Inspect a project from the terminal

   The `skeleton` (or `tree`) subcommand prints the structural tree with file headers and symbol definitions; `--include` adds gitignored paths back when running the server.

```bash
npx -y contextplus skeleton ./my-project
bunx contextplus /path/to/workspace --include repos/lacuna
```

## When to use it

- Let a coding agent find code by meaning in a large repository instead of grepping and reading whole files
- Check every file and line that uses a symbol before an agent renames or removes it
- Keep AI edits reversible with restore points that sit outside your git history
- Run codebase search fully offline with a local Ollama embedding model
