Skip to main content
Glama

get_branch

Retrieve detailed information about a specific branch in a GitLab project by providing the project identifier and branch name.

Instructions

取得分支詳細資訊

Args: project_id: 專案 ID 或路徑 branch_name: 分支名稱

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYes
branch_nameYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The `get_branch` tool handler function in `src/gitlab_mcp/server.py`. It fetches branch details using the GitLab client and formats the information for the user. Note that while `@mcp.tool()` is not immediately preceding this specific function in the file, it is part of the tool implementation set.
    def get_branch(project_id: int | str, branch_name: str) -> str:
        """取得分支詳細資訊
    
        Args:
            project_id: 專案 ID 或路徑
            branch_name: 分支名稱
        """
        try:
            client = get_client()
            b = client.get_branch(project_id, branch_name)
    
            commit = b.get("commit", {})
            flags = []
            if b.get("default"):
                flags.append("預設")
            if b.get("protected"):
                flags.append("受保護")
            if b.get("merged"):
                flags.append("已合併")
    
            return f"""分支: {b['name']}
    屬性: {', '.join(flags) if flags else '無'}
    最新 Commit: {commit.get('id', 'N/A')}
    Commit 標題: {commit.get('title', 'N/A')}
    Commit 作者: {commit.get('author_name', 'N/A')}
    Commit 時間: {commit.get('committed_date', 'N/A')}
    網址: {b.get('web_url', '')}"""
        except GitLabAPIError as e:
            return f"取得分支失敗: {str(e)}"
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states the tool retrieves detailed information, implying a read-only operation, but doesn't disclose behavioral traits like authentication needs, rate limits, error handling, or what 'detailed information' entails. This leaves significant gaps for an agent.

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 concise and front-loaded with the purpose, followed by parameter listings. However, the parameter section is brief and could be more integrated, but overall it avoids unnecessary verbosity.

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

Completeness3/5

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

Given the tool has an output schema, the description doesn't need to explain return values. However, with no annotations, low schema coverage, and multiple sibling tools, the description lacks completeness in guiding usage, behavioral context, and parameter details, making it only minimally adequate.

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

Parameters3/5

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

Schema description coverage is 0%, so the description must compensate. It lists the parameters (project_id, branch_name) and provides minimal semantics (e.g., '專案 ID 或路徑' for project_id), but doesn't explain formats, constraints, or examples. This adds some value over the bare schema but is insufficient for full understanding.

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 purpose ('取得分支詳細資訊' translates to 'Get branch detailed information'), which is clear but basic. It doesn't distinguish this tool from siblings like 'list_branches' or 'compare_branches', leaving ambiguity about scope and differentiation.

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. For example, it doesn't clarify if this is for retrieving metadata of a single branch versus listing multiple branches (list_branches) or comparing branches (compare_branches), which are relevant sibling tools.

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/snowild/gitlab-mcp'

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