Skip to main content
Glama
echelon-ai-labs

ServiceNow MCP Server

get_catalog_item

Retrieve a specific service catalog item using its ID or sys_id via the ServiceNow API.

Instructions

Get a specific service catalog item.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Implementation Reference

  • Main handler function that retrieves a specific ServiceNow service catalog item by ID using the Table API, formats the item details including variables, and returns a structured CatalogResponse.
    def get_catalog_item(
        config: ServerConfig,
        auth_manager: AuthManager,
        params: GetCatalogItemParams,
    ) -> CatalogResponse:
        """
        Get a specific service catalog item from ServiceNow.
    
        Args:
            config: Server configuration
            auth_manager: Authentication manager
            params: Parameters for getting a catalog item
    
        Returns:
            Response containing the catalog item details
        """
        logger.info(f"Getting service catalog item: {params.item_id}")
        
        # Build the API URL
        url = f"{config.instance_url}/api/now/table/sc_cat_item/{params.item_id}"
        
        # Prepare query parameters
        query_params = {
            "sysparm_display_value": "true",
            "sysparm_exclude_reference_link": "true",
        }
        
        # Make the API request
        headers = auth_manager.get_headers()
        headers["Accept"] = "application/json"
        
        try:
            response = requests.get(url, headers=headers, params=query_params)
            response.raise_for_status()
            
            # Process the response
            result = response.json()
            item = result.get("result", {})
            
            if not item:
                return CatalogResponse(
                    success=False,
                    message=f"Catalog item not found: {params.item_id}",
                    data=None,
                )
            
            # Format the response
            formatted_item = {
                "sys_id": item.get("sys_id", ""),
                "name": item.get("name", ""),
                "short_description": item.get("short_description", ""),
                "description": item.get("description", ""),
                "category": item.get("category", ""),
                "price": item.get("price", ""),
                "picture": item.get("picture", ""),
                "active": item.get("active", ""),
                "order": item.get("order", ""),
                "delivery_time": item.get("delivery_time", ""),
                "availability": item.get("availability", ""),
                "variables": get_catalog_item_variables(config, auth_manager, params.item_id),
            }
            
            return CatalogResponse(
                success=True,
                message=f"Retrieved catalog item: {item.get('name', '')}",
                data=formatted_item,
            )
        
        except requests.exceptions.RequestException as e:
            logger.error(f"Error getting catalog item: {str(e)}")
            return CatalogResponse(
                success=False,
                message=f"Error getting catalog item: {str(e)}",
                data=None,
            )
  • Pydantic model defining the input parameters for the get_catalog_item tool, requiring an item_id.
    class GetCatalogItemParams(BaseModel):
        """Parameters for getting a specific service catalog item."""
        
        item_id: str = Field(..., description="Catalog item ID or sys_id")
  • Pydantic model used for the output response of the get_catalog_item tool and other catalog operations.
    class CatalogResponse(BaseModel):
        """Response from catalog operations."""
    
        success: bool = Field(..., description="Whether the operation was successful")
        message: str = Field(..., description="Message describing the result")
        data: Optional[Dict[str, Any]] = Field(None, description="Response data")
  • Tool registration in the central tool definitions dictionary, mapping the tool name to its handler, params schema, return type, description, and serialization method.
    "get_catalog_item": (
        get_catalog_item_tool,
        GetCatalogItemParams,
        str,  # Expects JSON string
        "Get a specific service catalog item.",
        "json_dict",  # Tool returns Pydantic model
    ),
  • Helper function called by get_catalog_item to fetch and format the variables (options) for the catalog item from the item_option_new table.
    def get_catalog_item_variables(
        config: ServerConfig,
        auth_manager: AuthManager,
        item_id: str,
    ) -> List[Dict[str, Any]]:
        """
        Get variables for a specific service catalog item.
    
        Args:
            config: Server configuration
            auth_manager: Authentication manager
            item_id: Catalog item ID or sys_id
    
        Returns:
            List of variables for the catalog item
        """
        logger.info(f"Getting variables for catalog item: {item_id}")
        
        # Build the API URL
        url = f"{config.instance_url}/api/now/table/item_option_new"
        
        # Prepare query parameters
        query_params = {
            "sysparm_query": f"cat_item={item_id}^ORDERBYorder",
            "sysparm_display_value": "true",
            "sysparm_exclude_reference_link": "true",
        }
        
        # Make the API request
        headers = auth_manager.get_headers()
        headers["Accept"] = "application/json"
        
        try:
            response = requests.get(url, headers=headers, params=query_params)
            response.raise_for_status()
            
            # Process the response
            result = response.json()
            variables = result.get("result", [])
            
            # Format the response
            formatted_variables = []
            for variable in variables:
                formatted_variables.append({
                    "sys_id": variable.get("sys_id", ""),
                    "name": variable.get("name", ""),
                    "label": variable.get("question_text", ""),
                    "type": variable.get("type", ""),
                    "mandatory": variable.get("mandatory", ""),
                    "default_value": variable.get("default_value", ""),
                    "help_text": variable.get("help_text", ""),
                    "order": variable.get("order", ""),
                })
            
            return formatted_variables
        
        except requests.exceptions.RequestException as e:
            logger.error(f"Error getting catalog item variables: {str(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 full burden for behavioral disclosure. It fails to describe any behavioral traits: it doesn't indicate if this is a read-only operation, what permissions are required, how errors are handled (e.g., invalid item_id), or the format of the returned data. For a tool with zero annotation coverage, this is a significant gap.

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 that directly states the tool's purpose without unnecessary words. It is front-loaded with the core action and resource, making it easy to parse quickly. Every word earns its place, adhering to ideal conciseness.

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 (a read operation with one parameter), lack of annotations, and no output schema, the description is incomplete. It doesn't cover behavioral aspects like safety, error handling, or return format, nor does it clarify parameter semantics. For a tool in this context, more detail is needed to guide effective use.

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 adds no information about the 'item_id' parameter beyond what the schema minimally provides (type and requirement). The description doesn't explain what constitutes a valid 'item_id', where to find it, or provide examples, leaving semantics unclear.

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

Purpose4/5

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

The description clearly states the action ('Get') and resource ('a specific service catalog item'), making the purpose understandable. It distinguishes this from sibling tools like 'list_catalog_items' by specifying retrieval of a single item rather than listing multiple items. However, it doesn't explicitly differentiate from other 'get_' tools like 'get_article' or 'get_user', which follow similar patterns.

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. It doesn't mention prerequisites (e.g., needing an item ID), contrast with 'list_catalog_items' for browsing, or specify error conditions. Without such context, the agent must infer usage from the tool name and schema alone.

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

Related 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/echelon-ai-labs/servicenow-mcp'

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