Skip to main content
Glama
vparlapalli490

ServiceNow MCP Server

resolve_incident

Resolve incidents in ServiceNow by providing incident ID, resolution code, and notes. Streamline incident management and close tasks efficiently using the MCP server integration.

Instructions

Resolve an incident in ServiceNow

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
incident_idYesIncident ID or sys_id
resolution_codeYesResolution code for the incident
resolution_notesYesResolution notes for the incident

Implementation Reference

  • The handler function that implements the resolve_incident tool. It resolves an incident by looking up the sys_id if needed, then PUTs state='6' (Resolved), close_code, close_notes, and resolved_at to the ServiceNow incident table API.
    def resolve_incident( config: ServerConfig, auth_manager: AuthManager, params: ResolveIncidentParams, ) -> IncidentResponse: """ Resolve an incident in ServiceNow. Args: config: Server configuration. auth_manager: Authentication manager. params: Parameters for resolving the incident. Returns: Response with the result of the operation. """ # Determine if incident_id is a number or sys_id incident_id = params.incident_id if len(incident_id) == 32 and all(c in "0123456789abcdef" for c in incident_id): # This is likely a sys_id api_url = f"{config.api_url}/table/incident/{incident_id}" else: # This is likely an incident number # First, we need to get the sys_id try: query_url = f"{config.api_url}/table/incident" query_params = { "sysparm_query": f"number={incident_id}", "sysparm_limit": 1, } response = requests.get( query_url, params=query_params, headers=auth_manager.get_headers(), timeout=config.timeout, ) response.raise_for_status() result = response.json().get("result", []) if not result: return IncidentResponse( success=False, message=f"Incident not found: {incident_id}", ) incident_id = result[0].get("sys_id") api_url = f"{config.api_url}/table/incident/{incident_id}" except requests.RequestException as e: logger.error(f"Failed to find incident: {e}") return IncidentResponse( success=False, message=f"Failed to find incident: {str(e)}", ) # Build request data data = { "state": "6", # Resolved "close_code": params.resolution_code, "close_notes": params.resolution_notes, "resolved_at": "now", } # Make request try: response = requests.put( 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 resolved successfully", incident_id=result.get("sys_id"), incident_number=result.get("number"), ) except requests.RequestException as e: logger.error(f"Failed to resolve incident: {e}") return IncidentResponse( success=False, message=f"Failed to resolve incident: {str(e)}", )
  • Pydantic model defining the input parameters for the resolve_incident tool: incident_id, resolution_code, resolution_notes.
    class ResolveIncidentParams(BaseModel): """Parameters for resolving an incident.""" incident_id: str = Field(..., description="Incident ID or sys_id") resolution_code: str = Field(..., description="Resolution code for the incident") resolution_notes: str = Field(..., description="Resolution notes for the incident")
  • Registration of the resolve_incident tool in the tool_definitions dictionary, mapping name to (function, params model, return type, description, serialization).
    "resolve_incident": ( resolve_incident_tool, ResolveIncidentParams, str, "Resolve an incident in ServiceNow", "str", ),
  • Re-export of resolve_incident function from incident_tools for use in tool_utils and elsewhere.
    resolve_incident,
  • Import of resolve_incident aliased as resolve_incident_tool for use in tool registration.
    resolve_incident as resolve_incident_tool, )

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/vparlapalli490/MCP'

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