Skip to main content
Glama

SourceSage: LLM을 위한 효율적인 코드 메모리

SourceSage는 코드베이스의 핵심 요소(논리, 스타일, 표준)를 효율적으로 기억하는 동시에 동적 업데이트와 빠른 검색을 지원하는 MCP(Model Context Protocol) 서버입니다. 언어에 구애받지 않고 LLM이 여러 언어의 코드를 이해하는 방식을 활용하도록 설계되었습니다.

특징

  • 언어 무관 : LLM이 이해하는 모든 프로그래밍 언어로 작업 가능

  • 지식 그래프 저장소 : 코드 엔터티, 관계, 패턴 및 스타일 규칙을 효율적으로 저장합니다.

  • LLM 기반 분석 : LLM을 사용하여 코드를 분석하고 통찰력을 제공합니다.

  • 토큰 효율적 스토리지 : 메모리 용량을 최대화하면서 토큰 사용량을 최소화하도록 최적화합니다.

  • 증분 업데이트 : 중복 저장소 없이 코드가 변경될 때 지식을 업데이트합니다.

  • 빠른 검색 : 관련 정보를 빠르고 정확하게 검색할 수 있습니다.

Related MCP server: Logseq MCP Tools

작동 원리

SourceSage는 다음과 같은 새로운 접근 방식을 사용합니다.

  1. LLM은 코드 파일(모든 언어)을 분석합니다.

  2. LLM은 MCP 도구를 사용하여 엔터티, 관계, 패턴 및 스타일 규칙을 등록합니다.

  3. SourceSage는 이 지식을 토큰 효율적인 그래프 구조로 저장합니다.

  4. LLM은 나중에 필요할 때 이 지식을 쿼리할 수 있습니다.

이 접근 방식은 MCP 서버의 효율적인 메모리 관리에 집중하는 동시에 LLM의 고유한 언어 이해력을 활용합니다.

설치

지엑스피1

용법

MCP 서버 실행

# Run the server
sourcesage

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

데스크톱용 Claude에 연결

  1. 데스크톱용 Open 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 : 지식 그래프에 코드 엔터티를 등록합니다.

    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 : 엔티티 간 관계를 등록합니다.

    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 : 코드 패턴을 등록합니다

    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 : 코딩 스타일 규칙을 등록합니다.

    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 : 엔티티에 관찰을 추가합니다.

    Input:
      - entity_name: Name of the entity
      - observation: Observation to add
    Output: Confirmation message
  6. query_entities : 지식 그래프의 쿼리 엔터티

    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 : 엔터티에 대한 자세한 정보를 가져옵니다.

    Input:
      - entity_name: Name of the entity
    Output: Detailed information about the entity
  8. query_patterns : 지식 그래프의 쿼리 코드 패턴

    Input:
      - language: Filter by programming language (optional)
      - pattern_name: Filter by pattern name (optional)
    Output: List of matching patterns
  9. query_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 : 지식 그래프에 대한 통계를 가져옵니다.

Input: None
Output: Statistics about the knowledge graph
  1. clear_knowledge : 그래프에서 모든 지식을 지웁니다.

Input: None
Output: Confirmation message

Claude를 사용한 워크플로 예시

  1. 코드 분석 : Claude에게 코드 파일을 분석해 달라고 요청하세요.

    "Please analyze this Python file and register the key entities and relationships."
  2. 엔터티 등록 : Claude는 register_entity 도구를 사용하여 코드 엔터티를 저장합니다.

    "I'll register the main class in this file."
  3. 관계 등록 : Claude는 register_relationship 도구를 사용하여 관계를 저장합니다.

    "I'll register the inheritance relationship between these classes."
  4. 지식 쿼리 : 나중에 Claude에게 코드베이스에 대해 물어보세요.

    "What classes are defined in my codebase?"
    "Show me the details of the User class."
    "What's the relationship between the User and Profile classes?"
  5. 코딩 패턴 얻기 : Claude에게 코딩 패턴에 대해 물어보세요

    "What design patterns are used in my codebase?"
    "Show me examples of the Factory pattern in my code."

어떻게 다른가

기존 코드 분석 도구와 달리 SourceSage는 다음과 같은 기능을 제공합니다.

  1. LLM 이해 활용 : LLM의 기능을 활용하여 여러 언어의 코드 의미를 이해합니다.

  2. 의미 지식을 저장합니다 . 구문뿐만 아니라 의미와 관계에 초점을 맞춥니다.

  3. 언어에 구애받지 않음 : LLM이 이해하는 모든 프로그래밍 언어와 호환 가능

  4. 토큰 효율성을 최적화합니다 . 토큰 사용량을 최소화하는 방식으로 지식을 저장합니다.

  5. LLM 역량 향상에 따른 진화 : LLM이 향상됨에 따라 코드 이해도 향상됩니다.

