Skip to main content
Glama
penguinszp001

mcp-server-demo

move_files_by_glob

Moves all files matching a glob pattern from source directory to destination directory.

Instructions

Move all files matching a glob pattern from source_dir into destination_dir.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
source_dirYes
patternYes
destination_dirYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler function for the 'move_files_by_glob' tool. Uses @mcp.tool() decorator to register the function. It moves all files matching a glob pattern from source_dir to destination_dir, skipping files that already exist at the destination, and returns a JSON summary of what was moved/skipped.
    @mcp.tool()
    def move_files_by_glob(source_dir: str, pattern: str, destination_dir: str) -> str:
        """Move all files matching a glob pattern from source_dir into destination_dir."""
        source_root = _resolve_file_ops_path(source_dir)
        destination_root = _resolve_file_ops_path(destination_dir)
    
        if not source_root.is_dir():
            raise ValueError(f"Source directory does not exist: {source_root}")
    
        destination_root.mkdir(parents=True, exist_ok=True)
    
        moved: list[str] = []
        skipped: list[str] = []
        for source in sorted(source_root.glob(pattern)):
            if not source.is_file():
                continue
    
            destination = destination_root / source.name
            if destination.exists():
                skipped.append(source.name)
                continue
    
            shutil.move(str(source), str(destination))
            moved.append(source.name)
    
        summary = {
            "source_dir": str(source_root),
            "destination_dir": str(destination_root),
            "pattern": pattern,
            "moved_count": len(moved),
            "skipped_existing_count": len(skipped),
            "moved_files": moved,
            "skipped_existing_files": skipped,
        }
        return json.dumps(summary, indent=2)
  • server.py:133-134 (registration)
    The @mcp.tool() decorator on line 133 registers 'move_files_by_glob' as an MCP tool. No separate registration file exists; FastMCP's decorator pattern handles it inline.
    @mcp.tool()
    def move_files_by_glob(source_dir: str, pattern: str, destination_dir: str) -> str:
Behavior2/5

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

With no annotations provided, the description carries full burden but only states basic operation. It does not disclose important behavior like conflict handling, directory creation, glob syntax, or partial move risks.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single efficient sentence, no unnecessary words. Could include slightly more detail without harming conciseness.

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?

Despite 3 parameters and no annotations, the description omits behavior like overwrite policy, return value (despite output schema existing), and prerequisite checks. Incomplete for a mutation tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema has 0% coverage, and the description merely names the parameters without adding constraints, formats, or examples. 'source_dir', 'pattern', 'destination_dir' are not explained beyond their names.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly states the action (move), the resource (files matching a glob pattern), and the source/destination. It effectively distinguishes from sibling 'move_file' which handles single files.

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 on when to use this tool versus alternatives like 'move_file' or other file operations. No scenarios or exclusions provided.

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/penguinszp001/mcp-server-demo'

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