Skip to main content
Glama

MCP Source Relation Server

MCP Source Relation Server

指定されたディレクトリの src 配下のソースコードの関連性を解析するMCPサーバーです。 言語ごとのインポート文を解析し、ファイル間の依存関係を特定します。 Claudeに組み込むことで、Claudeがプロジェクトの依存関係を素早く確認でき、関連するファイルの特定に役立ちます。

機能

  • 複数言語のインポート解析をサポート
    • TypeScript/JavaScript: import文、require
    • Python: import文、from ... import
    • Ruby: require文、require_relative
    • Rust: mod宣言、use
  • tsconfig.jsonのパスエイリアス(@/components/...など)に対応
  • 言語ごとの特殊な機能に対応
    • Python: __init__.py、相対インポート
    • Rust: mod.rsパターン
    • TypeScript: エイリアス、index.ts
    • Ruby: 拡張子なしのrequire

セットアップ

必要条件

  • Python 3.10以上
  • uv

インストール

# uvのインストール $ curl -LsSf https://astral.sh/uv/install.sh | sh $ cd /path/to/mcp-source-relation # ライブラリのインストール $ uv sync

Claude for Desktopでの設定

claude_desktop_config.json に以下の設定を追加してください:

{ "mcpServers": { "source-relation": { "command": "uv", "args": [ "--directory", "/path/to/mcp-source-relation", # このプロジェクトディレクトリの絶対パスに書き換えてください "run", "source_relation.py" ] } } }

使用方法

Claudeでの使用

/Users/xxx/GitHub/xxx/ のソースの依存関係を確認して のように指示すると動作します

`/Users/owa/GitHub/mcp-source-relation/` のソースコードの依存関係を確認してみましょう。 依存関係の分析結果から、以下のような構造が確認できます: 1. メインの解析モジュール: `src/source_analyzer.py` - 各言語固有の解析モジュールを利用しています(Ruby, Python, TypeScript, Rust) 2. 言語別の解析モジュール: - `src/analyzers/ruby.py` - `src/analyzers/python.py` - `src/analyzers/typescript.py` - `src/analyzers/rust.py` - すべて `src/analyzers/base.py` を継承しています 3. 共通基盤: - `src/analyzers/base.py`: 基本的な解析機能を提供 - `src/utils/path.py`: パス操作のユーティリティ - `src/configs/typescript.py`: TypeScript固有の設定 特徴的な点: - 各言語の解析モジュールは共通の基底クラス(base.py)を継承しており、一貫性のある設計になっています - TypeScriptのみ独自の設定ファイル(configs/typescript.py)を持っています - パス操作は共通のユーティリティモジュール(utils/path.py)に集約されています この構造から、新しい言語のサポートを追加する場合は、`src/analyzers/` に新しいモジュールを追加し、`base.py` を継承することで実現できる設計になっていることがわかります。

ディレクトリを指定した場合はその下の src ディレクトリを解析します ファイルを指定した場合はそのファイルを基準に解析します promptからのパス入力にも対応しています promptで利用する場合は、Attach from MCP->Choose an integration->source-relationを選択してください

出力形式

解析結果は以下のようなJSON形式で出力されます:

{ "dependencies": { "components/Button.tsx": [ "types/index.ts", "utils/theme.ts" ], "pages/index.tsx": [ "components/Button.tsx", "utils/api.ts" ] } }

すべてのパスはsrcディレクトリを基準とした相対パスで表示されます。

サポートされるインポート形式

TypeScript/JavaScript

  • import { Component } from './Component'
  • import type { Type } from '@/types'
  • import './styles.css'
  • require('./module')
  • エイリアスパス(@/components/...

Python

  • import module
  • from module import name
  • from .module import name
  • from ..module import name

Ruby

  • require 'module'
  • require_relative './module'
  • 拡張子なしのrequire

Rust

  • mod module;
  • use crate::module;
  • use super::module;
  • use self::module;
Install Server
A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

local-only server

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

Analyzes source code dependencies across multiple programming languages in the specified directory to identify file relationships, assisting in dependency management and project structure understanding.

  1. 機能
    1. セットアップ
      1. 必要条件
      2. インストール
    2. Claude for Desktopでの設定
      1. 使用方法
        1. Claudeでの使用
      2. 出力形式
        1. サポートされるインポート形式
          1. TypeScript/JavaScript
          2. Python
          3. Ruby
          4. Rust

        Related MCP Servers

        • A
          security
          A
          license
          A
          quality
          Provides tools for collecting and documenting code from directories.
          Last updated -
          4
          81
          12
          TypeScript
          MIT License
          • Apple
          • Linux
        • -
          security
          A
          license
          -
          quality
          A Model Context Protocol tool for analyzing code repositories, performing security scans, and assessing code quality across multiple programming languages.
          Last updated -
          Python
          MIT License
          • Apple
          • Linux
        • -
          security
          F
          license
          -
          quality
          Analyzes codebases to generate dependency graphs and architectural insights across multiple programming languages, helping developers understand code structure and validate against architectural rules.
          Last updated -
          5
          JavaScript
        • -
          security
          A
          license
          -
          quality
          A tool that helps rank codebase files by importance (1-10 scale), track file dependencies, and provide summaries, all accessible through a simple JSON-based interface.
          Last updated -
          2
          TypeScript
          GPL 3.0
          • Linux

        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/owayo/mcp-source-relation'

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