PolarHub
  • Agents
  • MCP Servers
  • Skills
  • PolarBear
PolarHub © 2026
MCP Serversknowledge-and-memory码智
返回「knowledge-and-memory」

码智

modelscope·@sarathsp06/sourcesage

knowledge-and-memory0下载LocalModelScope

简介

SourceSage 是一个 MCP(模型上下文协议)服务器,能够高效记忆代码库的关键方面——逻辑、风格和标准——同时允许动态更新和快速检索。它被设计为与语言无关,利用 LLM 对多种语言代码的理解。

MCP Server 详情

来自 ModelScope 索引

SourceSage: 高效的代码记忆库,专为大语言模型设计

<a href="https://glama.ai/mcp/servers/@sarathsp06/sourcesage"> <img width="380" height="200" src="https://glama.ai/mcp/servers/@sarathsp06/sourcesage/badge" /> </a>

SourceSage 是一个 MCP(模型上下文协议)服务器,它能够高效地记住代码库的关键方面——逻辑、风格和标准,同时支持动态更新和快速检索。它的设计目标是与编程语言无关,利用大语言模型对多种编程语言的理解能力。

特性

  • 与编程语言无关:适用于大语言模型理解的任何编程语言
  • 知识图谱存储:高效存储代码实体、关系、模式和风格规范
  • 基于LLM的分析:依靠大语言模型来分析代码并提供见解
  • 令牌高效存储:在最大化内存容量的同时优化最小化令牌使用
  • 增量更新:当代码发生变化时更新知识,而不会产生冗余存储
  • 快速检索:实现相关信息的快速准确检索

工作原理

SourceSage 使用了一种新颖的方法:

  1. 大语言模型分析代码文件(任何语言)
  2. 大语言模型使用MCP工具注册实体、关系、模式和风格规范
  3. SourceSage 将这些知识以令牌高效的图形结构形式存储
  4. 当需要时,大语言模型可以查询这些知识

这种方法利用了大语言模型固有的语言理解能力,同时让MCP服务器专注于高效的内存管理。

安装

# Clone the repository
git clone https://github.com/yourusername/sourcesage.git
cd sourcesage

# Install the package
pip install -e .

使用方法

运行MCP服务器

# Run the server
sourcesage

# Or run directly from the repository
python -m sourcesage.mcp_server

连接到桌面版Claude

  1. 打开桌面版Claude
  2. 转到设置 > 开发者 > 编辑配置
  3. 在您的 claude_desktop_config.json 文件中添加以下内容:

如果您已安装包:

{
  "mcpServers": {
    "sourcesage": {
      "command": "sourcesage",
      "args": []
    }
  }
}

如果您从本地目录运行而不安装:

{
  "sourcesage": {
      "command": "uv", 
      "args": [
        "--directory",
        "/path/to/sourcesage",
        "run",
        "main.py"
      ]
    },
}
  1. 重启桌面版Claude

可用工具

SourceSage 提供了以下MCP工具:

  1. register_entity: Register a code entity in the knowledge graph

    Input:
      - name: Name of the entity (e.g., class name, function name)
      - entity_type: Type of entity (class, function, module, etc.)
      - summary: Brief description of the entity
      - signature: Entity signature (optional)
      - language: Programming language (optional)
      - observations: List of observations about the entity (optional)
      - metadata: Additional metadata (optional)
    Output: Confirmation message with entity ID
    
  2. register_relationship: Register a relationship between entities

    Input:
      - from_entity: Name of the source entity
      - to_entity: Name of the target entity
      - relationship_type: Type of relationship (calls, inherits, imports, etc.)
      - metadata: Additional metadata (optional)
    Output: Confirmation message with relationship ID
    
  3. register_pattern: Register a code pattern

    Input:
      - name: Name of the pattern
      - description: Description of the pattern
      - language: Programming language (optional)
      - example: Example code demonstrating the pattern (optional)
      - metadata: Additional metadata (optional)
    Output: Confirmation message with pattern ID
    
  4. register_style_convention: Register a coding style convention

    Input:
      - name: Name of the convention
      - description: Description of the convention
      - language: Programming language (optional)
      - examples: Example code snippets demonstrating the convention (optional)
      - metadata: Additional metadata (optional)
    Output: Confirmation message with convention ID
    
  5. add_entity_observation: Add an observation to an entity

    Input:
      - entity_name: Name of the entity
      - observation: Observation to add
    Output: Confirmation message
    
  6. query_entities: Query entities in the knowledge graph

    Input:
      - entity_type: Filter by entity type (optional)
      - language: Filter by programming language (optional)
      - name_pattern: Filter by name pattern (regex, optional)
      - limit: Maximum number of results to return (optional)
    Output: List of matching entities
    
  7. get_entity_details: Get detailed information about an entity

    Input:
      - entity_name: Name of the entity
    Output: Detailed information about the entity
    
  8. query_patterns: Query code patterns in the knowledge graph

    Input:
      - language: Filter by programming language (optional)
      - pattern_name: Filter by pattern name (optional)
    Output: List of matching patterns
    
  9. query_style_conventions: Query coding style conventions

    Input:
      - language: Filter by programming language (optional)
      - convention_name: Filter by convention name (optional)
    Output: List of matching style conventions
    
  10. get_knowledge_statistics: Get statistics about the knowledge graph

    Input: None
    Output: Statistics about the knowledge graph
    
  11. clear_knowledge: Clear all knowledge from the graph

    Input: None
    Output: Confirmation message
    

