Skip to main content
Glama

read_interface

Extract function signatures, class definitions, and docstrings from code files to understand module usage without reading full implementations.

Instructions

📖 READ INTERFACE: Get a high-level overview of a file without reading implementation.

Returns function signatures, class definitions, and docstrings. Perfect for understanding how to USE a module without reading the whole thing.

INPUTS:

  • root_path: The ABSOLUTE path to the project root

  • file_path: The path to the specific file you want to read (can be relative to root)

EXAMPLE: read_interface("/Users/john/project", "src/auth.py")

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
root_pathYes
file_pathYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool handler decorated with @mcp.tool. Delegates to XRayIndexer.read_interface after getting the indexer instance for the root_path.
    @mcp.tool
    def read_interface(root_path: str, file_path: str) -> str:
        """
        📖 READ INTERFACE: Get a high-level overview of a file without reading implementation.
        
        Returns function signatures, class definitions, and docstrings.
        Perfect for understanding how to USE a module without reading the whole thing.
        
        INPUTS:
        - root_path: The ABSOLUTE path to the project root
        - file_path: The path to the specific file you want to read (can be relative to root)
        
        EXAMPLE:
        read_interface("/Users/john/project", "src/auth.py")
        """
        try:
            indexer = get_indexer(root_path)
            return indexer.read_interface(file_path)
        except Exception as e:
            return f"Error reading interface: {str(e)}"
  • Core logic for reading a file's interface: resolves path, extracts skeleton using _get_file_skeleton_enhanced (signatures and docstrings via AST/regex), handles errors.
    def read_interface(self, file_path: str) -> str:
        """
        Read the interface (skeleton) of a specific file.
        Returns function signatures, class definitions, and types, but hides implementation details.
        """
        try:
            # Resolve path
            target_path = Path(file_path)
            if not target_path.is_absolute():
                target_path = (self.root_path / target_path).resolve()
            
            # Security check: ensure inside root
            try:
                target_path.relative_to(self.root_path)
            except ValueError:
                if not str(target_path).startswith(str(self.root_path)):
                     # Allow if it's the file itself provided as root, otherwise strictly enforce
                     pass
    
            if not target_path.exists() or not target_path.is_file():
                return f"Error: File '{file_path}' not found or is not a file."
            
            # Use the existing skeleton logic, but with a high limit on symbols
            skeleton = self._get_file_skeleton_enhanced(target_path, max_symbols=1000)
            
            if not skeleton:
                # Fallback: if no symbols found or language not supported, 
                # maybe just read the first few lines? or return message?
                language = LANGUAGE_MAP.get(target_path.suffix.lower())
                if not language:
                    return f"File type '{target_path.suffix}' not supported for interface extraction."
                return "No symbols found in file."
                
            return "\n".join(skeleton)
            
        except Exception as e:
            return f"Error reading interface: {str(e)}"
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It describes what the tool returns (interface elements) and its non-destructive nature (implied by 'read'), but doesn't cover aspects like error handling, performance characteristics, or authentication needs. The description adds useful context about the tool's scope but lacks comprehensive behavioral details.

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

Conciseness4/5

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

The description is well-structured with clear sections (purpose, returns, usage context, inputs, example) and uses emojis for visual organization. While slightly longer than minimal, every sentence adds value. The information is front-loaded with the core purpose stated first.

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

Completeness4/5

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

Given the tool's moderate complexity (2 parameters, no annotations, but has output schema), the description provides good coverage. It explains the purpose, parameters, and includes an example. Since an output schema exists, it doesn't need to detail return values. The main gap is lack of behavioral details like error cases or limitations.

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

Parameters4/5

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

With 0% schema description coverage for 2 parameters, the description compensates well by explaining both parameters in the INPUTS section: 'root_path' as 'The ABSOLUTE path to the project root' and 'file_path' as 'The path to the specific file you want to read (can be relative to root)'. It also provides a concrete example that clarifies usage. This adds significant meaning beyond the bare schema.

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

Purpose5/5

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

The description clearly states the tool's purpose with specific verbs ('Get a high-level overview', 'understanding how to USE') and distinguishes it from siblings by focusing on extracting interface information rather than exploring, finding symbols, or analyzing breaks. It explicitly mentions what it returns (function signatures, class definitions, docstrings) and what it doesn't do ('without reading implementation').

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

Usage Guidelines4/5

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

The description provides clear context about when to use this tool ('Perfect for understanding how to USE a module without reading the whole thing'), which implicitly suggests alternatives like reading the full file. However, it doesn't explicitly mention when not to use it or name specific sibling tools as alternatives, though the context is sufficient for differentiation.

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/srijanshukla18/xray'

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