Token导航 LogoToken导航TokenDH.com
MCP Context Memory logo
运维云端未说明官方级别未说明来源级核验

MCP Context Memory

MCP Server

基于Python的高端MCP服务器,提供本地语义记忆和代码索引功能,帮助AI助手突破上下文窗口限制。

工具数

3

提示词数

0

GitHub Stars

0

资源数

0
代码索引PythonClaudeClaude DesktopClaude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

maschmann

提供方

maschmann

最后核验

2026/5/17 20:22

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

详细介绍

语义项目大脑MCP服务器

一个基于Python的高端MCP(模型上下文协议)服务器,提供本地语义内存和代码索引器。使用 tree-sitter 用于基于AST的源代码解析,以理解类定义、方法签名和结构,而不是简单的文本分块。它还充当“长期记忆”,通过在会话中持久化架构决策,帮助AI助手绕过上下文窗口限制。

服务器使用 ChromaDB 用于快速、本地嵌入存储,并将其数据存储在 .context_db 当前项目目录中的文件夹。

先决条件

你需要 紫外线 安装后,无需手动管理虚拟环境即可运行服务器。

# Install uv if you haven't already
curl -LsSf https://astral.sh/uv/install.sh | sh

可用工具

服务器提供三个MCP工具:

  1. index_project(path: str = "."):扫描目录,使用AST(Python、Java、PHP、TS、JS、HTML)从语义上解析代码,并对其进行索引。默认为当前目录。
  2. search_context(query: str):对AST节点和过去的项目决策进行统一搜索。
  3. remember_decision(topic: str, context: str):保存手动架构注释或推理(例如,“我们为什么选择框架X”)。

使用AI助手

您可以使用 uvx (部分 uv)直接从PyPI运行此服务器。这是使用语义项目大脑的推荐方式,因为它会自动处理所有依赖关系。

Claude桌面集成

要在Claude Desktop中安装和使用此MCP服务器,请将以下内容添加到您的 claude_desktop_config.json:

{
  "mcpServers": {
    "semantic-brain": {
      "command": "uvx",
      "args": ["mcp-context-memory"],
      "alwaysAllow": [
        "index_project",
        "search_context",
        "remember_decision"
      ]
    }
  }
}

光标集成

在光标中,转到 设置>功能>MCP 并添加新的MCP服务器:

  • 姓名: 语义大脑
  • 类型: command
  • 命令: uvx mcp-context-memory

启动现有项目

为了在现有代码库中充分利用语义项目大脑,请按照以下步骤为其添加相关上下文:

  1. 初始语义索引:

运行索引工具来构建代码的初始AST映射: index_project(path=".") 这使大脑能够立即理解你的类、方法和结构化HTML。

  1. 捕获核心架构:

使用 remember_decision 记录项目的基本“为什么”。初次参赛的优秀候选人包括:

- 技术栈选择: remember_decision(topic="Tech Stack", context="We use Symfony 7 with PHP 8.3 because...") - 数据库模式: remember_decision(topic="Data Model", context="The 'Orders' table is partitioned by year to handle high volume...") - 身份验证流程: remember_decision(topic="Auth", context="JWT tokens are handled via LexikJWTAuthenticationBundle with a 1-hour TTL...")

  1. 索引文档:

如果你有现有 DOCS.mdARCHITECTURE.md 文件,您可以将其关键见解复制粘贴到 remember_decision 使它们与代码一起在语义上可搜索。

  1. 验证:

通过问一个问题来测试大脑的“记忆” search_context(query="How is authentication handled?")。如果它返回您存储的决策,它已准备好提供帮助。

人工智能代理说明(Agents.md)

复制以下块并将其粘贴到项目的 .cursorrules, AGENTS.md,或 GEMINI.md 指示LLM如何使用此服务器:

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

目录标签

目录标签

代码索引PythonClaude本地部署语义分析AI辅助开发长期记忆AST解析

支持客户端

Claude DesktopClaude

接入字段

传输方式(transport,传输协议)

未说明

鉴权方式(authType,认证方式)

none

工具数量(toolCount,工具数)

3

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

未说明none部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

仍需确认:installCommand

来源信息

继续浏览同类 MCP