Skip to main content
Glama
owayo

MCP Source Relation Server

get_source_relation

Analyze dependencies between source files to identify relationships and manage project structure effectively.

Instructions

Analyze dependencies between source files

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes

Implementation Reference

  • The main handler function for the 'get_source_relation' tool. It is decorated with @mcp.tool() which registers it as an MCP tool. The function creates a SourceAnalyzer instance, analyzes the source file or directory for dependencies (recursively if file), and returns a JSON string with the dependencies graph.
    @mcp.tool()
    def get_source_relation(path: str) -> str:
        """Analyze dependencies between source files"""
        path_obj = Path(path)
        base_dir = str(path_obj.parent if path_obj.is_file() else path_obj)
        analyzer = SourceAnalyzer(base_dir)
    
        # ソースコードを解析
        if path_obj.is_file():
            analyzed_files: Set[str] = set()
            file_path = str(path_obj.absolute())
            dependencies = analyze_dependencies_recursively(
                analyzer, file_path, analyzed_files
            )
        else:
            dependencies = analyzer.analyze_directory()
    
        # 結果をまとめる
        result = {"dependencies": dependencies}
    
        return json.dumps(result, indent=2, ensure_ascii=False)
  • Helper function used by the handler to recursively analyze dependencies starting from a given file, building a full dependency dictionary by calling analyzer.analyze_single_file and recursing on direct dependencies.
    def analyze_dependencies_recursively(
        analyzer: SourceAnalyzer, file_path: str, analyzed_files: Set[str]
    ) -> Dict[str, List[str]]:
        """ファイルの依存関係を再帰的に解析する
    
        Args:
            analyzer (SourceAnalyzer): 解析を行うアナライザーインスタンス
            file_path (str): 解析対象のファイルパス
            analyzed_files (Set[str]): 解析済みファイルのセット
    
        Returns:
            Dict[str, List[str]]: 解析されたすべての依存関係の辞書
        """
        if file_path in analyzed_files:
            return {}
    
        analyzed_files.add(file_path)
        dependencies: Dict[str, List[str]] = {}
    
        # ファイルを解析
        try:
            current_deps = analyzer.analyze_single_file(Path(file_path))
            direct_dependencies = current_deps.get(file_path, [])
            dependencies[file_path] = direct_dependencies
    
            # 各依存ファイルについても再帰的に解析
            for dependency in direct_dependencies:
                if dependency not in analyzed_files:
                    nested_deps = analyze_dependencies_recursively(
                        analyzer, dependency, analyzed_files
                    )
                    dependencies.update(nested_deps)
        except Exception:
            pass
    
        return dependencies
  • Key method in SourceAnalyzer called by the recursive helper to analyze a single file's direct dependencies and compute recursive ones.
    def analyze_single_file(self, file_path: Path) -> Dict[str, List[str]]:
        """単一のファイルを解析する
    
        Args:
            file_path (Path): 解析対象のファイルパス
    
        Returns:
            Dict[str, List[str]]: ファイルの完全な依存関係(直接および間接的な依存関係を含む)
        """
        self.analyze_file(file_path)
        normalized_path = self.normalize_path(file_path)
        return {normalized_path: self.get_recursive_dependencies(normalized_path)}
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. The description only states what the tool does at a high level ('analyze dependencies'), but doesn't disclose behavioral traits like whether this is a read-only operation, what format the analysis returns, whether it has side effects, performance characteristics, or error conditions.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise at just 5 words with no wasted language. It's front-loaded with the core purpose and uses efficient phrasing. Every word earns its place in conveying the basic function.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has no annotations, no output schema, and 0% schema description coverage, the description is completely inadequate. For a tool that performs analysis (potentially complex), the description provides minimal context about what analysis means, what results to expect, or how to interpret them.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description provides no information about parameters. With 0% schema description coverage and a single required parameter 'path', the description doesn't compensate at all - it doesn't explain what the path parameter represents, what format it expects, or how it relates to the dependency analysis.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Analyze dependencies between source files' states a general purpose (analyzing dependencies) and resource (source files), but lacks specificity about what kind of analysis is performed or what 'dependencies' means in this context. It doesn't distinguish from siblings, but there are no sibling tools to differentiate from.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives, prerequisites, or constraints. The description implies it's for dependency analysis, but doesn't specify scenarios where this is appropriate or what problems it solves.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

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