Skip to main content
Glama
javerthl

ServiceNow MCP Server

by javerthl

update_group

Modify an existing ServiceNow group by updating its name, description, manager, parent group, type, email, or active status using the group ID.

Instructions

Update an existing group in ServiceNow

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
activeNoWhether the group is active
descriptionNoDescription of the group
emailNoEmail address for the group
group_idYesGroup ID or sys_id to update
managerNoManager of the group (sys_id or username)
nameNoName of the group
parentNoParent group (sys_id or name)
typeNoType of the group

Implementation Reference

  • The main handler function for the 'update_group' tool. It performs a PATCH request to the ServiceNow sys_user_group table to update group attributes based on provided parameters.
    def update_group(
        config: ServerConfig,
        auth_manager: AuthManager,
        params: UpdateGroupParams,
    ) -> GroupResponse:
        """
        Update an existing group in ServiceNow.
    
        Args:
            config: Server configuration.
            auth_manager: Authentication manager.
            params: Parameters for updating the group.
    
        Returns:
            Response with the updated group details.
        """
        api_url = f"{config.api_url}/table/sys_user_group/{params.group_id}"
    
        # Build request data
        data = {}
        if params.name:
            data["name"] = params.name
        if params.description:
            data["description"] = params.description
        if params.manager:
            data["manager"] = params.manager
        if params.parent:
            data["parent"] = params.parent
        if params.type:
            data["type"] = params.type
        if params.email:
            data["email"] = params.email
        if params.active is not None:
            data["active"] = str(params.active).lower()
    
        # Make request
        try:
            response = requests.patch(
                api_url,
                json=data,
                headers=auth_manager.get_headers(),
                timeout=config.timeout,
            )
            response.raise_for_status()
    
            result = response.json().get("result", {})
    
            return GroupResponse(
                success=True,
                message="Group updated successfully",
                group_id=result.get("sys_id"),
                group_name=result.get("name"),
            )
    
        except requests.RequestException as e:
            logger.error(f"Failed to update group: {e}")
            return GroupResponse(
                success=False,
                message=f"Failed to update group: {str(e)}",
            )
  • Pydantic BaseModel defining the input schema/parameters for the update_group tool, including group_id (required) and optional fields like name, description, etc.
    class UpdateGroupParams(BaseModel):
        """Parameters for updating a group."""
    
        group_id: str = Field(..., description="Group ID or sys_id to update")
        name: Optional[str] = Field(None, description="Name of the group")
        description: Optional[str] = Field(None, description="Description of the group")
        manager: Optional[str] = Field(None, description="Manager of the group (sys_id or username)")
        parent: Optional[str] = Field(None, description="Parent group (sys_id or name)")
        type: Optional[str] = Field(None, description="Type of the group")
        email: Optional[str] = Field(None, description="Email address for the group")
        active: Optional[bool] = Field(None, description="Whether the group is active")
  • Tool registration entry in the central tool_definitions dictionary in get_tool_definitions(). Maps 'update_group' to its handler function (aliased), schema, return type, description, and serialization method.
    "update_group": (
        update_group_tool,
        UpdateGroupParams,
        Dict[str, Any],  # Expects dict
        "Update an existing group in ServiceNow",
        "raw_dict",
    ),
  • Export/import of the update_group function in the tools package __init__.py, making it available for import.
    update_group,
  • Pydantic model for the response returned by the update_group handler and other group operations.
    class GroupResponse(BaseModel):
        """Response from group operations."""
    
        success: bool = Field(..., description="Whether the operation was successful")
        message: str = Field(..., description="Message describing the result")
        group_id: Optional[str] = Field(None, description="ID of the affected group")
        group_name: Optional[str] = Field(None, description="Name of the affected group")

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