update_catalog_category
Modify an existing service catalog category by updating its title, description, parent category, icon, active status, or display order in ServiceNow.
Instructions
Update an existing service catalog category.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| active | No | Whether the category is active | |
| category_id | Yes | Category ID or sys_id | |
| description | No | Description of the category | |
| icon | No | Icon for the category | |
| order | No | Order of the category | |
| parent | No | Parent category sys_id | |
| title | No | Title of the category |
Implementation Reference
- The main handler function that performs the PATCH request to update a ServiceNow catalog category using the provided parameters.def update_catalog_category( config: ServerConfig, auth_manager: AuthManager, params: UpdateCatalogCategoryParams, ) -> CatalogResponse: """ Update an existing service catalog category in ServiceNow. Args: config: Server configuration auth_manager: Authentication manager params: Parameters for updating a catalog category Returns: Response containing the result of the operation """ logger.info(f"Updating service catalog category: {params.category_id}") # Build the API URL url = f"{config.instance_url}/api/now/table/sc_category/{params.category_id}" # Prepare request body with only the provided parameters body = {} if params.title is not None: body["title"] = params.title if params.description is not None: body["description"] = params.description if params.parent is not None: body["parent"] = params.parent if params.icon is not None: body["icon"] = params.icon if params.active is not None: body["active"] = str(params.active).lower() if params.order is not None: body["order"] = str(params.order) # Make the API request headers = auth_manager.get_headers() headers["Accept"] = "application/json" headers["Content-Type"] = "application/json" try: response = requests.patch(url, headers=headers, json=body) response.raise_for_status() # Process the response result = response.json() category = result.get("result", {}) # Format the response formatted_category = { "sys_id": category.get("sys_id", ""), "title": category.get("title", ""), "description": category.get("description", ""), "parent": category.get("parent", ""), "icon": category.get("icon", ""), "active": category.get("active", ""), "order": category.get("order", ""), } return CatalogResponse( success=True, message=f"Updated catalog category: {params.category_id}", data=formatted_category, ) except requests.exceptions.RequestException as e: logger.error(f"Error updating catalog category: {str(e)}") return CatalogResponse( success=False, message=f"Error updating catalog category: {str(e)}", data=None, )
- Pydantic model defining the input parameters for the update_catalog_category tool, including category_id (required) and optional fields like title, description, etc.class UpdateCatalogCategoryParams(BaseModel): """Parameters for updating a service catalog category.""" category_id: str = Field(..., description="Category ID or sys_id") title: Optional[str] = Field(None, description="Title of the category") description: Optional[str] = Field(None, description="Description of the category") parent: Optional[str] = Field(None, description="Parent category sys_id") icon: Optional[str] = Field(None, description="Icon for the category") active: Optional[bool] = Field(None, description="Whether the category is active") order: Optional[int] = Field(None, description="Order of the category")
- src/servicenow_mcp/utils/tool_utils.py:428-434 (registration)Registration of the tool in the central tool_definitions dictionary, mapping the tool name to its implementation function, params schema, return type hint, description, and serialization method."update_catalog_category": ( update_catalog_category_tool, UpdateCatalogCategoryParams, str, # Expects JSON string "Update an existing service catalog category.", "json_dict", # Tool returns Pydantic model ),