Skip to main content
Glama
JLKmach

ServiceNow MCP Server

by JLKmach

list_epics

Retrieve and filter ServiceNow epics by priority, assignment group, timeframe, or custom queries to manage agile project workflows.

Instructions

List epics from ServiceNow

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of records to return
offsetNoOffset to start from
priorityNoFilter by priority
assignment_groupNoFilter by assignment group
timeframeNoFilter by timeframe (upcoming, in-progress, completed)
queryNoAdditional query string

Implementation Reference

  • The core handler function for the 'list_epics' tool. It validates input parameters using ListEpicsParams, constructs a ServiceNow query based on filters like priority, assignment_group, timeframe, and custom query, then performs a GET request to the /api/now/table/rm_epic endpoint to retrieve epics.
    def list_epics(
        auth_manager: AuthManager,
        server_config: ServerConfig,
        params: Dict[str, Any],
    ) -> Dict[str, Any]:
        """
        List epics from ServiceNow.
    
        Args:
            auth_manager: The authentication manager.
            server_config: The server configuration.
            params: The parameters for listing epics.
    
        Returns:
            A list of epics.
        """
        # Unwrap and validate parameters
        result = _unwrap_and_validate_params(
            params, 
            ListEpicsParams
        )
        
        if not result["success"]:
            return result
        
        validated_params = result["params"]
        
        # Build the query
        query_parts = []
        
        if validated_params.priority:
            query_parts.append(f"priority={validated_params.priority}")
        if validated_params.assignment_group:
            query_parts.append(f"assignment_group={validated_params.assignment_group}")
        
        # Handle timeframe filtering
        if validated_params.timeframe:
            now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
            if validated_params.timeframe == "upcoming":
                query_parts.append(f"start_date>{now}")
            elif validated_params.timeframe == "in-progress":
                query_parts.append(f"start_date<{now}^end_date>{now}")
            elif validated_params.timeframe == "completed":
                query_parts.append(f"end_date<{now}")
        
        # Add any additional query string
        if validated_params.query:
            query_parts.append(validated_params.query)
        
        # Combine query parts
        query = "^".join(query_parts) if query_parts else ""
        
        # Get the instance URL
        instance_url = _get_instance_url(auth_manager, server_config)
        if not instance_url:
            return {
                "success": False,
                "message": "Cannot find instance_url in either server_config or auth_manager",
            }
        
        # Get the headers
        headers = _get_headers(auth_manager, server_config)
        if not headers:
            return {
                "success": False,
                "message": "Cannot find get_headers method in either auth_manager or server_config",
            }
        
        # Make the API request
        url = f"{instance_url}/api/now/table/rm_epic"
        
        params = {
            "sysparm_limit": validated_params.limit,
            "sysparm_offset": validated_params.offset,
            "sysparm_query": query,
            "sysparm_display_value": "true",
        }
        
        try:
            response = requests.get(url, headers=headers, params=params)
            response.raise_for_status()
            
            result = response.json()
            
            # Handle the case where result["result"] is a list
            epics = result.get("result", [])
            count = len(epics)
            
            return {
                "success": True,
                "epics": epics,
                "count": count,
                "total": count,  # Use count as total if total is not provided
            }
        except requests.exceptions.RequestException as e:
            logger.error(f"Error listing epics: {e}")
            return {
                "success": False,
                "message": f"Error listing epics: {str(e)}",
            }
  • Pydantic model defining the input schema for the list_epics tool parameters, including pagination (limit, offset), filters (priority, assignment_group, timeframe, query).
    class ListEpicsParams(BaseModel):
        """Parameters for listing epics."""
    
        limit: Optional[int] = Field(10, description="Maximum number of records to return")
        offset: Optional[int] = Field(0, description="Offset to start from")
        priority: Optional[str] = Field(None, description="Filter by priority")
        assignment_group: Optional[str] = Field(None, description="Filter by assignment group")
        timeframe: Optional[str] = Field(None, description="Filter by timeframe (upcoming, in-progress, completed)")
        query: Optional[str] = Field(None, description="Additional query string")
  • Registration of the 'list_epics' tool in the central tool definitions dictionary used by the MCP server. Maps the tool name to its handler function alias, input schema, return type hint, description, and serialization method.
    "list_epics": (
        list_epics_tool,
        ListEpicsParams,
        str,  # Expects JSON string
        "List epics from ServiceNow",
        "json",  # Tool returns list/dict
    ),
  • Import and re-export of the list_epics function in the tools package __init__.py, making it available for higher-level imports.
    from servicenow_mcp.tools.epic_tools import (
        create_epic,
        update_epic,
        list_epics,
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It only states the action ('List epics') without mentioning any behavioral traits such as read-only nature, pagination behavior (implied by limit/offset but not described), rate limits, authentication needs, or what the output looks like. 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.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence ('List epics from ServiceNow') that is front-loaded and wastes no words. However, it's overly concise to the point of under-specification, as it lacks necessary details for a tool with multiple parameters and no output schema, slightly reducing its effectiveness.

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 format, pagination behavior, or error handling, and relies entirely on the schema for parameter details. For a list tool with filtering options, more context is needed to guide the agent 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?

The input schema has 100% description coverage, with each parameter clearly documented (e.g., 'limit' as maximum records, 'timeframe' with values like 'upcoming'). The description adds no additional parameter semantics beyond what the schema provides, so it meets the baseline score of 3 for high schema coverage without compensating value.

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 epics from ServiceNow' states the verb ('List') and resource ('epics') with the source ('ServiceNow'), which provides a basic purpose. However, it's vague about scope (e.g., all epics vs. filtered) and doesn't differentiate from sibling tools like 'list_stories' or 'list_projects' beyond the resource type, missing specificity about what makes this tool unique for epics.

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 any prerequisites, context for filtering (e.g., vs. 'create_epic'), or comparisons to other list tools like 'list_stories', leaving the agent to infer usage solely from the tool name without explicit instructions.

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