Skip to main content
Glama
javerthl

ServiceNow MCP Server

by javerthl

list_users

Retrieve user records from ServiceNow with filtering options for active status, department, and search queries to manage user information effectively.

Instructions

List users in ServiceNow

Input Schema

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

Implementation Reference

  • Implementation of the list_users tool handler, which queries the ServiceNow sys_user table API with pagination, filtering by active status, department, and search query.
    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 for input parameters to the list_users tool, including pagination and filtering options.
    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, mapping name to function, params schema, description, etc.
    "list_users": ( list_users_tool, ListUsersParams, Dict[str, Any], # Expects dict "List users in ServiceNow", "raw_dict", ),
  • Re-export of list_users function in tools package __init__ for easy import.
    list_users,
  • Inclusion of list_users in the __all__ list for the tools package.
    "list_users",

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/javerthl/servicenow-mcp'

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