Skip to main content
Glama
JLKmach

ServiceNow MCP Server

by JLKmach

get_optimization_recommendations

Generate optimization recommendations for the service catalog to improve efficiency and performance.

Instructions

Get optimization recommendations for the service catalog.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
recommendation_typesYes
category_idNo

Implementation Reference

  • The main handler function implementing the get_optimization_recommendations tool. It processes various recommendation types by calling helper functions to fetch inactive items, low usage items, etc., and compiles them into recommendations.
    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 BaseModel defining the input schema 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
  • Tool registration in the central get_tool_definitions() function, associating the tool name with its handler, input schema, description, and serialization details.
    "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 tool handler in the tools package __init__.py, making it available for use in tool_utils.py and elsewhere.
    from servicenow_mcp.tools.catalog_optimization import (
        get_optimization_recommendations,
        update_catalog_item,
    )
  • Helper function to retrieve inactive catalog items via ServiceNow API, used by the main handler for 'inactive_items' recommendation type.
    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 []
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. The description only states what the tool does at a high level without revealing any behavioral traits such as whether it's a read-only operation, what permissions are required, how results are returned, or any rate limits. This leaves the agent with insufficient information about how the tool behaves when invoked.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with no wasted words. It's appropriately sized for a tool with a simple name, though this conciseness comes at the cost of detail. The structure is front-loaded with the core action, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a tool that presumably analyzes and provides recommendations, the description is completely inadequate. With no annotations, no output schema, and 0% schema description coverage, the description fails to provide essential context about what the tool returns, how to interpret results, or any behavioral expectations. This leaves significant gaps for an agent trying to use the tool effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, meaning the schema provides no descriptions for the two parameters ('recommendation_types' and 'category_id'). The description adds no information about what these parameters mean, what values they accept, or how they affect the output. For example, it doesn't explain what 'recommendation_types' are available or what 'category_id' refers to in the service catalog context.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose2/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states 'Get optimization recommendations for the service catalog' which is a tautology that essentially restates the tool name. It provides a verb ('Get') and resource ('optimization recommendations') but lacks specificity about what these recommendations entail or how they differ from other tools. Compared to sibling tools like 'list_catalog_items' or 'get_catalog_item', it doesn't clearly distinguish its unique function beyond the generic name.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, appropriate contexts, or exclusions. With many sibling tools focused on catalog management (e.g., 'list_catalog_items', 'get_catalog_item'), there's no indication of how this tool relates to them or when an agent should choose it over other options.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/JLKmach/servicenow-mcp'

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