submit_change_for_approval
Submit a change request for approval in ServiceNow using the unique change ID and optional comments to streamline the approval process.
Instructions
Submit a change request for approval
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| approval_comments | No | Comments for the approval request | |
| change_id | Yes | Change request ID or sys_id |
Implementation Reference
- The main handler function that implements the 'submit_change_for_approval' tool logic. It validates parameters, updates the change request state to 'assess', creates an approval record in sysapproval_approver table, and returns the result.def submit_change_for_approval( auth_manager: AuthManager, server_config: ServerConfig, params: Dict[str, Any], ) -> Dict[str, Any]: """ Submit a change request for approval in ServiceNow. Args: auth_manager: The authentication manager. server_config: The server configuration. params: The parameters for submitting a change request for approval. Returns: The result of the submission. """ # Unwrap and validate parameters result = _unwrap_and_validate_params( params, SubmitChangeForApprovalParams, required_fields=["change_id"] ) if not result["success"]: return result validated_params = result["params"] # Prepare the request data data = { "state": "assess", # Set state to "assess" to submit for approval } # Add approval comments if provided if validated_params.approval_comments: data["work_notes"] = validated_params.approval_comments # 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", } # Add Content-Type header headers["Content-Type"] = "application/json" # Make the API request url = f"{instance_url}/api/now/table/change_request/{validated_params.change_id}" try: response = requests.patch(url, json=data, headers=headers) response.raise_for_status() # Now, create an approval request approval_url = f"{instance_url}/api/now/table/sysapproval_approver" approval_data = { "document_id": validated_params.change_id, "source_table": "change_request", "state": "requested", } approval_response = requests.post(approval_url, json=approval_data, headers=headers) approval_response.raise_for_status() approval_result = approval_response.json() return { "success": True, "message": "Change request submitted for approval successfully", "approval": approval_result["result"], } except requests.exceptions.RequestException as e: logger.error(f"Error submitting change for approval: {e}") return { "success": False, "message": f"Error submitting change for approval: {str(e)}", }
- Pydantic model defining the input schema/parameters for the submit_change_for_approval tool: requires change_id, optional approval_comments.class SubmitChangeForApprovalParams(BaseModel): """Parameters for submitting a change request for approval.""" change_id: str = Field(..., description="Change request ID or sys_id") approval_comments: Optional[str] = Field(None, description="Comments for the approval request")
- src/servicenow_mcp/utils/tool_utils.py:468-474 (registration)Registration of the 'submit_change_for_approval' tool in the central tool_definitions dictionary, mapping name to handler function alias, schema, return type, description, and serialization method."submit_change_for_approval": ( submit_change_for_approval_tool, SubmitChangeForApprovalParams, str, "Submit a change request for approval", "str", # Tool returns simple message ),
- src/servicenow_mcp/tools/__init__.py:30-30 (registration)Re-export/import of the submit_change_for_approval function in tools/__init__.py for easy access.submit_change_for_approval,
- Import alias of the handler function used in tool registration.submit_change_for_approval as submit_change_for_approval_tool,