Skip to main content
Glama

get_gitlab_repo

Extract and process code from a GitLab repository branch as structured text for AI analysis and processing.

Instructions

Process and return the code from a GitLab repository branch as text

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_urlYes
branchNomaster

Implementation Reference

  • The tool handler function for 'get_gitlab_repo', decorated with @mcp.tool() for registration, which creates a GitlabRepo2Txt instance and invokes its process_repo method to retrieve and format the repository contents as text.
    @mcp.tool()
    async def get_gitlab_repo(repo_url: str, branch: str = "master")->str:
        """
        Process and return the code from a GitLab repository branch as text
        """
        try:
            repo_processor = GitlabRepo2Txt()
            repo_name, content = repo_processor.process_repo(
            repo_url=repo_url,
            branch=branch  # optional parameter
            )
            # logger.info(f"Processed GitLab repository: {repo_name}")
            # logger.info(f"Processed GitLab content: {content}")
            return content
        except Exception as e:
            # print(f"Error processing GitLab repository: {e}")
            return None
  • The process_repo method of the GitlabRepo2Txt class, which performs the core work of fetching README, repository structure, and non-binary file contents from a GitLab repository using the GitLab API.
    def process_repo(self, repo_url, branch='master'):
        """
        处理GitLab仓库并返回处理后的内容
        
        Args:
            repo_url (str): GitLab仓库URL
            branch (str, optional): 分支名称. 默认为 'master'
            
        Returns:
            tuple: (repo_name, content_string) - 仓库名和处理后的内容字符串
        """
        repo_name = repo_url.split('/')[-1]
        repo = self.gitlab.projects.get(repo_url.replace('https://gitlab.com/', ''))
    
        # print(f"Getting README for {repo_name}")
        readme_content = self._get_readme_content(repo, branch)
    
        # print(f"\nGetting repository structure for {repo_name}")
        repo_structure = f"Repository structure: {repo_name}\n"
        repo_structure += self._traverse_repo_iteratively(repo)
    
        # print(f"\nGetting file contents for {repo_name}")
        file_contents = self._get_file_contents_iteratively(repo, branch)
    
        instructions = "Use the following files and contents for analysis:\n\n"
        
        # 组合所有内容
        content = (
            instructions +
            f"README:\n{readme_content}\n\n" +
            repo_structure +
            '\n\n' +
            file_contents
        )
        
        return repo_name, content
Behavior2/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. It mentions 'process and return... as text', which implies a read operation, but fails to detail critical aspects such as authentication requirements, rate limits, error handling, or what 'process' entails (e.g., formatting, filtering). 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.

Conciseness4/5

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

The description is a single, straightforward sentence that efficiently conveys the core action and output. It is front-loaded with the main purpose and avoids unnecessary elaboration, making it easy to parse quickly. However, it could be slightly more structured to include key details without sacrificing brevity.

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 (involves external GitLab access), lack of annotations, 0% schema description coverage, and no output schema, the description is insufficient. It omits essential context such as authentication, error cases, return format details beyond 'as text', and how it differs from siblings, making it incomplete for reliable agent use.

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%, meaning parameters are undocumented in the schema. The description does not explain the parameters (repo_url, branch) beyond what's implied by the tool name and context. It adds no semantic details about parameter formats, constraints, or usage, failing to compensate for the lack of schema documentation.

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 states the tool 'Process and return the code from a GitLab repository branch as text', which provides a clear verb ('process and return') and resource ('code from a GitLab repository branch'). However, it doesn't explicitly distinguish this from its sibling tools (get_github_repo, get_local_repo) beyond mentioning 'GitLab', leaving some ambiguity about when to choose this specific tool over alternatives.

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_local_repo) or any other alternatives. It simply states what the tool does without indicating specific contexts, prerequisites, or exclusions, which limits its utility for an AI agent making selection decisions.

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