Skip to content

feat(mcp-servers): Allow configurable directories for filesystem server - #14

Merged
morgnza merged 1 commit into
mainfrom
feat/configurable-filesystem-allowed-dirs
Jul 16, 2026
Merged

feat(mcp-servers): Allow configurable directories for filesystem server#14
morgnza merged 1 commit into
mainfrom
feat/configurable-filesystem-allowed-dirs

Conversation

@yikunliu-aws

Copy link
Copy Markdown
Contributor

Summary

Makes the forwarded filesystem MCP server's allowed directories configurable instead of hardcoded.

Changes

mcp_servers/filesystem_server.py:

  • Reads allowed directories from sys.argv[1:] at startup
  • Falls back to C:\Users\Public\Documents if no args provided (backward-compatible)
  • list_directory() defaults to the first allowed dir instead of a hardcoded path
  • Multiple directories supported — each passed as a separate CLI arg

scripts/setup_mcp_redirection.sh:

  • New flag: --allowed-dirs "C:\Users\Public\Documents,D:\Data" (comma-separated)
  • Builds the manifest args array dynamically from the configured dirs
  • Default unchanged: C:\Users\Public\Documents

How it works

The MCP server manifest on the image controls what args are passed to the server at launch:

{"mcpServers": {"filesystem": {
  "command": "C:\\Program Files\\Python312\\python.exe",
  "args": ["C:\\McpServers\\filesystem_server.py", "C:\\Users\\Public\\Documents", "D:\\Data"]
}}}

Users who build their own images can also edit C:\ProgramData\NICE\dcv\mcp_server_redirection_config.json directly — no setup script required.

Testing

  • python -m py_compile passes
  • bash -n on setup script passes
  • ./scripts/ci_local.sh passes
  • Not tested against a live fleet (image rebuild required for the manifest change to take effect)

Comment thread scripts/setup_mcp_redirection.sh Outdated

# Build filesystem server args: script path + allowed directories
IFS=',' read -ra DIRS_ARRAY <<< "$ALLOWED_DIRS"
FS_ARGS="[\"C:\\\\\\\\McpServers\\\\\\\\filesystem_server.py\""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update to forward slashes for a cleaner view - "C:/McpServers/filesystem_server.py"

@yikunliu-aws

Copy link
Copy Markdown
Contributor Author

Addressed in 1d13b34 — switched all manifest paths to forward slashes (Python handles them natively on Windows). Also converts any backslashes in user-supplied --allowed-dirs to forward slashes for consistency. Much more readable now.

The filesystem MCP server now accepts allowed directories as CLI
arguments instead of a hardcoded path. Multiple directories are
supported — pass each as a separate arg:

    python filesystem_server.py C:/Users/Public/Documents D:/Data

If no arguments are provided, defaults to C:\Users\Public\Documents
(backward-compatible).

setup_mcp_redirection.sh gains a --allowed-dirs flag (comma-separated)
that plumbs the configured directories into the manifest args array.
Uses forward slashes in the manifest JSON for readability (Python
handles them natively on Windows). The list_directory tool defaults to
the first allowed dir rather than a hardcoded path.
@yikunliu-aws
yikunliu-aws force-pushed the feat/configurable-filesystem-allowed-dirs branch from 1d13b34 to 32a34c7 Compare July 16, 2026 17:42
@morgnza
morgnza merged commit 7552f00 into main Jul 16, 2026
4 checks passed
@yikunliu-aws
yikunliu-aws deleted the feat/configurable-filesystem-allowed-dirs branch July 17, 2026 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants