Skip to content

fix(mcp): preflight filesystem sandbox dir + offer mkdir in wizard (#362)#379

Merged
esengine merged 1 commit into
mainfrom
fix/mcp-filesystem-dir-check
May 7, 2026
Merged

fix(mcp): preflight filesystem sandbox dir + offer mkdir in wizard (#362)#379
esengine merged 1 commit into
mainfrom
fix/mcp-filesystem-dir-check

Conversation

@esengine

@esengine esengine commented May 7, 2026

Copy link
Copy Markdown
Owner

Closes #362.

Why

The official @modelcontextprotocol/server-filesystem refuses to start when its sandbox directory doesn't exist and prints a raw Node stack trace from inside npx's child:

Error accessing directory /tmp/reasonix-sandbox: ENOENT: no such file or directory, stat '/tmp/reasonix-sandbox'
    at async Object.stat (node:internal/fs/promises:1680:18)
    at async file:///home/dacec/.npm/_npx/.../server-filesystem/dist/index.js:43:23

The user has no idea what to do, and we're partly responsible: our wizard suggests /tmp/reasonix-sandbox as a placeholder, then saves whatever the user types into ~/.reasonix/config.json without checking it.

What changes

Two-layer fix.

1. Wizard input-time validation (src/cli/ui/Wizard.tsx)

When the filesystem MCP server's directory arg is submitted:

  • exists & dir → accept as before
  • exists but not a dir → red error, stay on input
  • missing → switch to a confirm step: [Y/Enter] create it (mkdir -p) / [N/Esc] enter a different path

2. Spawn-time fallback (src/mcp/preflight.ts + 3 call sites)

preflightStdioSpec(spec) runs right before new StdioTransport(...) in chat.tsx, run.ts, and mcp-inspect.ts. If a stdio spec contains @modelcontextprotocol/server-filesystem, every positional path arg is stated; missing → throws

MCP filesystem sandbox '/tmp/reasonix-sandbox' does not exist — create it with: mkdir -p '/tmp/reasonix-sandbox'

The existing per-call-site catch already surfaces this as a failed MCP lifecycle event, so users see the actionable message in the same place they currently see the raw stack.

The spawn-time path deliberately does not auto-mkdir: at that point the user might be running with a stale config they don't remember writing, and silently creating directories on their behalf is too magic. The wizard is the right place to ask before creating.

Tests

tests/mcp-preflight.test.ts — 6 cases:

  • non-filesystem servers: no-op
  • existing dir: no throw
  • missing dir: actionable error
  • path-is-a-file: distinct error
  • multi-dir spec, one missing: throws on the missing one
  • flag-shaped tokens after the package id: ignored

Test plan

  • npx vitest run tests/mcp-preflight.test.ts — 6/6 pass
  • npx vitest run — full suite 2430 pass / 5 skipped
  • tsc --noEmit clean
  • biome check clean on touched files
  • Manual: bunx reasonix code with a stale config pointing at a missing dir → actionable error instead of raw Node stack
  • Manual: reasonix init → pick filesystem → enter a missing path → Y creates it, N returns to input

)

The official @modelcontextprotocol/server-filesystem refuses to start
when its sandbox directory is missing and prints a raw Node stack
trace, leaving the user without an actionable next step.

- preflightStdioSpec validates every positional path arg before
  spawn and throws a one-line error: "create it with: mkdir -p '<path>'"
- The first-run / reconfigure wizard now stat()s the directory the
  user typed for filesystem MCP and offers Y/Enter to mkdir -p,
  N/Esc to enter a different path.
@esengine esengine merged commit 1a7d74f into main May 7, 2026
3 checks passed
@esengine esengine deleted the fix/mcp-filesystem-dir-check branch May 7, 2026 12:31
@esengine esengine mentioned this pull request May 7, 2026
5 tasks
esengine added a commit that referenced this pull request May 7, 2026
Ink 7 + React 19 chat scroll rewrite (#380), configurable web_search
backend with SearXNG (#338), MCP filesystem sandbox preflight + wizard
mkdir confirm (#362, PR #379), README URL fix (#375), bug template
update (#378).
ChasLui pushed a commit to ChasLui/DeepSeek-Reasonix that referenced this pull request May 23, 2026
…sengine#362) (esengine#379)

The official @modelcontextprotocol/server-filesystem refuses to start
when its sandbox directory is missing and prints a raw Node stack
trace, leaving the user without an actionable next step.

- preflightStdioSpec validates every positional path arg before
  spawn and throws a one-line error: "create it with: mkdir -p '<path>'"
- The first-run / reconfigure wizard now stat()s the directory the
  user typed for filesystem MCP and offers Y/Enter to mkdir -p,
  N/Esc to enter a different path.
ChasLui pushed a commit to ChasLui/DeepSeek-Reasonix that referenced this pull request May 23, 2026
Ink 7 + React 19 chat scroll rewrite (esengine#380), configurable web_search
backend with SearXNG (esengine#338), MCP filesystem sandbox preflight + wizard
mkdir confirm (esengine#362, PR esengine#379), README URL fix (esengine#375), bug template
update (esengine#378).
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.

after setting custom tmp dir. error shows when dir not exist

1 participant