Skip to content

Commit a3827d3

Browse files
authored
Merge pull request #22 from effytech/ticket-field-tools
✨ Added MCP Tools for Ticket Field Management
2 parents 74b8d84 + b81a67d commit a3827d3

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/freshdesk_mcp/server.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,38 @@ async def search_agents(query: str) -> list[Dict[str, Any]]:
555555
response = await client.get(url, headers=headers)
556556
return response.json()
557557

558+
@mcp.tool()
559+
async def create_ticket_field(ticket_field_fields: Dict[str, Any]) -> Dict[str, Any]:
560+
"""Create a ticket field in Freshdesk."""
561+
url = f"https://{FRESHDESK_DOMAIN}/api/v2/admin/ticket_fields"
562+
headers = {
563+
"Authorization": f"Basic {base64.b64encode(f'{FRESHDESK_API_KEY}:X'.encode()).decode()}"
564+
}
565+
async with httpx.AsyncClient() as client:
566+
response = await client.post(url, headers=headers, json=ticket_field_fields)
567+
return response.json()
568+
@mcp.tool()
569+
async def view_ticket_field(ticket_field_id: int) -> Dict[str, Any]:
570+
"""View a ticket field in Freshdesk."""
571+
url = f"https://{FRESHDESK_DOMAIN}/api/v2/admin/ticket_fields/{ticket_field_id}"
572+
headers = {
573+
"Authorization": f"Basic {base64.b64encode(f'{FRESHDESK_API_KEY}:X'.encode()).decode()}"
574+
}
575+
async with httpx.AsyncClient() as client:
576+
response = await client.get(url, headers=headers)
577+
return response.json()
578+
579+
@mcp.tool()
580+
async def update_ticket_field(ticket_field_id: int, ticket_field_fields: Dict[str, Any]) -> Dict[str, Any]:
581+
"""Update a ticket field in Freshdesk."""
582+
url = f"https://{FRESHDESK_DOMAIN}/api/v2/admin/ticket_fields/{ticket_field_id}"
583+
headers = {
584+
"Authorization": f"Basic {base64.b64encode(f'{FRESHDESK_API_KEY}:X'.encode()).decode()}"
585+
}
586+
async with httpx.AsyncClient() as client:
587+
response = await client.put(url, headers=headers, json=ticket_field_fields)
588+
return response.json()
589+
558590
def main():
559591
logging.info("Starting Freshdesk MCP server")
560592
mcp.run(transport='stdio')

0 commit comments

Comments
 (0)