기여하다

기여를 환영합니다! 풀 리퀘스트를 제출해 주세요.

특허

이 프로젝트는 MIT 라이선스에 따라 라이선스가 부여되었습니다. 자세한 내용은 라이선스 파일을 참조하세요.

Available Tools

13 tools
add_entity_observationC

Add an observation to an entity.

Args: entity_name: Name of the entity observation: Observation to add

Inputs: entity_name (required), observation (required).

clear_knowledgeA

Clear all knowledge from the graph.

Inputs: no named parameters.

dump_project_understandingA

Dump understanding of an entire project at once.

This tool provides a comprehensive dump of all knowledge related to a project, including all entities, relationships, patterns, and style conventions.

Args: project_path: Path to the project root directory include_observations: Whether to include detailed observations

Inputs: project_path (required), include_observations.

get_entity_detailsC

Get detailed information about an entity.

Args: entity_name: Name of the entity

Inputs: entity_name (required).

get_knowledge_statisticsC

Get statistics about the knowledge graph.

Inputs: no named parameters.

load_project_understandingB

Load understanding of an entire project at once.

This tool should be used by MCP clients to quickly get project understanding if available, instead of reading all the files individually. It loads all entities, relationships, patterns, and style conventions related to the project.

Args: project_path: Path to the project root directory

Inputs: project_path (required).

query_entitiesB

Query entities in the knowledge graph.

Args: entity_type: Filter by entity type (class, function, module, etc.) language: Filter by programming language name_pattern: Filter by name pattern (regex) limit: Maximum number of results to return

Inputs: entity_type, language, limit, name_pattern.

query_patternsB

Query code patterns in the knowledge graph.

Args: language: Filter by programming language pattern_name: Filter by pattern name

Inputs: language, pattern_name.

query_style_conventionsA

Query coding style conventions in the knowledge graph.

Args: language: Filter by programming language convention_name: Filter by convention name

Inputs: convention_name, language.

register_entityB

Register a code entity in the knowledge graph.

Args: 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 (e.g., function signature) language: Programming language observations: List of observations about the entity metadata: Additional metadata as key-value pairs

Inputs: entity_type (required), name (required), summary (required), language, +3 more.

register_patternB

Register a code pattern.

Args: name: Name of the pattern description: Description of the pattern language: Programming language example: Example code demonstrating the pattern metadata: Additional metadata as key-value pairs

Inputs: description (required), name (required), example, language, +1 more.

register_relationshipC

Register a relationship between entities.

Args: 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 as key-value pairs

Inputs: from_entity (required), relationship_type (required), to_entity (required), metadata.

register_style_conventionC

Register a coding style convention.

Args: name: Name of the convention description: Description of the convention language: Programming language examples: Example code snippets demonstrating the convention metadata: Additional metadata as key-value pairs

Inputs: description (required), name (required), examples, language, +1 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.3/5.0

    Scored across 13 tools

    Disambiguation4/5

    Most tools have distinct purposes focused on different aspects of knowledge graph management (entities, patterns, relationships, style conventions). However, there is some potential overlap between dump_project_understanding and load_project_understanding as both handle project-level data, though their descriptions clarify one is for output and the other for input.

    Naming Consistency5/5

    All tools follow a consistent snake_case naming pattern with clear verb_noun structure (e.g., add_entity_observation, get_entity_details, query_entities, register_entity). The naming is predictable and uniform across all 13 tools.

    Tool Count5/5

    With 13 tools, this is well-scoped for a knowledge graph server covering entities, patterns, relationships, and style conventions. Each tool serves a specific function in the CRUD/lifecycle operations, and none appear redundant or out of place.

    Completeness4/5

    The toolset provides comprehensive coverage for managing a knowledge graph, including registration, querying, and statistics. Minor gaps exist, such as no explicit update or delete operations for entities/patterns/relationships/conventions, but agents can work around this by re-registering or using clear_knowledge.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      A
      maintenance
      This is an MCP server for PostgREST. It allows LLMs perform database queries and operations on Postgres databases via PostgREST. This server works with both Supabase projects (which use PostgREST) and standalone PostgREST servers.
      2,128 npm
      3,017
      Apache 2.0
    • A
      license
      Not graded
      quality
      D
      maintenance
      A Model Context Protocol server that provides AI assistants with structured access to your Logseq knowledge graph, enabling retrieval, searching, analysis, and creation of content within your personal knowledge base.
      70
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      An MCP server that connects to a Swagger specification and helps an AI to build all the required models to generate a MCP server for that service.
      5
      167
      MIT