Skip to main content
Glama
cwente25

Knowledge Base MCP Server

by cwente25

move_category

Relocate a category to a new parent location in your knowledge base by specifying source and destination paths.

Instructions

Move a category to a different parent location

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
source_pathYesCurrent category path (e.g., 'personal/work-notes')
destination_pathYesNew parent path (e.g., 'work/archived')

Implementation Reference

  • MCP tool handler function that extracts arguments, calls storage.move_category, and formats the response.
    async def handle_move_category(arguments: dict) -> list[TextContent]:
        """Handle move_category tool call."""
        try:
            source_path = arguments["source_path"]
            destination_path = arguments["destination_path"]
    
            result = storage.move_category(
                source_path=source_path,
                destination_path=destination_path,
                create_destination=True
            )
    
            return [TextContent(type="text", text=result)]
        except (CategoryNotFoundError, CategoryExistsError, StorageError) as e:
            return [TextContent(type="text", text=str(e))]
        except Exception as e:
            return [TextContent(type="text", text=f"❌ Error: {str(e)}")]
  • Core storage method that performs the category move operation using shutil.move after validation.
    def move_category(
        self,
        source_path: str,
        destination_path: str,
        create_destination: bool = True
    ) -> str:
        """
        Move a category to a new location.
    
        Args:
            source_path: Current category path
            destination_path: New parent path (or full new path)
            create_destination: If True, create destination if it doesn't exist
    
        Returns:
            Success message with new path
    
        Raises:
            CategoryNotFoundError: If source doesn't exist
            StorageError: If move would create circular reference or fails
        """
        source_normalized = normalize_path(source_path)
        dest_normalized = normalize_path(destination_path)
    
        if not source_normalized:
            raise InvalidPathError("Source path cannot be empty")
    
        if not self._category_exists(source_normalized):
            raise CategoryNotFoundError(
                f"❌ Error: Category '{source_normalized}' not found"
            )
    
        # Check for circular reference
        if would_create_cycle(source_normalized, dest_normalized):
            raise StorageError(
                f"❌ Error: Cannot move '{source_normalized}' to '{dest_normalized}' "
                "(would create circular reference)"
            )
    
        # Determine final destination
        source_name = get_category_name(source_normalized)
        final_dest = join_path(dest_normalized, source_name)
    
        # Check if destination parent exists
        if dest_normalized and not self._category_exists(dest_normalized):
            if create_destination:
                self.create_category(dest_normalized, create_parents=True)
            else:
                raise CategoryNotFoundError(
                    f"❌ Error: Destination '{dest_normalized}' does not exist\n"
                    f"💡 Tip: Use create_destination=True to create it"
                )
    
        # Check if final destination already exists
        if self._category_exists(final_dest):
            raise CategoryExistsError(
                f"❌ Error: Category '{final_dest}' already exists"
            )
    
        # Perform move
        source_cat_path = self._get_category_path(source_normalized)
        final_dest_path = self._get_category_path(final_dest)
    
        try:
            shutil.move(str(source_cat_path), str(final_dest_path))
        except Exception as e:
            raise StorageError(f"Failed to move category: {e}")
    
        return f"✓ Category moved: '{source_normalized}' → '{final_dest}'"
  • Tool registration including name, description, and input schema.
    Tool(
        name="move_category",
        description="Move a category to a different parent location",
        inputSchema={
            "type": "object",
            "properties": {
                "source_path": {
                    "type": "string",
                    "description": "Current category path (e.g., 'personal/work-notes')",
                },
                "destination_path": {
                    "type": "string",
                    "description": "New parent path (e.g., 'work/archived')",
                },
            },
            "required": ["source_path", "destination_path"],
        },
    ),
  • Input schema defining parameters for the move_category tool.
    inputSchema={
        "type": "object",
        "properties": {
            "source_path": {
                "type": "string",
                "description": "Current category path (e.g., 'personal/work-notes')",
            },
            "destination_path": {
                "type": "string",
                "description": "New parent path (e.g., 'work/archived')",
            },
        },
        "required": ["source_path", "destination_path"],
    },
Behavior2/5

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

With no annotations, the description carries full burden but only states the basic operation. It doesn't disclose behavioral traits such as whether the move is atomic, what happens to child categories/notes, permission requirements, error conditions (e.g., invalid paths), or if it's destructive (though 'move' implies mutation). This leaves significant gaps for a mutation tool.

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 directly states the tool's purpose with zero wasted words. It is appropriately sized and front-loaded, making it easy to parse 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 this is a mutation tool with no annotations and no output schema, the description is incomplete. It lacks details on behavior (e.g., effects on hierarchy), error handling, or return values, which are critical for safe and effective use in a context with sibling tools like list_categories and delete_category.

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%, with clear parameter descriptions in the schema (e.g., 'Current category path'). The tool description adds no additional parameter semantics beyond implying relocation context, so it meets the baseline of 3 where the schema does the heavy lifting.

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 ('Move') and resource ('a category') with the specific operation 'to a different parent location'. It distinguishes from siblings like rename_category (which changes name but not location) and delete_category (which removes rather than relocates), though it doesn't explicitly name these alternatives.

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?

No guidance is provided on when to use this tool versus alternatives like rename_category or create_category. The description implies usage for relocation but doesn't mention prerequisites (e.g., existing categories), exclusions (e.g., moving to non-existent paths), or sibling tool relationships.

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