Skip to main content
Glama
JLKmach

ServiceNow MCP Server

by JLKmach

list_users

Retrieve and filter ServiceNow user accounts by status, department, or search terms to manage access and permissions.

Instructions

List users in ServiceNow

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of users to return
offsetNoOffset for pagination
activeNoFilter by active status
departmentNoFilter by department
queryNoCase-insensitive search term that matches against name, username, or email fields. Uses ServiceNow's LIKE operator for partial matching.

Implementation Reference

  • Core implementation of the list_users tool handler. Queries the ServiceNow sys_user table API using GET request with pagination (limit/offset), filters (active, department, query), and returns a dictionary with success status, message, users list, and count.
    def list_users(
        config: ServerConfig,
        auth_manager: AuthManager,
        params: ListUsersParams,
    ) -> dict:
        """
        List users from ServiceNow.
    
        Args:
            config: Server configuration.
            auth_manager: Authentication manager.
            params: Parameters for listing users.
    
        Returns:
            Dictionary containing list of users.
        """
        api_url = f"{config.api_url}/table/sys_user"
        query_params = {
            "sysparm_limit": str(params.limit),
            "sysparm_offset": str(params.offset),
            "sysparm_display_value": "true",
        }
    
        # Build query
        query_parts = []
        if params.active is not None:
            query_parts.append(f"active={str(params.active).lower()}")
        if params.department:
            query_parts.append(f"department={params.department}")
        if params.query:
            query_parts.append(
                f"^nameLIKE{params.query}^ORuser_nameLIKE{params.query}^ORemailLIKE{params.query}"
            )
    
        if query_parts:
            query_params["sysparm_query"] = "^".join(query_parts)
    
        # Make request
        try:
            response = requests.get(
                api_url,
                params=query_params,
                headers=auth_manager.get_headers(),
                timeout=config.timeout,
            )
            response.raise_for_status()
    
            result = response.json().get("result", [])
    
            return {
                "success": True,
                "message": f"Found {len(result)} users",
                "users": result,
                "count": len(result),
            }
    
        except requests.RequestException as e:
            logger.error(f"Failed to list users: {e}")
            return {"success": False, "message": f"Failed to list users: {str(e)}"}
  • Pydantic schema/model defining input parameters for the list_users tool: limit, offset for pagination; optional filters for active status, department, and free-text query.
    class ListUsersParams(BaseModel):
        """Parameters for listing users."""
    
        limit: int = Field(10, description="Maximum number of users to return")
        offset: int = Field(0, description="Offset for pagination")
        active: Optional[bool] = Field(None, description="Filter by active status")
        department: Optional[str] = Field(None, description="Filter by department")
        query: Optional[str] = Field(
            None,
            description="Case-insensitive search term that matches against name, username, or email fields. Uses ServiceNow's LIKE operator for partial matching.",
        )
  • Registration of the list_users tool in the central tool_definitions dictionary used by the MCP server. Maps tool name to (handler function alias, params schema, return type, description, serialization method).
    "list_users": (
        list_users_tool,
        ListUsersParams,
        Dict[str, Any],  # Expects dict
        "List users in ServiceNow",
        "raw_dict",
    ),
  • Re-export/import of list_users function from user_tools.py into the tools package __init__ for convenient access.
    from servicenow_mcp.tools.user_tools import (
        create_user,
        update_user,
        get_user,
        list_users,
        create_group,
        update_group,
        add_group_members,
        remove_group_members,
        list_groups,
    )
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure but offers minimal information. It doesn't mention that this is a read-only operation (implied by 'List'), pagination behavior (though schema covers offset/limit), rate limits, authentication requirements, or what fields are returned. The description adds almost no behavioral context beyond the basic action.

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 at just 4 words ('List users in ServiceNow'), with zero wasted words. It's front-loaded with the core action and resource. This is an example of efficient communication where every word earns its place.

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 tool with 5 parameters and no output schema, the description is insufficiently complete. It doesn't explain what information is returned about users, how results are structured, or any behavioral aspects. While the schema covers parameters well, the description fails to provide the contextual understanding needed for effective tool use, especially given the lack of annotations.

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 the schema already fully documents all 5 parameters. The description adds no additional parameter semantics beyond what's in the schema. According to scoring rules, when schema coverage is high (>80%), the baseline is 3 even with no param info in the description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'List users in ServiceNow' clearly states the verb ('List') and resource ('users in ServiceNow'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'get_user' (which retrieves a single user) or 'create_user' (which creates a user), missing an opportunity for sibling differentiation.

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 that this is for retrieving multiple users (vs. 'get_user' for a single user) or when filtering might be needed. There's no context about prerequisites, authentication, or typical use cases.

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