Skip to main content
Glama

zendesk_get_git_zen_links

Retrieve linked GitLab issues, merge requests, and commits for a Zendesk ticket. Returns structured data with state, labels, weight, and direct links.

Instructions

Get linked GitLab issues, merge requests, and commits for a Zendesk ticket via the Git-Zen integration. Returns structured lists with state, labels, weight, and direct GitLab links.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ticket_idYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The core handler function `_get_git_zen_links_data` that executes the tool logic: loads config for git_zen_field_id, fetches the Zendesk ticket via zenpy, extracts the custom field JSON (if present), parses issue groups, merge request groups, and commit groups, and returns a structured JSON response.
    def _get_git_zen_links_data(ticket_id: int) -> str:
        field_id = load_config().get("git_zen_field_id")
        if field_id is None:
            return _NOT_CONFIGURED_MESSAGE
    
        try:
            client = get_client()
            ticket = client.tickets(id=ticket_id)
            raw = None
            for f in (ticket.custom_fields or []):
                if f['id'] == field_id and f['value']:
                    raw = f['value']
                    break
    
            if not raw:
                return json.dumps({
                    "ticket_id": ticket_id,
                    "linked_issues": [],
                    "linked_mrs": [],
                    "linked_commits": [],
                }, indent=2)
    
            data = json.loads(raw)
    
            issues = []
            for group in data.get('issueGroup', []):
                for issue in group.get('issues', []):
                    issues.append({
                        "project": f"{group['owner']}/{group['name']}",
                        "number": issue['number'],
                        "title": issue['name'],
                        "link": issue['link'],
                        "state": issue['state'],
                        "labels": [lbl['name'] for lbl in issue.get('labels', [])],
                        "weight": issue.get('weight'),
                        "milestone": issue.get('milestone'),
                    })
    
            mrs = []
            for group in data.get('fileGroup', []):
                for mr in group.get('files', []):
                    mrs.append({
                        "project": f"{group.get('owner', '')}/{group.get('name', '')}",
                        "number": mr.get('number', ''),
                        "title": mr.get('name', ''),
                        "link": mr.get('link', ''),
                        "state": mr.get('state', ''),
                    })
    
            commits = []
            for group in data.get('commitGroup', []):
                for commit in group.get('commits', []):
                    commits.append({
                        "project": f"{group.get('owner', '')}/{group.get('name', '')}",
                        "sha": commit.get('id', ''),
                        "message": commit.get('message', ''),
                        "link": commit.get('url', ''),
                    })
    
            return json.dumps({
                "ticket_id": ticket_id,
                "linked_issues": issues,
                "linked_mrs": mrs,
                "linked_commits": commits,
            }, indent=2)
        except ConfigError as e:
            return str(e)
        except Exception as e:
            if "RecordNotFound" in str(e) or "404" in str(e):
                return f"Ticket #{ticket_id} not found or not accessible with current credentials."
            return f"Zendesk API error: {e}"
  • The `register_git_zen_tools` function that uses the @mcp.tool() decorator to register `zendesk_get_git_zen_links` as an MCP tool. The tool accepts a ticket_id (int) and returns a string.
    def register_git_zen_tools(mcp) -> None:
        @mcp.tool()
        def zendesk_get_git_zen_links(ticket_id: int) -> str:
            """Get linked GitLab issues, merge requests, and commits for a Zendesk ticket via the Git-Zen integration. Returns structured lists with state, labels, weight, and direct GitLab links."""
            return _get_git_zen_links_data(ticket_id)
  • Helper `load_config` used by the handler to read the git_zen_field_id from config.
    def load_config(path: Path | None = None) -> dict:
        resolved = path or config_path()
        try:
            return json.loads(resolved.read_text())
        except (FileNotFoundError, json.JSONDecodeError):
            return {}
  • Helper `get_client` used by the handler to get the Zendesk API client.
    def get_client(config_file: Path | None = None) -> Zenpy:
        cfg = load_config(config_file)
        subdomain = cfg.get("subdomain", "").strip()
        token = cfg.get("oauth_token", "").strip()
        if not subdomain or not token:
            raise ConfigError("Zendesk not configured. Run: zendesk-mcp setup")
        return Zenpy(subdomain=subdomain, oauth_token=token)
  • The import and call to `register_git_zen_tools(mcp)` in the main server setup, which triggers registration of all git-zen tools including `zendesk_get_git_zen_links`.
    from zendesk_mcp.tools.git_zen import register_git_zen_tools
    
    register_ticket_tools(mcp)
    register_comments_tools(mcp)
    register_attachment_tools(mcp)
    register_gitlab_context_tools(mcp)
    register_write_comment_tools(mcp)
    register_update_ticket_tools(mcp)
    register_time_tracking_tools(mcp)
    register_git_zen_tools(mcp)
Behavior4/5

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

No annotations are provided, so the description must convey behavioral traits. It details the output: structured lists with state, labels, weight, and direct GitLab links. However, it does not disclose whether the operation is read-only, any authentication requirements, rate limits, or behavior when no links exist.

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?

Two sentences, no wasted words. Information is front-loaded and directly relevant. The description is appropriately sized for the tool's simplicity.

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?

For a simple retrieval tool with one required parameter and an output schema, the description covers the purpose and output details adequately. It lacks mention of prerequisites (e.g., integration enabled) but is generally sufficient for an agent to invoke correctly.

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?

Schema description coverage is 0%, and the description adds no additional meaning to the sole parameter 'ticket_id' beyond its name and type. It could have clarified expected format or constraints (e.g., ticket must exist, integration must be active).

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 specifies the action ('get'), resource ('linked GitLab issues, merge requests, and commits'), and context ('via the Git-Zen integration for a Zendesk ticket'). It is distinct from sibling tools, all of which handle other Zendesk operations.

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

Usage Guidelines3/5

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

The description implies usage when needing Git-Zen links for a ticket but provides no explicit guidance on when to use this tool versus alternatives (e.g., other integration tools) or when not to use it. No prerequisites or exclusions are mentioned.

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/michaelrice/zendesk-mcp'

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