This document outlines the plan for implementing catalog optimization features in the ServiceNow MCP integration.
The catalog optimization features will help users analyze, manage, and improve their existing ServiceNow service catalogs. These features will provide insights into catalog usage, performance, and structure, and offer recommendations for optimization.
Parameters:
class CatalogUsageStatsParams(BaseModel):
"""Parameters for getting catalog usage statistics."""
time_period: str = Field("last_30_days", description="Time period for statistics (last_7_days, last_30_days, last_90_days, last_year)")
category_id: Optional[str] = Field(None, description="Filter by category ID")
include_inactive: bool = Field(False, description="Whether to include inactive items")Returns:
- Most ordered items
- Least ordered items
- Average processing time
- Abandonment rate (items added to cart but not ordered)
- User satisfaction ratings
Implementation:
- Query the ServiceNow API for order statistics
- Aggregate data by item and category
- Calculate metrics like order volume, processing time, and abandonment rate
Parameters:
class ItemPerformanceParams(BaseModel):
"""Parameters for getting performance metrics for a catalog item."""
item_id: str = Field(..., description="Catalog item ID")
time_period: str = Field("last_30_days", description="Time period for metrics")Returns:
- Order volume over time
- Average fulfillment time
- Approval rates
- Rejection reasons
- User ratings and feedback
Implementation:
- Query the ServiceNow API for item-specific metrics
- Calculate performance indicators
- Identify trends over the specified time period
Parameters:
class UpdateCatalogItemParams(BaseModel):
"""Parameters for updating a catalog item."""
item_id: str = Field(..., description="Catalog item ID to update")
name: Optional[str] = Field(None, description="New name for the item")
short_description: Optional[str] = Field(None, description="New short description")
description: Optional[str] = Field(None, description="New detailed description")
category: Optional[str] = Field(None, description="New category ID")
price: Optional[str] = Field(None, description="New price")
active: Optional[bool] = Field(None, description="Whether the item is active")
order: Optional[int] = Field(None, description="Display order in the category")Implementation:
- Build a PATCH request to update the catalog item
- Only include fields that are provided in the parameters
- Return the updated item details
Parameters:
class UpdateCatalogCategoryParams(BaseModel):
"""Parameters for updating a catalog category."""
category_id: str = Field(..., description="Category ID to update")
title: Optional[str] = Field(None, description="New title for the category")
description: Optional[str] = Field(None, description="New description")
parent: Optional[str] = Field(None, description="New parent category ID")
active: Optional[bool] = Field(None, description="Whether the category is active")
order: Optional[int] = Field(None, description="Display order")Implementation:
- Build a PATCH request to update the catalog category
- Only include fields that are provided in the parameters
- Return the updated category details
Parameters:
class UpdateItemVariableParams(BaseModel):
"""Parameters for updating a catalog item variable."""
variable_id: str = Field(..., description="Variable ID to update")
label: Optional[str] = Field(None, description="New label for the variable")
help_text: Optional[str] = Field(None, description="New help text")
default_value: Optional[str] = Field(None, description="New default value")
mandatory: Optional[bool] = Field(None, description="Whether the variable is mandatory")
order: Optional[int] = Field(None, description="Display order")Implementation:
- Build a PATCH request to update the catalog item variable
- Only include fields that are provided in the parameters
- Return the updated variable details
Parameters:
class OptimizationRecommendationsParams(BaseModel):
"""Parameters for getting catalog optimization recommendations."""
category_id: Optional[str] = Field(None, description="Filter by category ID")
recommendation_types: List[str] = Field(
["inactive_items", "low_usage", "high_abandonment", "slow_fulfillment", "description_quality"],
description="Types of recommendations to include"
)Returns:
- Inactive items that could be retired
- Items with low usage that might need promotion
- Items with high abandonment rates that might need simplification
- Items with slow fulfillment that need process improvements
- Items with poor description quality
Implementation:
- Query the ServiceNow API for various metrics
- Apply analysis algorithms to identify optimization opportunities
- Generate recommendations based on the analysis
Parameters:
class CatalogStructureAnalysisParams(BaseModel):
"""Parameters for analyzing catalog structure."""
include_inactive: bool = Field(False, description="Whether to include inactive categories and items")Returns:
- Categories with too many or too few items
- Deeply nested categories that might be hard to navigate
- Inconsistent naming patterns
- Duplicate or similar items across categories
Implementation:
- Query the ServiceNow API for the catalog structure
- Analyze the structure for usability issues
- Generate recommendations for improving the structure
- Implement
get_catalog_usage_stats - Implement
get_item_performance - Create tests for analytics tools
- Implement
update_catalog_item - Implement
update_catalog_category - Implement
update_item_variable - Create tests for management tools
- Implement
get_optimization_recommendations - Implement
get_catalog_structure_analysis - Create tests for optimization tools
- Register all tools with the MCP server
- Create example scripts for optimization workflows
- Update documentation
# Get catalog usage statistics
params = CatalogUsageStatsParams(time_period="last_90_days")
result = get_catalog_usage_stats(config, auth_manager, params)
# Print the most ordered items
print("Most ordered items:")
for item in result["most_ordered_items"]:
print(f"- {item['name']}: {item['order_count']} orders")
# Print items with high abandonment rates
print("\nItems with high abandonment rates:")
for item in result["high_abandonment_items"]:
print(f"- {item['name']}: {item['abandonment_rate']}% abandonment rate")# Get optimization recommendations
params = OptimizationRecommendationsParams(
recommendation_types=["inactive_items", "low_usage", "description_quality"]
)
result = get_optimization_recommendations(config, auth_manager, params)
# Print the recommendations
for rec in result["recommendations"]:
print(f"\n{rec['title']}")
print(f"Impact: {rec['impact']}, Effort: {rec['effort']}")
print(f"{rec['description']}")
print(f"Recommended Action: {rec['action']}")
print(f"Affected Items: {len(rec['items'])}")
for item in rec['items'][:3]:
print(f"- {item['name']}: {item['short_description']}")# Update a catalog item
params = UpdateCatalogItemParams(
item_id="sys_id_of_item",
short_description="Updated description that is more clear and informative",
price="99.99"
)
result = update_catalog_item(config, auth_manager, params)
if result["success"]:
print(f"Successfully updated item: {result['data']['name']}")
else:
print(f"Error: {result['message']}")-
Data Access: These tools require access to ServiceNow reporting and analytics data, which might require additional permissions.
-
Performance: Some of these analyses could be resource-intensive, especially for large catalogs.
-
Custom Metrics: ServiceNow instances often have custom metrics and KPIs for catalog performance, which would need to be considered.
-
Change Management: Any changes to the catalog should follow proper change management processes.
-
User Feedback: Incorporating user feedback data would make the optimization recommendations more valuable.