Skip to main content
Glama
effytech

Freshdesk MCP server

by effytech

create_ticket

Generate and submit support tickets in Freshdesk by specifying details like subject, description, source, priority, and status to streamline customer support operations.

Instructions

Create a ticket in Freshdesk

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
additional_fieldsNo
custom_fieldsNo
descriptionYes
emailNo
priorityYes
requester_idNo
sourceYes
statusYes
subjectYes

Implementation Reference

  • The core handler function for the 'create_ticket' tool. It is decorated with @mcp.tool(), which both defines the tool schema from type hints/docstring and registers it with the MCP server. Implements the logic to POST a new ticket to Freshdesk API with validation for enums and fields.
    @mcp.tool()
    async def create_ticket(
        subject: str,
        description: str,
        source: Union[int, str],
        priority: Union[int, str],
        status: Union[int, str],
        email: Optional[str] = None,
        requester_id: Optional[int] = None,
        custom_fields: Optional[Dict[str, Any]] = None,
        additional_fields: Optional[Dict[str, Any]] = None  # 👈 new parameter
    ) -> str:
        """Create a ticket in Freshdesk"""
        # Validate requester information
        if not email and not requester_id:
            return "Error: Either email or requester_id must be provided"
    
        # Convert string inputs to integers if necessary
        try:
            source_val = int(source)
            priority_val = int(priority)
            status_val = int(status)
        except ValueError:
            return "Error: Invalid value for source, priority, or status"
    
        # Validate enum values
        if (source_val not in [e.value for e in TicketSource] or
            priority_val not in [e.value for e in TicketPriority] or
            status_val not in [e.value for e in TicketStatus]):
            return "Error: Invalid value for source, priority, or status"
    
        # Prepare the request data
        data = {
            "subject": subject,
            "description": description,
            "source": source_val,
            "priority": priority_val,
            "status": status_val
        }
    
        # Add requester information
        if email:
            data["email"] = email
        if requester_id:
            data["requester_id"] = requester_id
    
        # Add custom fields if provided
        if custom_fields:
            data["custom_fields"] = custom_fields
    
         # Add any other top-level fields
        if additional_fields:
            data.update(additional_fields)
    
        url = f"https://{FRESHDESK_DOMAIN}/api/v2/tickets"
        headers = {
            "Authorization": f"Basic {base64.b64encode(f'{FRESHDESK_API_KEY}:X'.encode()).decode()}",
            "Content-Type": "application/json"
        }
    
        async with httpx.AsyncClient() as client:
            try:
                response = await client.post(url, headers=headers, json=data)
                response.raise_for_status()
    
                if response.status_code == 201:
                    return "Ticket created successfully"
    
                response_data = response.json()
                return f"Success: {response_data}"
    
            except httpx.HTTPStatusError as e:
                if e.response.status_code == 400:
                    # Handle validation errors and check for mandatory custom fields
                    error_data = e.response.json()
                    if "errors" in error_data:
                        return f"Validation Error: {error_data['errors']}"
                return f"Error: Failed to create ticket - {str(e)}"
            except Exception as e:
                return f"Error: An unexpected error occurred - {str(e)}"
  • Enum definitions used in create_ticket for validating source, status, and priority values against Freshdesk API constraints.
    class TicketSource(IntEnum):
        EMAIL = 1
        PORTAL = 2
        PHONE = 3
        CHAT = 7
        FEEDBACK_WIDGET = 9
        OUTBOUND_EMAIL = 10
    
    class TicketStatus(IntEnum):
        OPEN = 2
        PENDING = 3
        RESOLVED = 4
        CLOSED = 5
    
    class TicketPriority(IntEnum):
        LOW = 1
        MEDIUM = 2
        HIGH = 3
        URGENT = 4
    class AgentTicketScope(IntEnum):
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. While 'Create' implies a write operation, it doesn't specify permissions required, whether the operation is idempotent, rate limits, error handling, or what the response contains. This leaves significant gaps for a mutation tool.

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?

The description is a single, efficient sentence with zero waste. It's front-loaded with the core action and resource, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with 9 parameters (5 required), 0% schema description coverage, no annotations, and no output schema, the description is inadequate. It doesn't explain parameter meanings, behavioral traits, or usage context, leaving the agent poorly equipped to use this tool correctly.

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 description coverage is 0%, meaning none of the 9 parameters have descriptions in the schema. The tool description adds no information about parameters, failing to compensate for this gap. It doesn't explain what 'priority', 'source', or 'status' mean, or how 'additional_fields' and 'custom_fields' differ.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Create') and resource ('a ticket in Freshdesk'), making the purpose unambiguous. However, it doesn't distinguish this tool from sibling tools like 'create_contact_field' or 'create_group', which also create resources in Freshdesk but different ones.

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?

The description provides no guidance on when to use this tool versus alternatives. With sibling tools like 'create_contact_field' or 'create_group' available, there's no indication of when to create a ticket versus other resources, nor any mention of prerequisites or constraints.

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

Related 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/effytech/freshdesk_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server