Skip to main content
Glama

get_local_repo

Process local repository code into text format for AI analysis and processing, preserving context and structure.

Instructions

Process and return the code from a local repository as text

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_pathYes

Implementation Reference

  • The main handler function for the 'get_local_repo' MCP tool. It is decorated with @mcp.tool() which serves as both the implementation and registration. Wraps the synchronous LocalRepo2Txt.process_repo in an async executor with timeout handling.
    @mcp.tool()
    async def get_local_repo(repo_path: str)->str:
        """
        Process and return the code from a local repository as text
        """
        try:
            # Create an event loop
            loop = asyncio.get_event_loop()
            # Wrap synchronous operation in async operation with 300 seconds (5 minutes) timeout
            repo_processor = LocalRepo2Txt()
            repo_name, content = await asyncio.wait_for(
                loop.run_in_executor(None, repo_processor.process_repo, repo_path),
                timeout=300
            )
            return content
        except asyncio.TimeoutError:
            return "Processing timeout, please check repository size or file count"
        except Exception as e:
            return f"Processing failed: {str(e)}"
  • The core helper method called by the tool handler. It processes the local repository by traversing directory structure, collecting file paths, reading text contents (skipping binaries and ignored dirs), and formatting into a string with structure and contents.
    def process_repo(self, repo_path):
        """
        处理本地仓库并返回处理后的内容
        
        Args:
            repo_path (str): 本地仓库路径
            
        Returns:
            tuple: (repo_name, content_string) - 仓库名和处理后的内容字符串
        """
        repo_name = os.path.basename(repo_path)
    
        # print(f"Fetching repository structure for: {repo_name}")
        repo_structure = f"Repository Structure: {repo_name}\n"
        repo_structure += self._traverse_local_repo_iteratively(repo_path)
    
        repo_structure = repo_structure.replace(repo_path, '.')
    
        # print(f"\nFetching file contents for: {repo_name}")
        file_contents = self._get_local_file_contents_iteratively(repo_path)
    
        instructions = "Use the files and contents provided below to complete this analysis:\n\n"
        
        # 组合所有内容
        content = (
            instructions +
            repo_structure +
            '\n\n' +
            file_contents
        )
        
        return repo_name, content
  • The @mcp.tool() decorator registers the get_local_repo function as an MCP tool.
    @mcp.tool()
Behavior2/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 mentions 'Process and return' but doesn't specify what processing entails (e.g., formatting, filtering, or error handling), the return format details, or any constraints like file size limits or authentication needs. This leaves significant gaps in understanding the tool's behavior.

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 with a single sentence that directly states the tool's purpose. It is front-loaded and wastes no words, making it easy to parse quickly without unnecessary detail.

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

Completeness2/5

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

Given the tool's complexity (processing and returning code), lack of annotations, no output schema, and low schema coverage, the description is incomplete. It doesn't explain what 'Process' involves, the return format, error conditions, or how it differs from sibling tools, making it inadequate for an AI agent to use effectively without guesswork.

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

Parameters2/5

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

The schema description coverage is 0%, with one parameter (repo_path) undocumented in the schema. The description adds no information about this parameter, such as what 'repo_path' should be (e.g., a file system path, relative or absolute) or any examples. It fails to compensate for the low schema coverage, leaving the parameter meaning unclear.

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

Purpose4/5

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

The description clearly states the action ('Process and return') and resource ('code from a local repository as text'), providing a specific verb+resource combination. However, it doesn't explicitly differentiate from sibling tools like get_github_repo or get_gitlab_repo, which likely handle remote repositories instead of local ones.

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?

The description offers no guidance on when to use this tool versus its siblings (get_github_repo, get_gitlab_repo) or any alternatives. It lacks context about prerequisites, such as needing a valid local repository path, and doesn't mention exclusions or specific use cases.

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/crisschan/mcp-repo2llm'

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