update_changeset
Modify an existing ServiceNow changeset by updating its name, description, state, or assigned developer to reflect current requirements or progress.
Instructions
Update an existing changeset in ServiceNow
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| changeset_id | Yes | Changeset ID or sys_id | |
| description | No | Description of the changeset | |
| developer | No | Developer responsible for the changeset | |
| name | No | Name of the changeset | |
| state | No | State of the changeset |
Implementation Reference
- The main handler function that implements the update_changeset tool logic. It validates parameters using UpdateChangesetParams, prepares a PATCH request to the ServiceNow API endpoint /api/now/table/sys_update_set/{changeset_id}, and returns the updated changeset details.def update_changeset( auth_manager: AuthManager, server_config: ServerConfig, params: Union[Dict[str, Any], UpdateChangesetParams], ) -> Dict[str, Any]: """ Update an existing changeset in ServiceNow. Args: auth_manager: The authentication manager. server_config: The server configuration. params: The parameters for updating a changeset. Can be a dictionary or a UpdateChangesetParams object. Returns: The updated changeset. """ # Unwrap and validate parameters result = _unwrap_and_validate_params( params, UpdateChangesetParams, required_fields=["changeset_id"] ) if not result["success"]: return result validated_params = result["params"] # Prepare the request data data = {} # Add optional fields if provided if validated_params.name: data["name"] = validated_params.name if validated_params.description: data["description"] = validated_params.description if validated_params.state: data["state"] = validated_params.state if validated_params.developer: data["developer"] = validated_params.developer # If no fields to update, return error if not data: return { "success": False, "message": "No fields to update", } # 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/sys_update_set/{validated_params.changeset_id}" try: response = requests.patch(url, json=data, headers=headers) response.raise_for_status() result = response.json() return { "success": True, "message": "Changeset updated successfully", "changeset": result["result"], } except requests.exceptions.RequestException as e: logger.error(f"Error updating changeset: {e}") return { "success": False, "message": f"Error updating changeset: {str(e)}", }
- Pydantic model defining the input parameters for the update_changeset tool, including required changeset_id and optional fields like name, description, state, developer.class UpdateChangesetParams(BaseModel): """Parameters for updating a changeset.""" changeset_id: str = Field(..., description="Changeset ID or sys_id") name: Optional[str] = Field(None, description="Name of the changeset") description: Optional[str] = Field(None, description="Description of the changeset") state: Optional[str] = Field(None, description="State of the changeset") developer: Optional[str] = Field(None, description="Developer responsible for the changeset")
- src/servicenow_mcp/utils/tool_utils.py:642-648 (registration)The tool registration entry in get_tool_definitions() dictionary, mapping 'update_changeset' to its handler (aliased as update_changeset_tool), schema (UpdateChangesetParams), description, and serialization settings."update_changeset": ( update_changeset_tool, UpdateChangesetParams, str, # Expects JSON string "Update an existing changeset in ServiceNow", "json_dict", # Tool returns Pydantic model ),
- src/servicenow_mcp/tools/__init__.py:40-40 (registration)Import of the update_changeset function from changeset_tools.py in the tools package __init__.py, making it available for export.update_changeset,
- src/servicenow_mcp/utils/tool_utils.py:117-117 (registration)Import alias of update_changeset as update_changeset_tool, used in the tool definitions.update_changeset as update_changeset_tool,