Skip to main content
Glama

zendesk_log_time

Log time spent on a Zendesk ticket by providing ticket ID and seconds. Adds seconds to the running total and returns logged amount and new total in both seconds and human-readable format.

Instructions

Log time spent on a Zendesk ticket. Adds seconds to the running total and records it as the last-update time. Returns logged amount and new total in seconds and human-readable format.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ticket_idYes
secondsYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The tool handler function `zendesk_log_time` that logs time spent on a Zendesk ticket. It is decorated with @mcp.tool() and delegates to _log_time_data(ticket_id, seconds).
    @mcp.tool()
    def zendesk_log_time(ticket_id: int, seconds: int) -> str:
        """Log time spent on a Zendesk ticket. Adds seconds to the running total and records it as the last-update time. Returns logged amount and new total in seconds and human-readable format."""
        return _log_time_data(ticket_id, seconds)
  • The internal helper function `_log_time_data` that implements the actual business logic: validates seconds > 0, fetches the ticket, adds seconds to the running total via custom fields, updates the ticket via the Zendesk API, and returns a JSON response.
    def _log_time_data(ticket_id: int, seconds: int) -> str:
        if seconds <= 0:
            return f"seconds must be a positive integer, got {seconds}."
        try:
            client = get_client()
            ticket = client.tickets(id=ticket_id)
            current_total = int(_get_custom_field(ticket, _FIELD_TOTAL_TIME_SPENT) or 0)
            new_total = current_total + seconds
            update = Ticket(id=ticket_id)
            update.custom_fields = [
                {"id": _FIELD_TOTAL_TIME_SPENT, "value": new_total},
                {"id": _FIELD_TIME_SPENT_LAST_UPDATE, "value": seconds},
            ]
            client.tickets.update(update)
            return json.dumps({
                "ticket_id": ticket_id,
                "logged_sec": seconds,
                "logged_human": _format_duration(seconds),
                "new_total_sec": new_total,
                "new_total_human": _format_duration(new_total),
            }, 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 tool registration: `register_time_tracking_tools` is imported from `zendesk_mcp.tools.time_tracking` and called with the `mcp` instance in the `main()` function.
    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)
  • The `register_time_tracking_tools` function that uses the `@mcp.tool()` decorator to register both `zendesk_get_time_tracking` and `zendesk_log_time` as MCP tools.
    def register_time_tracking_tools(mcp) -> None:
        @mcp.tool()
        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)
    
        @mcp.tool()
        def zendesk_log_time(ticket_id: int, seconds: int) -> str:
            """Log time spent on a Zendesk ticket. Adds seconds to the running total and records it as the last-update time. Returns logged amount and new total in seconds and human-readable format."""
  • Helper function `_format_duration` that converts seconds to a human-readable format (e.g., '2h 15m' or '5m 30s'). Used by both the logging and retrieval functions.
    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"
Behavior3/5

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

Without annotations, the description carries full burden. It discloses core behavior (adding seconds, updating last-update time) and return format, but does not mention idempotency, permission requirements, or whether it updates in real-time.

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?

Three sentences, 30 words, front-loaded with the main action. No redundant or vague language. Each sentence adds meaningful information.

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 simple input schema (two integers) and presence of an output schema, the description covers the essential purpose and return values. It lacks details on error handling or concurrency but is sufficient for basic use.

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 coverage is 0%, so the description must compensate. It adds context that 'seconds' are added to a running total, but does not explain 'ticket_id' beyond its name or provide constraints (e.g., valid ticket ID). Parameter names are self-explanatory, but more detail would help.

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 action (log time), the resource (Zendesk ticket), and the outcome (add seconds, record last-update, return amounts). It distinguishes from siblings like 'zendesk_get_time_tracking' by focusing on adding 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 on when to use this tool versus alternatives like 'zendesk_get_time_tracking' or other ticket operations. The description does not mention prerequisites or contexts where this tool is 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