From 6b2fcf34bc049531a01fae64e23285f37260dd80 Mon Sep 17 00:00:00 2001 From: TeeJS <4136437+TeeJS@users.noreply.github.com> Date: Tue, 18 Aug 2026 23:46:34 -0600 Subject: [PATCH] fix: return a dict instead of a str on error branches Eleven tools are declared `-> Dict[str, Any]` but return a bare f-string on the non-200 branch, and each carries a literal-$ typo (`${response.json()}`), so the error text renders as e.g. `Cannot fetch agents ${...}` and the return value violates the declared type (which also trips FastMCP structured-output validation). Switch them to the dict error idiom already used elsewhere in the file (e.g. get_ticket_tasks): {"error": , "details": response.json()}. Co-Authored-By: Claude Opus 4.8 --- src/freshservice_mcp/server.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/freshservice_mcp/server.py b/src/freshservice_mcp/server.py index 9edc831..0da29dc 100644 --- a/src/freshservice_mcp/server.py +++ b/src/freshservice_mcp/server.py @@ -1599,7 +1599,7 @@ async def update_ticket_conversation(conversation_id: int,body: str)-> Dict[str, if status_code == 200: return response.json() else: - return f"Cannot update conversation ${response.json()}" + return {"error": "Cannot update conversation", "details": response.json()} #GET ALL TICKET CONVERSATION @mcp.tool() @@ -1614,7 +1614,7 @@ async def list_all_ticket_conversation(ticket_id: int)-> Dict[str, Any]: if status_code == 200: return response.json() else: - return f"Cannot fetch ticket conversations ${response.json()}" + return {"error": "Cannot fetch ticket conversations", "details": response.json()} #GET ALL PRODUCTS @mcp.tool() @@ -1675,7 +1675,7 @@ async def get_products_by_id(product_id:int)-> Dict[str, Any]: if status_code == 200: return response.json() else: - return f"Cannot fetch products from the freshservice ${response.json()}" + return {"error": "Cannot fetch products from the freshservice", "details": response.json()} #CREATE PRODUCT @mcp.tool() @@ -1961,7 +1961,7 @@ async def get_requester_id(requester_id:int)-> Dict[str, Any]: if status_code == 200: return response.json() else: - return f"Cannot fetch requester from the freshservice ${response.json()}" + return {"error": "Cannot fetch requester from the freshservice", "details": response.json()} #LIST ALL REQUESTER FIELDS @mcp.tool() @@ -1976,7 +1976,7 @@ async def list_all_requester_fields()-> Dict[str, Any]: if status_code == 200: return response.json() else: - return f"Cannot fetch requester from the freshservice ${response.json()}" + return {"error": "Cannot fetch requester from the freshservice", "details": response.json()} #UPDATE REQUESTER @mcp.tool() @@ -2106,7 +2106,7 @@ async def get_agent(agent_id:int)-> Dict[str, Any]: if status_code == 200: return response.json() else: - return f"Cannot fetch requester from the freshservice ${response.json()}" + return {"error": "Cannot fetch requester from the freshservice", "details": response.json()} #GET ALL AGENTS @mcp.tool() @@ -2221,7 +2221,7 @@ async def update_agent(agent_id, occasional=None, email=None, department_ids=Non if status_code == 200: return response.json() else: - return f"Cannot fetch agents from the freshservice ${response.json()}" + return {"error": "Cannot fetch agents from the freshservice", "details": response.json()} #GET AGENT FIELDS @mcp.tool() @@ -2236,7 +2236,7 @@ async def get_agent_fields()-> Dict[str, Any]: if status_code == 200: return response.json() else: - return f"Cannot fetch agents from the freshservice ${response.json()}" + return {"error": "Cannot fetch agents from the freshservice", "details": response.json()} #GET ALL AGENT GROUPS @mcp.tool() @@ -2251,7 +2251,7 @@ async def get_all_agent_groups()-> Dict[str, Any]: if status_code == 200: return response.json() else: - return f"Cannot fetch agents from the freshservice ${response.json()}" + return {"error": "Cannot fetch agents from the freshservice", "details": response.json()} #GET AGENT GROUP BY ID @mcp.tool() @@ -2266,7 +2266,7 @@ async def getAgentGroupById(group_id:int)-> Dict[str, Any]: if status_code == 200: return response.json() else: - return f"Cannot fetch agents from the freshservice ${response.json()}" + return {"error": "Cannot fetch agents from the freshservice", "details": response.json()} #ADD REQUESTER TO GROUP @mcp.tool() @@ -2415,7 +2415,7 @@ async def get_requester_groups_by_id(requester_group_id:int)-> Dict[str, Any]: if status_code == 200: return response.json() else: - return f"Cannot fetch requester group from the freshservice ${response.json()}" + return {"error": "Cannot fetch requester group from the freshservice", "details": response.json()} #CREATE REQUESTER GROUP @mcp.tool()