SourceSage: LLM のための効率的なコードメモリ
SourceSageは、コードベースの主要な側面(ロジック、スタイル、標準)を効率的に記憶し、動的な更新と高速な取得を可能にするMCP(Model Context Protocol)サーバーです。LLMの複数言語にわたるコード理解を活用し、言語に依存しないように設計されています。
特徴
言語に依存しない: LLMが理解できるあらゆるプログラミング言語で動作します
ナレッジグラフストレージ: コードエンティティ、関係、パターン、スタイル規則を効率的に保存します
LLM駆動型分析:LLMを利用してコードを分析し、洞察を提供する
トークン効率の高いストレージ: メモリ容量を最大化しながらトークンの使用を最小限に抑えるように最適化します。
増分更新:冗長ストレージなしでコードが変更されたときに知識を更新します
高速検索:関連情報を迅速かつ正確に検索できます
Related MCP server: Logseq MCP Tools
仕組み
SourceSage は次のような斬新なアプローチを採用しています:
LLMはコードファイル(あらゆる言語)を分析します
LLMはMCPツールを使用して、エンティティ、関係、パターン、およびスタイル規則を登録します。
SourceSageはこの知識をトークン効率の良いグラフ構造に保存する
LLMは必要に応じてこの知識を後で照会できる。
このアプローチは、LLM の固有の言語理解を活用しながら、MCP サーバーを効率的なメモリ管理に重点を置きます。
インストール
使用法
MCPサーバーの実行
Claude for Desktop への接続
デスクトップ版Claudeを開く
設定 > 開発者 > 設定の編集に移動します
claude_desktop_config.jsonに以下を追加します。
パッケージをインストールした場合:
インストールせずにローカル ディレクトリから実行している場合:
デスクトップ版のClaudeを再起動
利用可能なツール
SourceSage は次の MCP ツールを提供します。
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 IDregister_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 IDregister_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 IDregister_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 IDadd_entity_observation : エンティティに観測を追加する
Input: - entity_name: Name of the entity - observation: Observation to add Output: Confirmation messagequery_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 entitiesget_entity_details : エンティティの詳細情報を取得する
Input: - entity_name: Name of the entity Output: Detailed information about the entityquery_patterns : ナレッジグラフ内のクエリコードパターン
Input: - language: Filter by programming language (optional) - pattern_name: Filter by pattern name (optional) Output: List of matching patternsquery_style_conventions : クエリコーディングスタイルの規約
Input: - language: Filter by programming language (optional) - convention_name: Filter by convention name (optional) Output: List of matching style conventionsget_knowledge_statistics : ナレッジグラフに関する統計情報を取得する
clear_knowledge : グラフからすべての知識をクリアします
クロードによるワークフローの例
コードの分析: Claude にコードファイルの分析を依頼します
"Please analyze this Python file and register the key entities and relationships."エンティティの登録: Claudeはregister_entityツールを使用してコードエンティティを保存します。
"I'll register the main class in this file."関係の登録: Claudeはregister_relationshipツールを使用して関係を保存します
"I'll register the inheritance relationship between these classes."クエリ知識: 後で、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?"コーディングパターンを入手する: コーディングパターンについてクロードに質問する
"What design patterns are used in my codebase?" "Show me examples of the Factory pattern in my code."
どう違うのか
従来のコード分析ツールとは異なり、SourceSage は次のことを行います。
LLMの理解を活用: LLMの能力を活用して言語間のコードセマンティクスを理解します
意味的知識を保存: 構文だけでなく意味と関係性に焦点を当てます
言語に依存しない: LLMが理解できるあらゆるプログラミング言語で動作します
トークン効率を最適化: トークンの使用を最小限に抑える方法で知識を保存します
LLMの機能とともに進化: LLMが進化するにつれて、コードの理解も向上します
貢献
貢献を歓迎します!お気軽にプルリクエストを送信してください。
ライセンス
このプロジェクトは MIT ライセンスに基づいてライセンスされています - 詳細については LICENSE ファイルを参照してください。
Appeared in Searches
- A tool for extracting code metadata and exposing it via MCP
- Retrieve the latest documentation of libraries in word embeddings form for LLMs
- Using local LLMs for code writing, reviewing, and rule generation
- Assistance with reviewing and merging code changes in a merge request
- Resources or Assistance for Learning to Code