Skip to main content
Glama

zendesk_get_time_tracking

Get time tracking data for a Zendesk ticket, including total time spent and time on the last update, returned in seconds and human-readable format (e.g., '2h 15m').

Instructions

Get time tracking data for a Zendesk ticket. Returns total time spent and time spent on the last update, in both seconds and human-readable format (e.g. '2h 15m').

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ticket_idYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function for the zendesk_get_time_tracking tool. Decorated with @mcp.tool(), it delegates to _get_time_tracking_data to fetch and format time tracking data from Zendesk custom fields.
    def zendesk_get_time_tracking(ticket_id: int) -> str:
        """Get time tracking data for a Zendesk ticket. Returns total time spent and time spent on the last update, in both seconds and human-readable format (e.g. '2h 15m')."""
        return _get_time_tracking_data(ticket_id)
  • Helper that queries Zendesk API via zenpy, extracts custom field values for total time spent and last update time, formats them into a JSON response (seconds + human-readable).
    def _get_time_tracking_data(ticket_id: int) -> str:
        try:
            client = get_client()
            ticket = client.tickets(id=ticket_id)
            total = int(_get_custom_field(ticket, _FIELD_TOTAL_TIME_SPENT) or 0)
            last = int(_get_custom_field(ticket, _FIELD_TIME_SPENT_LAST_UPDATE) or 0)
            return json.dumps({
                "ticket_id": ticket_id,
                "total_time_spent_sec": total,
                "time_spent_last_update_sec": last,
                "total_time_human": _format_duration(total),
                "time_spent_last_update_human": _format_duration(last),
            }, 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}"
  • Converts seconds to a human-readable duration string (e.g. '2h 15m' or '5m 30s').
    def _format_duration(seconds: int) -> str:
        m, s = divmod(seconds, 60)
        h, m = divmod(m, 60)
        if h:
            return f"{h}h {m:02d}m"
        return f"{m}m {s:02d}s"
  • Helper to extract a specific custom field value from a Zendesk ticket by field ID.
    def _get_custom_field(ticket, field_id: int):
        for f in (ticket.custom_fields or []):
            if f['id'] == field_id:
                return f['value']
        return None
  • The tool is registered via register_time_tracking_tools(mcp) call in the server's main() function, which imports and invokes the registration module.
    from zendesk_mcp.tools.time_tracking import register_time_tracking_tools
    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)
Behavior3/5

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

No annotations provided, so description carries the burden. It discloses return format (seconds and human-readable) but lacks details on permissions, rate limits, or behavior when time tracking is not enabled.

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 succinct sentences that front-load the purpose and clearly describe outputs. No unnecessary words.

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 presence of an output schema (not shown), the description is mostly complete for a simple getter. Could be improved by mentioning that time tracking must be enabled, but overall adequate.

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% for the only parameter (ticket_id). The description does not add any additional meaning beyond what the schema provides, such as format or constraints.

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 gets time tracking data for a Zendesk ticket, with specific details about returned fields. It distinguishes from siblings like zendesk_log_time and zendesk_get_ticket.

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 on when to use this tool versus alternatives. Does not mention prerequisites, edge cases, or scenarios where another tool would be more appropriate.

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