Persistent-Code MCP Server
带有 LlamaIndex 的持久代码 MCP 服务器
一个模型上下文协议 (MCP) 服务器,用于创建并维护由 Claude 生成的代码的语义知识图谱。该服务器由 LlamaIndex 提供支持,能够跨会话维护上下文,并具备高级语义搜索功能,无需在上下文窗口中显示整个代码库。
问题与解决方案
使用 Claude 开发软件时:
上下文窗口有限,难以处理大型代码库
会话之间丢失先前的代码上下文
Claude 缺乏对项目结构的持续理解
每个会话都需要对代码进行重复解释
保持实施的一致性具有挑战性
Persistent-Code 通过以下方式解决这些问题:
创建代码组件及其关系的知识图谱
跟踪每个组件的实施状态
提供导航、查询和理解代码库的工具
为特定的编码任务组装必要的最小上下文
在聊天会话中保持持久的知识
Related MCP server: Claude Server MCP
LlamaIndex 集成
Persistent-Code 利用 LlamaIndex 来提供增强的语义理解:
语义搜索:根据含义(而不仅仅是关键字)查找代码组件
向量嵌入:将代码嵌入到向量空间中以进行相似性匹配
知识图谱:从语义上跟踪组件之间的关系
上下文检索:根据语义相关性检索相关代码
这种集成使 Claude 能够更深入地了解您的代码库:
根据函数的功能来查找函数,而不仅仅是函数的名称
准备上下文时获取更多相关的代码组件
更好地理解组件之间的关系
更准确地检索类似实现的示例
安装
先决条件
Python 3.10 或更高版本
UV 包管理器(推荐)或 pip
设置
# Clone repository
git clone https://github.com/your-username/persistent-code-mcp.git
cd persistent-code-mcp
# Set up environment with UV
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
uv pip install -r requirements.txt
# Or with pip
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt用法
初始化项目
python -m persistent_code init --project-name "YourProject"启动服务器
python -m persistent_code serve --project-name "YourProject"为桌面配置 Claude
编辑您的 Claude for Desktop 配置文件:
位置:
~/Library/Application Support/Claude/claude_desktop_config.json添加以下配置:
{
"mcpServers": {
"persistent-code": {
"command": "path to python in venv",
"args": [
"-m",
"persistent_code",
"serve",
"--project-name",
"default"
],
"cwd": "persistent-code-mcp",
"env": {
"PYTHONPATH": "abs path to persistent-code-mcp"
}
}
}
}重启 Claude 桌面版
通过向 Claude 询问您的代码来连接到您的 MCP 服务器
可用工具
知识图谱管理
add_component:向图中添加新的代码组件update_component:更新现有组件add_relationship:创建组件之间的关系
代码检索和导航
get_component:通过 ID 或名称检索组件find_related_components:查找与给定组件相关的组件search_code:语义搜索代码库
状态管理
update_status:更新组件的实现状态get_project_status:检索整个项目的实施状态find_next_tasks:建议执行下一个逻辑组件
上下文组装
prepare_context:为特定任务组装最小上下文continue_implementation:提供上下文以继续实现组件get_implementation_plan:生成实施待处理组件的计划
代码分析
analyze_code:分析代码并更新知识图谱
示例工作流程
初始化项目:
python -m persistent_code init --project-name "TodoApp"启动服务器:
python -m persistent_code serve --project-name "TodoApp"请克劳德设计您的项目:
Can you help me design a Todo app with Python and FastAPI? Let's start with the core data models.Claude 将创建组件并在知识图谱中跟踪它们
在稍后的会话中继续开发:
Let's continue working on the Todo app. What's our implementation status?克劳德将检索当前状态并建议后续步骤
实现具体组件:
Let's implement the task completion endpoint for our Todo appClaude 将检索相关上下文并提供一致的实施
使用语义搜索
通过 LlamaIndex 集成,您现在可以使用更自然的语言来查找组件:
Find me all code related to handling task completion克劳德将使用语义搜索来查找相关组件,即使它们没有明确包含“任务完成”字样。
运行 LlamaIndex 演示
我们提供了一个演示脚本来展示语义功能:
# Activate your virtual environment
source .venv/bin/activate # or source venv/bin/activate
# Run the demo
python examples/llama_index_demo.py这将演示分析日历应用程序并执行功能语义搜索。
贡献
欢迎贡献代码!欢迎提交 Pull 请求。
执照
该项目根据 MIT 许可证获得许可 - 有关详细信息,请参阅 LICENSE 文件。
This server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Appeared in Searches
- TypeScript code analysis tools to reduce Claude API usage
- Trending MCP server for memory usage with GitHub Copilot integration
- A programming resource or code repository index
- Claude Desktop with persistent memory and artifact library system
- A server for managing systematic Drupal module development with advanced memory and project features
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/sparshdrolia/Persistent-code-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server