mcp-context-memory

mcp-context-memory

A local semantic memory and code-indexer that uses AST parsing for structural understanding and persists architectural decisions to help AI assistants bypass context window limits.

Category
访问服务器

README

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:

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

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选