create_incident
Automate incident creation in ServiceNow by specifying details like description, priority, and assigned user. Simplifies tracking and resolving issues using the MCP Server.
Instructions
Create a new incident in ServiceNow
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| assigned_to | No | User assigned to the incident | |
| assignment_group | No | Group assigned to the incident | |
| caller_id | No | User who reported the incident | |
| category | No | Category of the incident | |
| description | No | Detailed description of the incident | |
| impact | No | Impact of the incident | |
| priority | No | Priority of the incident | |
| short_description | Yes | Short description of the incident | |
| subcategory | No | Subcategory of the incident | |
| urgency | No | Urgency of the incident |
Implementation Reference
- Main handler function that executes the create_incident tool by building incident data and POSTing to ServiceNow API.def create_incident( config: ServerConfig, auth_manager: AuthManager, params: CreateIncidentParams, ) -> IncidentResponse: """ Create a new incident in ServiceNow. Args: config: Server configuration. auth_manager: Authentication manager. params: Parameters for creating the incident. Returns: Response with the created incident details. """ api_url = f"{config.api_url}/table/incident" # Build request data data = { "short_description": params.short_description, } if params.description: data["description"] = params.description if params.caller_id: data["caller_id"] = params.caller_id if params.category: data["category"] = params.category if params.subcategory: data["subcategory"] = params.subcategory if params.priority: data["priority"] = params.priority if params.impact: data["impact"] = params.impact if params.urgency: data["urgency"] = params.urgency if params.assigned_to: data["assigned_to"] = params.assigned_to if params.assignment_group: data["assignment_group"] = params.assignment_group # Make request try: response = requests.post( api_url, json=data, headers=auth_manager.get_headers(), timeout=config.timeout, ) response.raise_for_status() result = response.json().get("result", {}) return IncidentResponse( success=True, message="Incident created successfully", incident_id=result.get("sys_id"), incident_number=result.get("number"), ) except requests.RequestException as e: logger.error(f"Failed to create incident: {e}") return IncidentResponse( success=False, message=f"Failed to create incident: {str(e)}", )
- Pydantic BaseModel defining the input parameters and validation schema for the create_incident tool.class CreateIncidentParams(BaseModel): """Parameters for creating an incident.""" short_description: str = Field(..., description="Short description of the incident") description: Optional[str] = Field(None, description="Detailed description of the incident") caller_id: Optional[str] = Field(None, description="User who reported the incident") category: Optional[str] = Field(None, description="Category of the incident") subcategory: Optional[str] = Field(None, description="Subcategory of the incident") priority: Optional[str] = Field(None, description="Priority of the incident") impact: Optional[str] = Field(None, description="Impact of the incident") urgency: Optional[str] = Field(None, description="Urgency of the incident") assigned_to: Optional[str] = Field(None, description="User assigned to the incident") assignment_group: Optional[str] = Field(None, description="Group assigned to the incident")
- src/servicenow_mcp/utils/tool_utils.py:318-324 (registration)Tool registration in get_tool_definitions() dictionary, mapping name to handler alias, schema, return type, description, and serialization method."create_incident": ( create_incident_tool, CreateIncidentParams, str, "Create a new incident in ServiceNow", "str", ),
- src/servicenow_mcp/utils/tool_utils.py:130-131 (registration)Import and alias of the create_incident handler function used in tool registration.create_incident as create_incident_tool, )
- src/servicenow_mcp/tools/__init__.py:42-44 (registration)Re-export of create_incident function from incident_tools in the tools package __init__.from servicenow_mcp.tools.incident_tools import ( add_comment, create_incident,