get_change_request_details
Retrieve detailed information for a specific change request in ServiceNow by providing its ID, enabling efficient tracking and management of change processes.
Instructions
Get detailed information about a specific change request
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| change_id | Yes | Change request ID or sys_id |
Implementation Reference
- The main handler function that executes the tool logic: validates params, fetches change request details and associated tasks via ServiceNow REST API, returns structured response.def get_change_request_details( auth_manager: AuthManager, server_config: ServerConfig, params: Dict[str, Any], ) -> Dict[str, Any]: """ Get details of a change request from ServiceNow. Args: auth_manager: The authentication manager. server_config: The server configuration. params: The parameters for getting change request details. Returns: The change request details. """ # Unwrap and validate parameters result = _unwrap_and_validate_params( params, GetChangeRequestDetailsParams, required_fields=["change_id"] ) if not result["success"]: return result validated_params = result["params"] # Get the instance URL instance_url = _get_instance_url(auth_manager, server_config) if not instance_url: return { "success": False, "message": "Cannot find instance_url in either server_config or auth_manager", } # Get the headers headers = _get_headers(auth_manager, server_config) if not headers: return { "success": False, "message": "Cannot find get_headers method in either auth_manager or server_config", } # Make the API request url = f"{instance_url}/api/now/table/change_request/{validated_params.change_id}" params = { "sysparm_display_value": "true", } try: response = requests.get(url, headers=headers, params=params) response.raise_for_status() result = response.json() # Get tasks associated with this change request tasks_url = f"{instance_url}/api/now/table/change_task" tasks_params = { "sysparm_query": f"change_request={validated_params.change_id}", "sysparm_display_value": "true", } tasks_response = requests.get(tasks_url, headers=headers, params=tasks_params) tasks_response.raise_for_status() tasks_result = tasks_response.json() return { "success": True, "change_request": result["result"], "tasks": tasks_result["result"], } except requests.exceptions.RequestException as e: logger.error(f"Error getting change request details: {e}") return { "success": False, "message": f"Error getting change request details: {str(e)}", }
- Pydantic BaseModel defining the input schema for the tool, with required 'change_id' field.class GetChangeRequestDetailsParams(BaseModel): """Parameters for getting change request details.""" change_id: str = Field(..., description="Change request ID or sys_id")
- src/servicenow_mcp/utils/tool_utils.py:454-460 (registration)Tool registration in the central get_tool_definitions() dictionary, associating the tool name with its handler function alias, params schema, description, and serialization settings."get_change_request_details": ( get_change_request_details_tool, GetChangeRequestDetailsParams, str, # Expects JSON string "Get detailed information about a specific change request", "json", # Tool returns list/dict ),