Skip to main content
Glama
javerthl

ServiceNow MCP Server

by javerthl

get_optimization_recommendations

Generate optimization recommendations for the ServiceNow service catalog to improve performance and efficiency based on specified recommendation types and categories.

Instructions

Get optimization recommendations for the service catalog.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
category_idNo
recommendation_typesYes

Implementation Reference

  • Core handler function that orchestrates fetching various types of catalog optimization recommendations by calling helper functions like _get_inactive_items, _get_low_usage_items, etc., and formats them into a response dictionary.
    def get_optimization_recommendations( config: ServerConfig, auth_manager: AuthManager, params: OptimizationRecommendationsParams ) -> Dict: """ Get optimization recommendations for the ServiceNow Service Catalog. Args: config: The server configuration auth_manager: The authentication manager params: The parameters for getting optimization recommendations Returns: A dictionary containing the optimization recommendations """ logger.info("Getting catalog optimization recommendations") recommendations = [] category_id = params.category_id try: # Get recommendations based on the requested types for rec_type in params.recommendation_types: if rec_type == "inactive_items": items = _get_inactive_items(config, auth_manager, category_id) if items: recommendations.append({ "type": "inactive_items", "title": "Inactive Catalog Items", "description": "Items that are currently inactive in the catalog", "items": items, "impact": "medium", "effort": "low", "action": "Review and either update or remove these items", }) elif rec_type == "low_usage": items = _get_low_usage_items(config, auth_manager, category_id) if items: recommendations.append({ "type": "low_usage", "title": "Low Usage Catalog Items", "description": "Items that have very few orders", "items": items, "impact": "medium", "effort": "medium", "action": "Consider promoting these items or removing them if no longer needed", }) elif rec_type == "high_abandonment": items = _get_high_abandonment_items(config, auth_manager, category_id) if items: recommendations.append({ "type": "high_abandonment", "title": "High Abandonment Rate Items", "description": "Items that are frequently added to cart but not ordered", "items": items, "impact": "high", "effort": "medium", "action": "Simplify the request process or improve the item description", }) elif rec_type == "slow_fulfillment": items = _get_slow_fulfillment_items(config, auth_manager, category_id) if items: recommendations.append({ "type": "slow_fulfillment", "title": "Slow Fulfillment Items", "description": "Items that take longer than average to fulfill", "items": items, "impact": "high", "effort": "high", "action": "Review the fulfillment process and identify bottlenecks", }) elif rec_type == "description_quality": items = _get_poor_description_items(config, auth_manager, category_id) if items: recommendations.append({ "type": "description_quality", "title": "Poor Description Quality", "description": "Items with missing, short, or low-quality descriptions", "items": items, "impact": "medium", "effort": "low", "action": "Improve the descriptions to better explain the item's purpose and benefits", }) return { "success": True, "recommendations": recommendations, } except Exception as e: logger.error(f"Error getting optimization recommendations: {e}") return { "success": False, "message": f"Error getting optimization recommendations: {str(e)}", "recommendations": [], }
  • Pydantic model defining the input parameters for the tool: list of recommendation types and optional category ID.
    class OptimizationRecommendationsParams(BaseModel): """Parameters for getting optimization recommendations.""" recommendation_types: List[str] category_id: Optional[str] = None
  • Registration of the tool in the get_tool_definitions dictionary, linking the aliased handler function, input schema, return type hint, description, and serialization method.
    "get_optimization_recommendations": ( get_optimization_recommendations_tool, OptimizationRecommendationsParams, str, # Expects JSON string "Get optimization recommendations for the service catalog.", "json", # Tool returns list/dict ),
  • Export/import of the handler function from catalog_optimization module into tools namespace.
    from servicenow_mcp.tools.catalog_optimization import ( get_optimization_recommendations, update_catalog_item, )
  • Helper function to fetch inactive catalog items via ServiceNow API, used by the main handler.
    def _get_inactive_items( config: ServerConfig, auth_manager: AuthManager, category_id: Optional[str] = None ) -> List[Dict]: """ Get inactive catalog items. Args: config: The server configuration auth_manager: The authentication manager category_id: Optional category ID to filter by Returns: A list of inactive catalog items """ try: # Build the query query = "active=false" if category_id: query += f"^category={category_id}" # Make the API request url = f"{config.instance_url}/api/now/table/sc_cat_item" headers = auth_manager.get_headers() params = { "sysparm_query": query, "sysparm_fields": "sys_id,name,short_description,category", "sysparm_limit": "50", } response = requests.get(url, headers=headers, params=params) response.raise_for_status() return response.json()["result"] except Exception as e: logger.error(f"Error getting inactive items: {e}") return []

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/javerthl/servicenow-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server