Skip to main content
Glama
vparlapalli490

ServiceNow MCP Server

list_articles

Retrieve ServiceNow knowledge articles with filtering options for knowledge base, category, workflow state, and search queries to find relevant information.

Instructions

List knowledge articles

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of articles to return
offsetNoOffset for pagination
knowledge_baseNoFilter by knowledge base
categoryNoFilter by category
queryNoSearch query for articles
workflow_stateNoFilter by workflow state

Implementation Reference

  • Handler function that implements the list_articles tool by querying the ServiceNow kb_knowledge table API with filters and transforming the response.
    def list_articles(
        config: ServerConfig,
        auth_manager: AuthManager,
        params: ListArticlesParams,
    ) -> Dict[str, Any]:
        """
        List knowledge articles with filtering options.
    
        Args:
            config: Server configuration.
            auth_manager: Authentication manager.
            params: Parameters for listing articles.
    
        Returns:
            Dictionary with list of articles and metadata.
        """
        api_url = f"{config.api_url}/table/kb_knowledge"
    
        # Build query parameters
        query_params = {
            "sysparm_limit": params.limit,
            "sysparm_offset": params.offset,
            "sysparm_display_value": "all",
        }
    
        # Build query string
        query_parts = []
        if params.knowledge_base:
            query_parts.append(f"kb_knowledge_base.sys_id={params.knowledge_base}")
        if params.category:
            query_parts.append(f"kb_category.sys_id={params.category}")
        if params.workflow_state:
            query_parts.append(f"workflow_state={params.workflow_state}")
        if params.query:
            query_parts.append(f"short_descriptionLIKE{params.query}^ORtextLIKE{params.query}")
    
        if query_parts:
            query_string = "^".join(query_parts)
            logger.debug(f"Constructed article query string: {query_string}")
            query_params["sysparm_query"] = query_string
        
        # Log the query parameters for debugging
        logger.debug(f"Listing articles with query params: {query_params}")
    
        # Make request
        try:
            response = requests.get(
                api_url,
                params=query_params,
                headers=auth_manager.get_headers(),
                timeout=config.timeout,
            )
            response.raise_for_status()
    
            # Get the JSON response
            json_response = response.json()
            logger.debug(f"Article listing raw response: {json_response}")
            
            # Safely extract the result
            if isinstance(json_response, dict) and "result" in json_response:
                result = json_response.get("result", [])
            else:
                logger.error("Unexpected response format: %s", json_response)
                return {
                    "success": False,
                    "message": f"Unexpected response format",
                    "articles": [],
                    "count": 0,
                    "limit": params.limit,
                    "offset": params.offset,
                }
    
            # Transform the results
            articles = []
            
            # Handle either string or list
            if isinstance(result, list):
                for article_item in result:
                    if not isinstance(article_item, dict):
                        logger.warning("Skipping non-dictionary article item: %s", article_item)
                        continue
                        
                    # Safely extract values
                    article_id = article_item.get("sys_id", "")
                    title = article_item.get("short_description", "")
                    
                    # Extract nested values safely
                    knowledge_base = ""
                    if isinstance(article_item.get("kb_knowledge_base"), dict):
                        knowledge_base = article_item["kb_knowledge_base"].get("display_value", "")
                    
                    category = ""
                    if isinstance(article_item.get("kb_category"), dict):
                        category = article_item["kb_category"].get("display_value", "")
                    
                    workflow_state = ""
                    if isinstance(article_item.get("workflow_state"), dict):
                        workflow_state = article_item["workflow_state"].get("display_value", "")
                    
                    created = article_item.get("sys_created_on", "")
                    updated = article_item.get("sys_updated_on", "")
                    
                    articles.append({
                        "id": article_id,
                        "title": title,
                        "knowledge_base": knowledge_base,
                        "category": category,
                        "workflow_state": workflow_state,
                        "created": created,
                        "updated": updated,
                    })
            else:
                logger.warning("Result is not a list: %s", result)
    
            return {
                "success": True,
                "message": f"Found {len(articles)} articles",
                "articles": articles,
                "count": len(articles),
                "limit": params.limit,
                "offset": params.offset,
            }
    
        except requests.RequestException as e:
            logger.error(f"Failed to list articles: {e}")
            return {
                "success": False,
                "message": f"Failed to list articles: {str(e)}",
                "articles": [],
                "count": 0,
                "limit": params.limit,
                "offset": params.offset,
            }
  • Pydantic model defining input parameters for the list_articles tool, including pagination and filtering options.
    class ListArticlesParams(BaseModel):
        """Parameters for listing knowledge articles."""
        
        limit: int = Field(10, description="Maximum number of articles to return")
        offset: int = Field(0, description="Offset for pagination")
        knowledge_base: Optional[str] = Field(None, description="Filter by knowledge base")
        category: Optional[str] = Field(None, description="Filter by category")
        query: Optional[str] = Field(None, description="Search query for articles")
        workflow_state: Optional[str] = Field(None, description="Filter by workflow state")
  • Registration of the list_articles tool in the central tool definitions dictionary used by the MCP server.
    "list_articles": (
        list_articles_tool,
        ListArticlesParams,
        Dict[str, Any],  # Expects dict
        "List knowledge articles",
        "raw_dict",  # Tool returns raw dict
    ),
  • Import of the list_articles handler aliased as list_articles_tool for use in tool registration.
    from servicenow_mcp.tools.knowledge_base import (
        list_articles as list_articles_tool,
    )
  • Re-export of list_articles from knowledge_base module in tools package init.
    from servicenow_mcp.tools.knowledge_base import (
        create_article,
        create_category,
        create_knowledge_base,
        get_article,
        list_articles,
        list_knowledge_bases,
        publish_article,
        update_article,
        list_categories,
    )
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. 'List knowledge articles' implies a read-only operation, but it doesn't specify whether this requires permissions, how results are ordered, if there are rate limits, or what the output format looks like (e.g., list of objects with fields). For a tool with 6 parameters and no annotations, this is a significant gap in behavioral context.

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 extremely concise with just three words ('List knowledge articles'), making it front-loaded and efficient. There is no wasted language or unnecessary elaboration, which aligns well with the tool's simple purpose, though this conciseness comes at the cost of detail in other dimensions.

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 (6 parameters, no annotations, no output schema), the description is incomplete. It doesn't explain the return values (e.g., what fields are included in listed articles), behavioral aspects like pagination or filtering logic, or how it differs from siblings. For a list tool with multiple filtering options, more context 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.

Parameters3/5

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

The input schema has 100% description coverage, with each parameter clearly documented (e.g., 'limit' for maximum articles, 'query' for search). The description adds no additional parameter semantics beyond what the schema provides, but since the schema coverage is high, the baseline score of 3 is appropriate as the schema adequately handles parameter documentation.

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 knowledge articles' clearly states the verb ('List') and resource ('knowledge articles'), making the basic purpose understandable. However, it lacks specificity about what aspects of articles are listed (e.g., titles, metadata) and doesn't distinguish itself from sibling tools like 'get_article' or 'list_knowledge_bases', which could cause 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. It doesn't mention when to choose 'list_articles' over 'get_article' (for single article details) or 'list_knowledge_bases' (for listing knowledge bases instead of articles), nor does it specify prerequisites like authentication or context. This leaves the agent without usage direction.

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

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