zendesk_post_comment
Post a public reply on a Zendesk ticket visible to the requester. Use for customer-facing responses.
Instructions
Post a public reply on a Zendesk ticket. The reply is visible to the requester. Use for customer-facing responses.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ticket_id | Yes | ||
| body | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- The zendesk_post_comment tool handler. Accepts ticket_id (int) and body (str), and delegates to _post_comment_data with public=True to post a public comment on a Zendesk ticket.
def zendesk_post_comment(ticket_id: int, body: str) -> str: """Post a public reply on a Zendesk ticket. The reply is visible to the requester. Use for customer-facing responses.""" return _post_comment_data(ticket_id, body, public=True) - Core helper function _post_comment_data that creates a Zenpy Ticket and Comment object, calls client.tickets.update() to submit the comment/public note, and returns a success/error message.
def _post_comment_data(ticket_id: int, body: str, public: bool) -> str: try: client = get_client() ticket = Ticket(id=ticket_id) ticket.comment = Comment(body=body, public=public) client.tickets.update(ticket) label = "Public comment" if public else "Internal note" return f"{label} posted successfully on ticket #{ticket_id}." 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}" - src/zendesk_mcp/tools/write_comments.py:22-31 (registration)Registration function that decorates the tool handler with @mcp.tool() and is called from server.py to register the zendesk_post_comment tool.
def register_write_comment_tools(mcp) -> None: @mcp.tool() def zendesk_post_comment(ticket_id: int, body: str) -> str: """Post a public reply on a Zendesk ticket. The reply is visible to the requester. Use for customer-facing responses.""" return _post_comment_data(ticket_id, body, public=True) @mcp.tool() def zendesk_post_internal_note(ticket_id: int, body: str) -> str: """Post an internal note on a Zendesk ticket. Internal notes are only visible to agents and are not sent to the requester.""" return _post_comment_data(ticket_id, body, public=False) - src/zendesk_mcp/server.py:17-37 (registration)Import and call that registers the write_comment tools (including zendesk_post_comment) on the MCP server.
from zendesk_mcp.tools.write_comments import register_write_comment_tools from zendesk_mcp.tools.update_ticket import register_update_ticket_tools 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)