Skip to main content
Glama
vparlapalli490

ServiceNow MCP Server

list_catalog_items

Retrieve and filter service catalog items from ServiceNow instances. Use parameters like category, query, and active status to customize results, with options for pagination and limiting output.

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

  • The handler function that implements the list_catalog_items tool logic by querying the ServiceNow API for 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")
  • The tool registration entry 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 ),
  • Shared Pydantic model for catalog tool responses (used in related functions).
    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")
  • 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, )

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/vparlapalli490/MCP'

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