Skip to main content
Glama

zendesk_log_time

Log time spent on a Zendesk ticket by adding seconds to the running total and returning the 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 @mcp.tool() decorated function that implements the 'zendesk_log_time' tool. It delegates to _log_time_data.
    @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)
  • Core business logic: reads current total from custom field, adds seconds, updates ticket's custom fields (total time spent and last update time), returns JSON result.
    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}"
  • Registration call in server.py's main() that wires up the time tracking tools (including zendesk_log_time) into the MCP server.
    register_time_tracking_tools(mcp)
  • Registration function that uses @mcp.tool() decorator to register both time tracking tools with FastMCP.
    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."""
            return _log_time_data(ticket_id, seconds)
  • Helper that formats seconds into human-readable duration (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"
Behavior4/5

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

Discloses that time is added to a running total and updates last-update time, and returns amounts in seconds and human-readable format. No annotations were provided, so this is adequate though it could mention if time is additive or replaces.

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 concise sentences, no fluff, front-loaded with action and effect. Every sentence adds value.

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 two-parameter tool, the description covers the main action and output. However, it omitted details like ticket existence validation or permission requirements, but given an output schema may provide return info, it's reasonably complete.

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 coverage is 0%, and the description does not add meaning beyond parameter names. It does not explain constraints (e.g., positive integers) or behavior like error handling, which would compensate for the lack of schema descriptions.

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 verb 'Log time' and the resource 'Zendesk ticket', and distinguishes from siblings like 'zendesk_get_time_tracking' by specifying it adds time rather than retrieving it.

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?

No explicit guidance on when to use or when not to use, nor alternative tools. Usage is implied for logging time on a ticket, but lacks context like prerequisites or conditions.

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