Skip to main content
Glama
DynamicEndpoints

PowerShell Exec MCP Server

ensure_directory

Create directories automatically to prevent errors in PowerShell automation workflows. Specify a path to verify existence or create missing directories and return the absolute path.

Instructions

Ensure directory exists and return absolute path.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function for the 'ensure_directory' tool. It normalizes the given path, ensures the directory exists by creating it if necessary using os.makedirs, and returns the absolute path.
    @mcp.tool()
    def ensure_directory(path: str) -> str:
        """Ensure directory exists and return absolute path."""
        abs_path = normalize_path(path)
        if os.path.splitext(abs_path)[1]:  # If path has an extension
            dir_path = os.path.dirname(abs_path)
        else:
            dir_path = abs_path
        os.makedirs(dir_path, exist_ok=True)
        return abs_path
  • Helper utility function used by ensure_directory to convert relative paths to absolute paths based on the current working directory.
    def normalize_path(path: str) -> str:
        """Convert relative paths to absolute using current working directory."""
        if not path:
            raise ValueError("Path cannot be empty")
        if path.startswith(('./','.\\')):
            path = path[2:]
        if not os.path.isabs(path):
            path = os.path.join(os.getcwd(), path)
        return os.path.abspath(path)
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 ensures directory existence and returns a path, but lacks details on permissions needed, whether it creates directories if missing, error conditions, or side effects. This is a significant gap for a tool that likely involves file system mutations.

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 extremely concise and front-loaded in a single sentence, with no wasted words. It efficiently conveys the core functionality without unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (involving file system operations) and the presence of an output schema, the description is minimally adequate. It covers the basic purpose but lacks behavioral details that annotations would normally provide, leaving gaps in understanding how the tool behaves in practice.

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

Parameters4/5

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

The description adds meaning beyond the input schema, which has 0% coverage. It clarifies that the 'path' parameter is used to specify the directory to ensure, providing context not in the schema. With only one parameter, this is sufficient to compensate for the low schema coverage.

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 tool's purpose with a specific verb ('ensure') and resource ('directory'), explaining it checks existence and returns an absolute path. However, it doesn't differentiate from sibling tools, which are unrelated to directory management, so the distinction isn't necessary here.

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. The description implies it's for directory existence checks, but it doesn't mention prerequisites, error handling, or comparisons to other file system operations in the sibling set.

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/DynamicEndpoints/PowerShell-Exec-MCP-Server'

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