Skip to main content
Glama

sourcesage

SourceSage: LLM のための効率的なコードメモリ

SourceSageは、コードベースの主要な側面(ロジック、スタイル、標準)を効率的に記憶し、動的な更新と高速な取得を可能にするMCP(Model Context Protocol)サーバーです。LLMの複数言語にわたるコード理解を活用し、言語に依存しないように設計されています。

特徴

  • 言語に依存しない: LLMが理解できるあらゆるプログラミング言語で動作します
  • ナレッジグラフストレージ: コードエンティティ、関係、パターン、スタイル規則を効率的に保存します
  • LLM駆動型分析:LLMを利用してコードを分析し、洞察を提供する
  • トークン効率の高いストレージ: メモリ容量を最大化しながらトークンの使用を最小限に抑えるように最適化します。
  • 増分更新:冗長ストレージなしでコードが変更されたときに知識を更新します
  • 高速検索:関連情報を迅速かつ正確に検索できます

仕組み

SourceSage は次のような斬新なアプローチを採用しています:

  1. LLMはコードファイル(あらゆる言語)を分析します
  2. LLMはMCPツールを使用して、エンティティ、関係、パターン、およびスタイル規則を登録します。
  3. SourceSageはこの知識をトークン効率の良いグラフ構造に保存する
  4. LLMは必要に応じてこの知識を後で照会できる。

このアプローチは、LLM の固有の言語理解を活用しながら、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 for Desktop への接続

  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 : ナレッジグラフにコードエンティティを登録する
    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

クロードによるワークフローの例

  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. コーディングパターンを入手する: コーディングパターンについてクロードに質問する
    "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 ライセンスに基づいてライセンスされています - 詳細については LICENSE ファイルを参照してください。

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

SourceSageは、コードベースの主要な側面(ロジック、スタイル、標準)を効率的に記憶し、動的な更新と高速な取得を可能にするMCP(Model Context Protocol)サーバーです。LLMの複数言語にわたるコード理解を活用し、言語に依存しないように設計されています。

  1. 特徴
    1. 仕組み
      1. インストール
        1. 使用法
          1. MCPサーバーの実行
          2. Claude for Desktop への接続
          3. 利用可能なツール
        2. クロードによるワークフローの例
          1. どう違うのか
            1. 貢献
              1. ライセンス

                Related MCP Servers

                • -
                  security
                  A
                  license
                  -
                  quality
                  A Model Context Protocol (MCP) server that enables semantic search and retrieval of documentation using a vector database (Qdrant). This server allows you to add documentation from URLs or local files and then search through them using natural language queries.
                  Last updated -
                  14
                  74
                  JavaScript
                  Apache 2.0
                  • Apple
                • -
                  security
                  F
                  license
                  -
                  quality
                  An MCP server that enables language models to access code intelligence features like completions, definitions, and references across multiple programming languages through the Language Server Protocol.
                  Last updated -
                  Python
                • -
                  security
                  A
                  license
                  -
                  quality
                  A MCP server that transforms code repositories from GitHub, GitLab, or local directories into LLM-friendly formats, preserving context and structure for better AI processing.
                  Last updated -
                  1
                  Python
                  Apache 2.0
                • -
                  security
                  A
                  license
                  -
                  quality
                  An MCP server that analyzes codebases and generates contextual prompts, making it easier for AI assistants to understand and work with code repositories.
                  Last updated -
                  10
                  Python
                  MIT License

                View all related MCP servers

                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/sarathsp06/sourcesage'

                If you have feedback or need assistance with the MCP directory API, please join our Discord server