示例工作流与 Claude

  1. 分析代码:请 Claude 分析你的代码文件

    "请分析这个 Python 文件并注册关键实体和关系。"
    
  2. 注册实体:Claude 将使用 register_entity 工具来存储代码实体

    "我将在这个文件中注册主要的类。"
    
  3. 注册关系:Claude 将使用 register_relationship 工具来存储关系

    "我将注册这些类之间的继承关系。"
    
  4. 查询知识:之后,可以向 Claude 询问有关你的代码库的信息

    "我的代码库中定义了哪些类?"
    "给我展示 User 类的详细信息。"
    "User 类和 Profile 类之间有什么关系?"
    
  5. 获取编码模式:询问 Claude 关于编码模式的信息

    "在我的代码库中使用了哪些设计模式?"
    "给我展示我的代码中工厂模式的例子。"
    

它的不同之处

与传统的代码分析工具不同,SourceSage:

  1. 利用 LLM 的理解能力:利用 LLM 跨语言理解代码语义的能力
  2. 存储语义知识:专注于意义和关系,而不仅仅是语法
  3. 语言无关:适用于 LLM 理解的任何编程语言
  4. 优化令牌效率:以减少令牌使用的方式存储知识
  5. 随着 LLM 功能的发展而进化:随着 LLM 的改进,代码理解也会随之提高

贡献

欢迎贡献!请随时提交 Pull Request。

许可证

本项目采用 MIT 许可证 - 详情请参阅 LICENSE 文件。

相关 MCP Servers(来自「knowledge-and-memory」)

代码知识记忆库工具

通过向量嵌入技术,为项目提供记忆库和RAG上下文支持,以增强代码理解和管理,并与RooCode和Cline集成。

@davidvc/code-knowledge-mcptool

记忆库管理器

通过全局和分支特定的记忆库,管理跨 Claude AI 会话的项目文档和上下文的服务器,通过结构化的 JSON 文档存储实现一致的知识管理。

@t3ta/memory-bank-mcp-server

快递100 MCP Server

快递100 MCP Server提供快递信息查询、快递运费预估比价、快递时效查询(含发货前时效查询与在途动态时效查询)等功能。

kuaidi100/kuaidi100-mcp

模型上下文缓存器

一种模型上下文协议服务器,通过在语言模型交互之间高效缓存数据来减少令牌消耗,自动存储和检索信息以最小化冗余令牌使用。

@ibproduct/ib-mcp-cache-server

深度搜索推理增强服务

通过集成DeepSeek R1的高级推理引擎以处理复杂推理任务,从而增强Claude推理能力的服务器。

@moyu6027/deepseek-MCP-server

提示工坊

通过简化的SOLID架构,启用提示词的创建、管理和模板化,允许用户按类别组织提示词并在运行时填充模板。

@sparesparrow/mcp-prompts

自动安装

点击按钮会唤起 PolarBear 客户端,并把当前 MCP Server 的 Markdown 详情文档地址传给客户端。

/api/mcps/sarathsp06-sourcesage/markdown
打开 PolarBear 安装查看 Markdown 文档

手动安装

在 PolarBear 或其他支持 MCP 的客户端中,新建 MCP Server,并参考下方来源或安装提示配置。

# Clone the repository git clone https://github.com/yourusername/sourcesage.git cd sourcesage # Install the package pip install -e .

基本信息

分类
knowledge-and-memory / developer-tools / version-control
运行方式
No
许可证
MIT License
详情文件
sarathsp06-sourcesage.md