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 []
Behavior2/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. It mentions 'Get' but does not clarify if this is a read-only operation, what permissions are required, whether it has side effects, or how results are returned (e.g., pagination, format). For a tool with no annotation coverage, this is a significant gap in transparency.

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

Conciseness4/5

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

The description is a single, efficient sentence with no wasted words, making it easy to parse. However, it is overly concise to the point of under-specification, as it omits necessary details for effective tool use. This brevity is appropriate in structure but compromises completeness.

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

Completeness2/5

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

Given the complexity of optimization recommendations, no annotations, 0% schema coverage, and no output schema, the description is incomplete. It does not explain what the tool returns, how recommendations are structured, or any behavioral nuances. For a tool with two parameters and potential variability in output, this is inadequate.

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

Parameters2/5

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

Schema description coverage is 0%, so the description must compensate for undocumented parameters. It does not explain the meaning of 'category_id' or 'recommendation_types,' their expected values, or how they influence the output. Without this information, the agent lacks context for proper parameter usage, failing to add value beyond the bare schema.

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

Purpose3/5

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

The description states the tool's purpose as 'Get optimization recommendations for the service catalog,' which is clear but vague. It specifies the verb 'Get' and resource 'optimization recommendations,' but does not detail what these recommendations entail or how they differ from other tools like 'list_catalog_items' or 'update_catalog_item.' This lack of specificity prevents it from achieving a higher score.

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

Usage Guidelines2/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. With many sibling tools related to catalog management (e.g., 'list_catalog_items,' 'update_catalog_item'), there is no indication of context, prerequisites, or exclusions. This absence of usage instructions limits its effectiveness for an AI agent.

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

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