Skip to main content
Glama
vparlapalli490

ServiceNow MCP Server

create_category

Add new categories or subcategories to organize content in ServiceNow knowledge bases, specifying title, description, and parent relationships.

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)
activeNoWhether the category is active

Implementation Reference

  • Implements the core logic for the 'create_category' tool by sending a POST request to the ServiceNow kb_category table API, handling parameters like title, knowledge_base, parent_category, and returning a CategoryResponse.
    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
        
        # 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 BaseModel defining the input schema (parameters) 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)")
        active: bool = Field(True, description="Whether the category is active")
  • Registers the 'create_category' tool in the central tool_definitions dictionary used by the MCP server, mapping the aliased handler function, aliased schema (CreateKBCategoryParams), 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
    ),
  • In the ServiceNowMCP class initialization, calls get_tool_definitions with the aliased create_category handler (create_kb_category_tool) to load all tool definitions including create_category.
    self.tool_definitions = get_tool_definitions(
        create_kb_category_tool, list_kb_categories_tool
    )
  • Imports the create_category function 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,
    )
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. While 'Create' implies a write/mutation operation, the description doesn't address important behavioral aspects like required permissions, whether this operation is idempotent, what happens on duplicate titles, what the response contains, or any rate limits. For a mutation tool with zero annotation coverage, this is inadequate.

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 states exactly what the tool does without any unnecessary words. It's appropriately sized and front-loaded with the core functionality.

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 mutation tool with no annotations and no output schema, the description is insufficient. It doesn't explain what the tool returns, what happens on success/failure, or important behavioral constraints. Given the complexity of creating a resource in a knowledge base system, more context about the operation's effects and requirements would be necessary for an agent to use it 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?

Schema description coverage is 100%, so the schema already documents all 5 parameters thoroughly. The description doesn't add any parameter-specific information beyond what's in the schema. The baseline score of 3 reflects adequate coverage through the schema alone, though the description adds no additional semantic context about parameters.

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 a new category') and resource ('in a knowledge base'), which is specific and unambiguous. However, it doesn't differentiate from sibling tools like 'create_catalog_category' or 'list_categories', which would require more specificity about what distinguishes this particular category creation operation.

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. There are multiple sibling tools that involve categories (create_catalog_category, list_categories, update_catalog_category), but the description doesn't explain when this specific knowledge base category creation tool should be chosen over those alternatives or what prerequisites might exist.

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/vparlapalli490/MCP'

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