Semantic Project Brain MCP Server with AST Parsing
Project description
Semantic Project Brain MCP Server
A high-end Python-based MCP (Model Context Protocol) server that provides a local, semantic memory and code-indexer. It uses tree-sitter for AST-based parsing of source code to understand class definitions, method signatures, and structures, rather than naive text chunking. It also acts as a "Long-Term Memory" to help AI assistants bypass context window limits by persisting architectural decisions across sessions.
The server uses ChromaDB for fast, local embedding storage, and stores its data in a .context_db folder within your current project directory.
Prerequisites
You need uv installed to run the server without managing virtual environments manually.
# Install uv if you haven't already
curl -LsSf https://astral.sh/uv/install.sh | sh
Available Tools
The server provides three MCP tools:
index_project(path: str): Scans a directory, parses code semantically using AST (Python, Java, PHP, TS, JS, HTML), and indexes it.search_context(query: str): A unified search over AST nodes and past project decisions.remember_decision(topic: str, context: str): Saves manual architectural notes or reasoning (e.g., "Why we chose framework X").
Usage with AI Assistants
You can use uvx (part of uv) to run this server directly from PyPI. This is the recommended way to use the Semantic Project Brain as it handles all dependencies automatically.
Claude Desktop Integration
To install and use this MCP server with Claude Desktop, add the following to your claude_desktop_config.json:
{
"mcpServers": {
"semantic-brain": {
"command": "uvx",
"args": ["mcp-context-memory"],
"alwaysAllow": [
"index_project",
"search_context",
"remember_decision"
]
}
}
}
Cursor Integration
In Cursor, go to Settings > Features > MCP and add a new MCP Server:
- Name: Semantic Brain
- Type:
command - Command:
uvx mcp-context-memory
Bootstrapping an Existing Project
To get the most out of the Semantic Project Brain in an existing codebase, follow these steps to seed it with relevant context:
-
Initial Semantic Indexing: Run the indexing tool to build the initial AST-based map of your code:
index_project(path=".")This allows the brain to immediately understand your classes, methods, and structural HTML. -
Capturing Core Architecture: Use
remember_decisionto document the foundational "Why" of the project. Good candidates for initial entries include:- Tech Stack Choice:
remember_decision(topic="Tech Stack", context="We use Symfony 7 with PHP 8.3 because...") - Database Schema:
remember_decision(topic="Data Model", context="The 'Orders' table is partitioned by year to handle high volume...") - Authentication Flow:
remember_decision(topic="Auth", context="JWT tokens are handled via LexikJWTAuthenticationBundle with a 1-hour TTL...")
- Tech Stack Choice:
-
Indexing Documentation: If you have existing
DOCS.mdorARCHITECTURE.mdfiles, you can copy-paste their key insights intoremember_decisionto make them semantically searchable alongside the code. -
Verification: Test the brain's "memory" by asking it a question through
search_context(query="How is authentication handled?"). If it returns your stored decisions, it's ready to assist.
Instructions for AI Agents (AGENTS.md)
Copy the following block and paste it into your project's .cursorrules, AGENTS.md, or GEMINI.md to instruct the LLM on how to use this server:
# Semantic Project Brain Usage Guidelines
You have access to the `semantic-brain` MCP server. Follow these rules rigorously:
1. **Re-indexing:**
- If you make significant structural changes (e.g., creating a new module, renaming classes, or refactoring), you MUST trigger `index_project(path=".")` when you finish to keep the AST index up to date.
- If you cannot find expected code in `search_context`, trigger an index update first.
2. **Understanding the Codebase:**
- Use `search_context(query="ClassName")` to understand class hierarchies, locate method definitions, and retrieve precise semantic chunks of code instead of grepping the entire workspace.
3. **Remembering Decisions:**
- Before completing a task that involved a notable architectural decision, tradeoff, or complex logic, you are OBLIGATED to call `remember_decision(topic="...", context="...")`.
- Store "Why" something was built a certain way, so you and other agents can retrieve it in future sessions using `search_context`.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcp_context_memory-0.3.0.tar.gz.
File metadata
- Download URL: mcp_context_memory-0.3.0.tar.gz
- Upload date:
- Size: 147.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7800239c23d26d1ca335a1050ed6f88a53c8f552cae6906f32da1df7b211a7c
|
|
| MD5 |
2ab3871b9deb05ca9d69fa443110117b
|
|
| BLAKE2b-256 |
ccfbf67cf5ba8e59047be22f17a3053d32bbf0f85f19f1389c10d3f77ecbb9f8
|
Provenance
The following attestation bundles were made for mcp_context_memory-0.3.0.tar.gz:
Publisher:
pypi-publish.yml on maschmann/mcp-context-memory
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mcp_context_memory-0.3.0.tar.gz -
Subject digest:
c7800239c23d26d1ca335a1050ed6f88a53c8f552cae6906f32da1df7b211a7c - Sigstore transparency entry: 1191162459
- Sigstore integration time:
-
Permalink:
maschmann/mcp-context-memory@3c1ebeb5b63e29cd657718830712770258e4819f -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/maschmann
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@3c1ebeb5b63e29cd657718830712770258e4819f -
Trigger Event:
push
-
Statement type:
File details
Details for the file mcp_context_memory-0.3.0-py3-none-any.whl.
File metadata
- Download URL: mcp_context_memory-0.3.0-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
466a74cbc67a77fc8a7e6a8d104e230319a947701b8d9e096bd68872da4addc4
|
|
| MD5 |
9abafeb6c7d45f604ef17d561208c83b
|
|
| BLAKE2b-256 |
2f0455c24075dd93dd73de83def195e448dc77a1c7a1e17c93a459a80752460a
|
Provenance
The following attestation bundles were made for mcp_context_memory-0.3.0-py3-none-any.whl:
Publisher:
pypi-publish.yml on maschmann/mcp-context-memory
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mcp_context_memory-0.3.0-py3-none-any.whl -
Subject digest:
466a74cbc67a77fc8a7e6a8d104e230319a947701b8d9e096bd68872da4addc4 - Sigstore transparency entry: 1191162466
- Sigstore integration time:
-
Permalink:
maschmann/mcp-context-memory@3c1ebeb5b63e29cd657718830712770258e4819f -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/maschmann
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@3c1ebeb5b63e29cd657718830712770258e4819f -
Trigger Event:
push
-
Statement type: