sourcesage

by sarathsp06
Verified

local-only server

The server can only run on the client’s local machine because it depends on local resources.

Integrations

  • Stores knowledge about code entities, relationships, patterns, and style conventions from a codebase, with support for incremental updates when code changes.

  • Referenced for source code management and contributions, allowing users to clone the repository and submit pull requests.

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

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

특징

  • 언어 무관 : LLM이 이해하는 모든 프로그래밍 언어로 작업 가능
  • 지식 그래프 저장소 : 코드 엔터티, 관계, 패턴 및 스타일 규칙을 효율적으로 저장합니다.
  • LLM 기반 분석 : LLM을 사용하여 코드를 분석하고 통찰력을 제공합니다.
  • 토큰 효율적 스토리지 : 메모리 용량을 최대화하면서 토큰 사용량을 최소화하도록 최적화합니다.
  • 증분 업데이트 : 중복 저장소 없이 코드가 변경될 때 지식을 업데이트합니다.
  • 빠른 검색 : 관련 정보를 빠르고 정확하게 검색할 수 있습니다.

작동 원리

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 라이선스에 따라 라이선스가 부여되었습니다. 자세한 내용은 라이선스 파일을 참조하세요.

-
security - not tested
A
license - permissive license
-
quality - not tested

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

  1. Features
    1. How It Works
      1. Installation
        1. Usage
          1. Running the MCP Server
          2. Connecting to Claude for Desktop
          3. Available Tools
        2. Example Workflow with Claude
          1. How It's Different
            1. Contributing
              1. License
                ID: wnhfsg4ui5