Skip to main content
Glama

zendesk_get_time_tracking

Retrieve total time spent and last update time for a Zendesk ticket 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 tool handler function 'zendesk_get_time_tracking' decorated with @mcp.tool(). Accepts a ticket_id (int) and delegates to the private _get_time_tracking_data function.
    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)
  • Core helper '_get_time_tracking_data' that fetches the ticket via Zenpy client, reads custom field values for total time spent and last update time, and returns JSON with both seconds and human-readable formats.
    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}"
  • Custom field IDs for time tracking: _FIELD_TOTAL_TIME_SPENT (30435145651479) and _FIELD_TIME_SPENT_LAST_UPDATE (30435145655959). These define the schema of Zendesk ticket custom fields used.
    _FIELD_TOTAL_TIME_SPENT = 30435145651479
    _FIELD_TIME_SPENT_LAST_UPDATE = 30435145655959
  • Helper '_get_custom_field' that extracts a custom field value by ID from a ticket's custom_fields list.
    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
  • Import and registration of the time tracking tools (including zendesk_get_time_tracking) in the main server module. The import is at line 19, and the registration call is at line 39.
    from zendesk_mcp.tools.time_tracking import register_time_tracking_tools
    from zendesk_mcp.tools.git_zen import register_git_zen_tools
    from zendesk_mcp.tools.create_ticket import register_create_ticket_tools
    from zendesk_mcp.tools.list_tickets import register_list_tickets_tools
    from zendesk_mcp.tools.knowledge_base import register_knowledge_base_resource
    from zendesk_mcp.tools.tags import register_tag_tools
    from zendesk_mcp.tools.views import register_view_tools
    from zendesk_mcp.tools.macros import register_macro_tools
    from zendesk_mcp.tools.users import register_user_tools
    from zendesk_mcp.tools.groups import register_group_tools
    from zendesk_mcp.tools.organizations import register_organization_tools
    from zendesk_mcp.tools.custom_statuses import register_custom_status_tools
    from zendesk_mcp.prompts import register_prompts
    
    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)
Behavior3/5

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

With no annotations, the description carries full burden. It discloses the return format but does not explicitly state that the operation is read-only, lacks authentication or rate limit notes, and omits potential side effects. It is minimally adequate but not thorough.

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 two sentences long, front-loading the action and then detailing the return values. Every sentence adds value with 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 tool's simplicity (one parameter, no annotations, output schema exists), the description covers the essential purpose and output. It could be improved by adding usage context or behavioral notes, but it is largely complete for basic retrieval.

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 input schema has one parameter (ticket_id) with no description and 0% schema description coverage. The tool description does not elaborate on the parameter beyond the schema, adding no additional semantic meaning. For a simple integer ID, this is acceptable but not helpful.

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 retrieves time tracking data for a specific Zendesk ticket, specifying the output includes total and last update time in seconds and human-readable format. This is a specific verb-resource pair that distinguishes it from sibling tools like zendesk_log_time which logs time.

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. There is no mention of contexts where this tool is appropriate or inappropriate, nor any reference to sibling tools like zendesk_log_time for comparison.

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