Skip to main content
Glama
javerthl

ServiceNow MCP Server

by javerthl

list_catalog_items

Retrieve available service catalog items from ServiceNow with filtering options for category, search query, and active status to support service request management.

Instructions

List service catalog items.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
activeNoWhether to only return active catalog items
categoryNoFilter by category
limitNoMaximum number of catalog items to return
offsetNoOffset for pagination
queryNoSearch query for catalog items

Implementation Reference

  • Implementation of the list_catalog_items tool handler, which queries the ServiceNow sc_cat_item table API with filters and returns formatted catalog items.
    def list_catalog_items(
        config: ServerConfig,
        auth_manager: AuthManager,
        params: ListCatalogItemsParams,
    ) -> Dict[str, Any]:
        """
        List service catalog items from ServiceNow.
    
        Args:
            config: Server configuration
            auth_manager: Authentication manager
            params: Parameters for listing catalog items
    
        Returns:
            Dictionary containing catalog items and metadata
        """
        logger.info("Listing service catalog items")
        
        # Build the API URL
        url = f"{config.instance_url}/api/now/table/sc_cat_item"
        
        # Prepare query parameters
        query_params = {
            "sysparm_limit": params.limit,
            "sysparm_offset": params.offset,
            "sysparm_display_value": "true",
            "sysparm_exclude_reference_link": "true",
        }
        
        # Add filters
        filters = []
        if params.active:
            filters.append("active=true")
        if params.category:
            filters.append(f"category={params.category}")
        if params.query:
            filters.append(f"short_descriptionLIKE{params.query}^ORnameLIKE{params.query}")
        
        if filters:
            query_params["sysparm_query"] = "^".join(filters)
        
        # 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()
            items = result.get("result", [])
            
            # Format the response
            formatted_items = []
            for item in items:
                formatted_items.append({
                    "sys_id": item.get("sys_id", ""),
                    "name": item.get("name", ""),
                    "short_description": item.get("short_description", ""),
                    "category": item.get("category", ""),
                    "price": item.get("price", ""),
                    "picture": item.get("picture", ""),
                    "active": item.get("active", ""),
                    "order": item.get("order", ""),
                })
            
            return {
                "success": True,
                "message": f"Retrieved {len(formatted_items)} catalog items",
                "items": formatted_items,
                "total": len(formatted_items),
                "limit": params.limit,
                "offset": params.offset,
            }
        
        except requests.exceptions.RequestException as e:
            logger.error(f"Error listing catalog items: {str(e)}")
            return {
                "success": False,
                "message": f"Error listing catalog items: {str(e)}",
                "items": [],
                "total": 0,
                "limit": params.limit,
                "offset": params.offset,
            }
  • Pydantic model defining the input parameters for the list_catalog_items tool.
    class ListCatalogItemsParams(BaseModel):
        """Parameters for listing service catalog items."""
        
        limit: int = Field(10, description="Maximum number of catalog items to return")
        offset: int = Field(0, description="Offset for pagination")
        category: Optional[str] = Field(None, description="Filter by category")
        query: Optional[str] = Field(None, description="Search query for catalog items")
        active: bool = Field(True, description="Whether to only return active catalog items")
  • Registration of the list_catalog_items tool in the central tool definitions dictionary used by the MCP server.
    "list_catalog_items": (
        list_catalog_items_tool,
        ListCatalogItemsParams,
        str,  # Expects JSON string
        "List service catalog items.",
        "json",  # Tool returns list/dict
    ),
  • Import and alias of the list_catalog_items function for use in tool registration.
    from servicenow_mcp.tools.catalog_tools import (
        list_catalog_items as list_catalog_items_tool,
    )
  • Re-export of list_catalog_items from catalog_tools in the tools package __init__.
    from servicenow_mcp.tools.catalog_tools import (
        create_catalog_category,
        get_catalog_item,
        list_catalog_categories,
        list_catalog_items,
        move_catalog_items,
        update_catalog_category,
    )
Behavior2/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. 'List service catalog items' implies a read-only operation that returns multiple items, but doesn't disclose important behaviors like pagination handling (though the schema shows limit/offset), authentication requirements, rate limits, error conditions, or what happens when no items match filters. The description adds minimal value beyond the basic operation name.

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 maximally concise - a single four-word sentence that states the core operation. There's zero wasted language or unnecessary elaboration. While this conciseness comes at the cost of completeness, the structure is perfectly efficient for what it does communicate.

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?

For a list operation with 5 parameters, no annotations, and no output schema, the description is severely incomplete. It doesn't explain what 'service catalog items' are in this context, what fields are returned, how results are ordered, whether there are permissions considerations, or what the response format looks like. The agent would need to guess about many important aspects of using this tool effectively.

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

Parameters3/5

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

Schema description coverage is 100%, so all 5 parameters are well-documented in the schema itself. The description adds no parameter information beyond what's in the schema - it doesn't explain relationships between parameters, provide examples of valid category values, or clarify search query syntax. With complete schema coverage, the baseline of 3 is appropriate as the description doesn't compensate but also doesn't need to.

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 'List service catalog items' is a tautology that essentially restates the tool name 'list_catalog_items'. It provides the verb 'List' and resource 'service catalog items', but doesn't specify what catalog items are, what fields are returned, or how this differs from sibling tools like 'get_catalog_item' or 'list_catalog_categories'. The purpose is clear at a basic level but lacks meaningful differentiation from related tools.

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 absolutely no guidance on when to use this tool versus alternatives. With multiple sibling tools like 'get_catalog_item' (singular retrieval), 'list_catalog_categories', and 'list_catalog_item_variables', there's no indication of when this list operation is appropriate versus those other catalog-related operations. No context, prerequisites, or exclusions are mentioned.

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