Skip to main content
Glama
JLKmach

ServiceNow MCP Server

by JLKmach

create_category

Create a new category or subcategory in a ServiceNow knowledge base to organize articles and improve content structure.

Instructions

Create a new category in a knowledge base

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
titleYesTitle of the category
descriptionNoDescription of the category
knowledge_baseYesThe knowledge base to create the category in
parent_categoryNoParent category (if creating a subcategory). Sys_id refering to the parent category or sys_id of the parent table.
parent_tableNoParent table (if creating a subcategory). Sys_id refering to the table where the parent category is defined.
activeNoWhether the category is active

Implementation Reference

  • The handler function that implements the create_category tool by making a POST request to ServiceNow's kb_category table endpoint with the provided parameters.
    def create_category(
        config: ServerConfig,
        auth_manager: AuthManager,
        params: CreateCategoryParams,
    ) -> CategoryResponse:
        """
        Create a new category in a knowledge base.
    
        Args:
            config: Server configuration.
            auth_manager: Authentication manager.
            params: Parameters for creating the category.
    
        Returns:
            Response with the created category details.
        """
        api_url = f"{config.api_url}/table/kb_category"
    
        # Build request data
        data = {
            "label": params.title,
            "kb_knowledge_base": params.knowledge_base,
            # Convert boolean to string "true"/"false" as ServiceNow expects
            "active": str(params.active).lower(),
        }
    
        if params.description:
            data["description"] = params.description
        if params.parent_category:
            data["parent"] = params.parent_category
        if params.parent_table:
            data["parent_table"] = params.parent_table
        
        # Log the request data for debugging
        logger.debug(f"Creating category with data: {data}")
    
        # Make request
        try:
            response = requests.post(
                api_url,
                json=data,
                headers=auth_manager.get_headers(),
                timeout=config.timeout,
            )
            response.raise_for_status()
    
            result = response.json().get("result", {})
            logger.debug(f"Category creation response: {result}")
    
            # Log the specific fields to check the knowledge base assignment
            if "kb_knowledge_base" in result:
                logger.debug(f"Knowledge base in response: {result['kb_knowledge_base']}")
            
            # Log the active status
            if "active" in result:
                logger.debug(f"Active status in response: {result['active']}")
            
            return CategoryResponse(
                success=True,
                message="Category created successfully",
                category_id=result.get("sys_id"),
                category_name=result.get("label"),
            )
    
        except requests.RequestException as e:
            logger.error(f"Failed to create category: {e}")
            return CategoryResponse(
                success=False,
                message=f"Failed to create category: {str(e)}",
            )
  • Pydantic model defining the input schema for the create_category tool, including required fields like title and knowledge_base.
    class CreateCategoryParams(BaseModel):
        """Parameters for creating a category in a knowledge base."""
    
        title: str = Field(..., description="Title of the category")
        description: Optional[str] = Field(None, description="Description of the category")
        knowledge_base: str = Field(..., description="The knowledge base to create the category in")
        parent_category: Optional[str] = Field(None, description="Parent category (if creating a subcategory). Sys_id refering to the parent category or sys_id of the parent table.")
        parent_table: Optional[str] = Field(None, description="Parent table (if creating a subcategory). Sys_id refering to the table where the parent category is defined.")
        active: bool = Field(True, description="Whether the category is active")
  • Tool registration entry in the tool_definitions dictionary, mapping 'create_category' to its aliased handler, schema, description, and serialization hint.
    "create_category": (
        create_kb_category_tool_impl,  # Use passed function
        CreateKBCategoryParams,
        str,  # Expects JSON string
        "Create a new category in a knowledge base",
        "json_dict",  # Tool returns Pydantic model
    ),
  • Import of the create_category handler aliased as create_kb_category_tool, which is passed to get_tool_definitions for registration.
    from servicenow_mcp.tools.knowledge_base import (
        create_category as create_kb_category_tool,
    )
  • Alias for the CreateCategoryParams schema used in tool registration as CreateKBCategoryParams.
        CreateCategoryParams as CreateKBCategoryParams,  # Aliased
    )
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 but provides minimal information. It states this is a creation operation but doesn't mention permission requirements, whether this is a destructive/write operation, what happens on success/failure, or any system constraints. For a creation tool with zero annotation coverage, this leaves significant behavioral gaps.

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 a single, efficient sentence that communicates the core purpose without unnecessary words. It's appropriately front-loaded with the essential action and resource, making it immediately scannable and understandable. No sentence feels wasted or redundant.

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 creation tool with 6 parameters, no annotations, and no output schema, the description is insufficiently complete. It doesn't address what the tool returns, what happens on failure, permission requirements, or how it differs from similar sibling tools. The combination of mutation functionality and lack of structured metadata requires more descriptive context than provided.

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 description adds no parameter-specific information beyond what's already documented in the schema (which has 100% coverage). It doesn't explain relationships between parameters like 'parent_category' and 'parent_table', provide examples of valid values, or clarify edge cases. With complete schema documentation, the baseline score of 3 is appropriate as the description doesn't add meaningful parameter context.

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 clearly states the action ('create') and resource ('new category in a knowledge base'), making the purpose immediately understandable. However, it doesn't differentiate this tool from similar sibling tools like 'create_catalog_category' or 'list_categories', which would require mentioning specific domain context or distinguishing features.

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. With sibling tools like 'create_catalog_category' and 'list_categories' available, there's no indication of when this specific category creation tool is appropriate versus other category-related operations. No prerequisites, exclusions, or contextual boundaries are mentioned.

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