Skip to main content
Glama
maschmann

mcp-context-memory

by maschmann

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

Related MCP server: ProjectMind MCP

Available Tools

The server provides three MCP tools:

  1. index_project(path: str = "."): Scans a directory, parses code semantically using AST (Python, Java, PHP, TS, JS, HTML), and indexes it. Defaults to current directory.

  2. search_context(query: str): A unified search over AST nodes and past project decisions.

  3. 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:

  1. 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.

  2. Capturing Core Architecture: Use remember_decision to 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...")

  3. Indexing Documentation: If you have existing DOCS.md or ARCHITECTURE.md files, you can copy-paste their key insights into remember_decision to make them semantically searchable alongside the code.

  4. 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`.

Available Tools

3 tools
index_projectA

Scans the directory, respects .gitignore, and performs AST-based decomposition to index class definitions, methods, and structural HTML/CSS into 'code_semantics'.

Args: path: The absolute or relative path of the directory to index. Defaults to current directory.

ParametersJSON Schema
NameRequiredDescriptionDefault
pathNo.

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.1/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full transparency burden. It discloses important behavior like respecting .gitignore and using AST-based decomposition, but it does not explain side effects, persistence, repeatability, or whether the operation modifies files.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two concise sentences. The first delivers the core action and scope; the second handles the parameter. There is no redundant text or unnecessary detail.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Since an output schema exists, return-value details are not required. The description covers the input, behavior (.gitignore, AST), and destination ('code_semantics'), which is largely complete for a one-parameter indexing tool, though edge cases and sibling relationships are not discussed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema has no property description, but the Args section clearly defines 'path' as 'The absolute or relative path of the directory to index' and notes the default. This provides complete semantic meaning for the single parameter, going well beyond the bare schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb ('scans') and resource ('directory') while detailing the decomposition into class definitions, methods, and HTML/CSS structures. It clearly differentiates from sibling tools like 'search_context' and 'remember_decision' by describing an indexing operation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies the tool is for indexing a project to build 'code_semantics', but it does not explicitly state when to use it versus searching or remembering decisions. There are no exclusions or alternative tool references.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

remember_decisionB

Allows the LLM to save manual architectural notes or 'Why' something was built a certain way.

Args: topic: A short topic or category name for this decision. context: The detailed reasoning, architectural decision, or context.

ParametersJSON Schema
NameRequiredDescriptionDefault
topicYes
contextYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

B3.3/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries full burden. It discloses the tool's action (saving notes) but does not mention persistence behavior, whether it overwrites existing decisions, or any side effects. No annotation contradiction detected.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise and well-structured, with a lead sentence and clear arg list. No fluff or redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the simple two-string-parameter form, the description covers the essential purpose and params. However, it omits behavioral details (e.g., how decisions are stored or retrieved) and does not provide usage context relative to siblings, leaving minor gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema itself has 0% description coverage, but the tool description compensates by defining both params: topic as a short category and context as detailed reasoning. This gives meaningful semantic guidance beyond the raw string type.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool saves manual architectural notes or 'Why' decisions, using the verb 'save' with a specific resource. It distinguishes itself from sibling tools (index_project, search_context) by its save/remember role, though it doesn't explicitly name alternatives.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies use for recording architectural decisions but provides no explicit guidance on when to use it instead of search_context or index_project. No when-not-to-use conditions are given.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

search_contextA

A unified search that looks through both code structures (AST nodes) and past project decisions.

Args: query: The search query to find relevant context.

ParametersJSON Schema
NameRequiredDescriptionDefault
queryYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.2/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description must disclose behaviors. It states what the tool searches, but does not explicitly mention that it is read-only or non-destructive. The verb 'search' implies a read operation, but this is not explicitly confirmed, and no side effects or limitations are disclosed.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is very brief: one sentence plus a parameter argument. It is front-loaded with the core purpose and contains no filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple single-parameter search tool, the description covers the essential purpose and parameter semantics. An output schema exists, so return values are handled elsewhere. It lacks usage examples or explicit limitations, but is largely complete for the tool's complexity.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 0%, so the description compensates by explaining the query parameter: 'The search query to find relevant context.' This adds meaning beyond the bare string type, though it is minimal and lacks examples or nuances about matching behavior.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description explicitly states 'unified search' and specifies the resources: 'code structures (AST nodes)' and 'past project decisions'. This clearly distinguishes it from sibling tools (index_project, remember_decision) which are about writing/storing rather than searching.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context: it is the retrieval complement to index_project and remember_decision, as it searches across both types of data. However, it does not explicitly state when not to use this tool or mention alternatives.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 3 tool updatesv0.3.1
    • First observedindex_project
    • First observedremember_decision
    • First observedsearch_context

TDQS

A4/5.0
Disambiguation5/5

Each tool has a clear, distinct purpose: index_project builds the semantic index, search_context queries it, and remember_decision stores explicit architectural notes. There is no functional overlap between these three operations.

Naming Consistency5/5

All tool names follow the same verb_noun pattern: index_project, search_context, remember_decision. The verbs are concise and the nouns accurately describe the target resource, making the API predictable and easy to navigate.

Tool Count5/5

With only 3 tools, the server is tightly scoped to its stated purpose of context memory. Each tool covers a distinct fundamental operation (index, search, remember), and there is no bloat or redundancy.

Completeness4/5

The tool set covers the core lifecycle of context memory: ingest (index_project), query (search_context), and explicit knowledge persistence (remember_decision). Minor gaps include lack of delete/update for decisions and no re-indexing mechanism, but these are not critical for the primary workflow.

Maintenance

ActivityInactive
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/maschmann/mcp-context-memory'

If you have feedback or need assistance with the MCP directory API, please join our Discord server