modelcontextprotocol / modelcontextprotocol/servers

Filesystem MCP: create_directory fails with relative paths but works with absolute paths - Kiro AI IDE

Open
#2,416 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug server-filesystem
Dominant language
TypeScript
Stars
90.5k
Forks
11.7k
Avg merge
2d 2h
Merged PRs (30d)
5

Description

Bug: create_directory fails with relative paths but works with absolute paths

Description

The create_directory function in the filesystem MCP server only works when provided with absolute paths. When using relative paths, it incorrectly throws an "Access denied" error even though the path is within allowed directories.

Steps to Reproduce

  1. Configure filesystem MCP with allowed directories (see config below)

  2. Try to create a directory using a relative path:

    mcp_filesystem_create_directory({ path: "./Dishank" })
    
  3. Observe error: Error: Access denied - path outside allowed directories: c:\Learn\import_tracker\Dishank not in C:\Learn\import_tracker, C:\Users\ADMIN\.kiro, C:\Learn\import_tracker

  4. Try with absolute path:

    mcp_filesystem_create_directory({ path: "C:\\Learn\\import_tracker\\Dishank" })
    
  5. This works successfully: Successfully created directory C:\Learn\import_tracker\Dishank

Expected Behavior

Both relative and absolute paths should work as long as they resolve to a location within the allowed directories.

Current Configuration

{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "C:\\Learn\\import_tracker",
        "C:\\Users\\ADMIN\\.kiro",
        "."
      ],
      "disabled": false,
      "autoApprove": [
        "read_file"
      ]
    }
  }
}

Environment

  • OS: Windows
  • Platform: win32
  • Shell: cmd
  • Kiro IDE: Version: 0.1.25 (user setup)
    VSCode Version: 1.94.0
    Commit: 6124c448360adbeb0adbc771a86db283d2d3f4db
    Date: 2025-07-23T19:45:58.809Z
    Electron: 30.5.1
    ElectronBuildId: undefined
    Chromium: 124.0.6367.243
    Node.js: 20.16.0
    V8: 12.4.254.20-electron.0
    OS: Windows_NT x64 10.0.26100
  • MCP Server Version: @modelcontextprotocol/server-filesystem (latest via npx)
  • Node.js: 18+ (required for Kiro)

Additional Context

The error message shows that the server is correctly resolving the relative path to its absolute form (c:\Learn\import_tracker\Dishank), but then fails to recognize that this path is within the allowed directories list, even though C:\Learn\import_tracker is explicitly listed as an allowed directory.

This appears to be a path normalization issue where the comparison between the resolved path and allowed directories is failing due to case sensitivity or path format differences.

Reproduction via Kiro IDE

This issue was discovered while using Kiro IDE's MCP integration. The filesystem MCP server was configured through Kiro's .kiro/settings/mcp.json configuration file, and the issue manifested when attempting to create directories through Kiro's AI assistant using the mcp_filesystem_create_directory tool.

Impact

This bug affects the usability of the filesystem MCP server when integrated with IDEs like Kiro, as users naturally expect relative paths to work within their project workspace.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the filesystem MCP server's create_directory entry point and reproduce the Windows case with an allowed directory and a relative path such as ./Dishank. Compare the resolved relative path with the configured allowed paths, then verify that both relative and absolute paths inside an allowed directory are accepted without weakening access checks.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
backend, security
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.