Skip to main content
Glama
JLKmach

ServiceNow MCP Server

by JLKmach

list_catalog_items

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

Instructions

List service catalog items.

Input Schema

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

Implementation Reference

  • The main handler function that implements the list_catalog_items tool. It queries the ServiceNow API for sc_cat_item table with filters, formats the response, and returns a structured dictionary.
    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, including pagination, filtering by category/query/active status.
    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 get_tool_definitions dictionary, mapping name to implementation function, input schema model, return type hint, description, and serialization method. This is used by the MCP server to expose the tool.
    "list_catalog_items": (
        list_catalog_items_tool,
        ListCatalogItemsParams,
        str,  # Expects JSON string
        "List service catalog items.",
        "json",  # Tool returns list/dict
    ),
  • Import alias for the list_catalog_items function, used in tool registration.
    from servicenow_mcp.tools.catalog_tools import (
        list_catalog_items as list_catalog_items_tool,
    )
  • Import of catalog tools including list_catalog_items into the tools package __init__, making it available for further imports and tool_utils.
    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. It only states the action ('List') without mentioning pagination behavior, rate limits, authentication needs, or what 'service catalog items' entails (e.g., format, fields returned). This is inadequate for a tool with multiple parameters and no output schema.

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 zero wasted words. It's front-loaded with the core action and resource, making it immediately understandable without unnecessary elaboration.

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 tool's complexity (5 parameters, no annotations, no output schema), the description is incomplete. It lacks behavioral context (e.g., pagination, return format) and doesn't compensate for the absence of structured fields, making it insufficient for reliable agent use beyond basic invocation.

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?

The input schema has 100% description coverage, clearly documenting all 5 parameters (limit, offset, category, query, active). The description adds no additional parameter semantics beyond the schema, so it meets the baseline of 3 for adequate but not enhanced coverage.

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 'List service catalog items' clearly states the verb ('List') and resource ('service catalog items'), making the purpose understandable. However, it doesn't differentiate from sibling tools like 'list_catalog_categories' or 'list_catalog_item_variables' that also list related catalog entities, leaving room for confusion about scope.

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 siblings like 'get_catalog_item' (for single items) and 'list_catalog_categories' (for categories), there's no indication of context, prerequisites, or exclusions, leaving the agent to infer usage from the name 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

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