Skip to main content
Glama
cwente25

Knowledge Base MCP Server

by cwente25

create_category

Add a new category or subcategory to organize content in your knowledge base. Specify the category path with forward slashes for nested structures and include an optional description.

Instructions

Create a new category or subcategory in the knowledge base

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
category_pathYesCategory path (e.g., 'work', 'work/clients', 'personal/spiritual/devotionals'). Use forward slashes for nested categories.
descriptionNoOptional description for the category

Implementation Reference

  • The handler function that executes the create_category tool. It extracts arguments, calls the storage layer to create the category, handles errors, and returns formatted TextContent.
    async def handle_create_category(arguments: dict) -> list[TextContent]:
        """Handle create_category tool call."""
        try:
            category_path = arguments["category_path"]
            description = arguments.get("description")
    
            result = storage.create_category(
                category_path=category_path,
                description=description,
                create_parents=True
            )
    
            return [TextContent(type="text", text=result)]
        except (CategoryExistsError, InvalidPathError, StorageError) as e:
            return [TextContent(type="text", text=str(e))]
        except Exception as e:
            return [TextContent(type="text", text=f"❌ Error: {str(e)}")]
  • The tool registration in list_tools(), defining the name, description, and input schema for create_category.
    Tool(
        name="create_category",
        description="Create a new category or subcategory in the knowledge base",
        inputSchema={
            "type": "object",
            "properties": {
                "category_path": {
                    "type": "string",
                    "description": "Category path (e.g., 'work', 'work/clients', 'personal/spiritual/devotionals'). Use forward slashes for nested categories.",
                },
                "description": {
                    "type": "string",
                    "description": "Optional description for the category",
                },
            },
            "required": ["category_path"],
        },
    ),
  • The inputSchema defining the parameters for the create_category tool: required category_path and optional description.
    inputSchema={
        "type": "object",
        "properties": {
            "category_path": {
                "type": "string",
                "description": "Category path (e.g., 'work', 'work/clients', 'personal/spiritual/devotionals'). Use forward slashes for nested categories.",
            },
            "description": {
                "type": "string",
                "description": "Optional description for the category",
            },
        },
        "required": ["category_path"],
    },
  • The core storage method that performs the actual category creation: validates path, creates directory, saves optional metadata, and returns success message.
    def create_category(
        self,
        category_path: str,
        description: Optional[str] = None,
        create_parents: bool = True
    ) -> str:
        """
        Create a new category.
    
        Args:
            category_path: Category path (e.g., "work/clients/acme")
            description: Optional description for the category
            create_parents: If True, create parent directories as needed
    
        Returns:
            Success message
    
        Raises:
            CategoryExistsError: If category already exists
            InvalidPathError: If path is invalid
            StorageError: If creation fails
        """
        # Normalize and validate path
        normalized = normalize_path(category_path)
        if not normalized:
            raise InvalidPathError("Category path cannot be empty")
    
        is_valid, error_msg = validate_path(normalized)
        if not is_valid:
            raise InvalidPathError(error_msg)
    
        # Check if already exists
        if self._category_exists(normalized):
            raise CategoryExistsError(
                f"❌ Error: Category '{normalized}' already exists\n"
                f"💡 Tip: Use rename_category to rename it"
            )
    
        # Create the directory
        cat_path = self._get_category_path(normalized)
        try:
            cat_path.mkdir(parents=create_parents, exist_ok=False)
        except FileExistsError:
            raise CategoryExistsError(f"Category '{normalized}' already exists")
        except FileNotFoundError:
            parent = get_parent_path(normalized)
            raise StorageError(
                f"❌ Error: Parent category '{parent}' does not exist\n"
                f"💡 Tip: Create parent first or use create_parents=True"
            )
        except Exception as e:
            raise StorageError(f"Failed to create category '{normalized}': {e}")
    
        # Save metadata if description provided
        if description:
            metadata = CategoryMetadata(description=description)
            self._save_category_metadata(normalized, metadata)
    
        return f"✓ Category '{normalized}' created successfully"
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. It states the tool creates categories but doesn't mention potential side effects (e.g., if creating duplicates is allowed, what permissions are required, or how errors are handled). This is insufficient for a mutation tool, as it leaves critical behavioral traits unspecified.

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, clear sentence that directly states the tool's purpose without any unnecessary words. It is front-loaded and efficiently conveys the core functionality, making it easy for an agent to parse and understand quickly.

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?

Given the complexity of a mutation tool with no annotations and no output schema, the description is incomplete. It doesn't cover behavioral aspects like error conditions, return values, or interaction with sibling tools. For a tool that modifies data, more context is needed to ensure safe and correct usage by an agent.

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 the input schema already provides. Since schema description coverage is 100%, the baseline score is 3. The description doesn't elaborate on parameter usage, such as examples for 'category_path' beyond what's in the schema, so it doesn't add extra value.

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 or subcategory in the knowledge base'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'move_category' or 'rename_category', which also involve category modifications, so it doesn't reach the highest score.

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. For example, it doesn't mention whether to use 'create_category' for new categories versus 'move_category' for reorganizing existing ones, or if there are prerequisites like parent categories needing to exist first. This lack of context leaves the agent without usage direction.

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/cwente25/KnowledgeBaseMCP'

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