Skip to content

fix: resolve session dir to an absolute writable path#12

Merged
jamiew merged 1 commit into
jamiew:mainfrom
caseypugh:fix/session-dir-readonly-fs
Jun 15, 2026
Merged

fix: resolve session dir to an absolute writable path#12
jamiew merged 1 commit into
jamiew:mainfrom
caseypugh:fix/session-dir-readonly-fs

Conversation

@caseypugh

Copy link
Copy Markdown
Collaborator

Problem

The server crashes on startup under MCP clients that launch it with a read-only working directory (e.g. Claude Desktop, which launches from /):

OSError: [Errno 30] Read-only file system: '.mm'
  File ".../server.py", line 926, in <module>
    session_dir.mkdir(mode=0o700, exist_ok=True)

The session directory was Path(".mm") — a relative path — so it was created in whatever cwd the client used. With uv run from the repo cwd is writable and it works, but uvx monarch-mcp-jamiew launched by Claude Desktop runs from a read-only cwd and the process exits before it can connect.

Fix

Resolve the session directory to an absolute path:

  • Honor a new MONARCH_SESSION_DIR env var if set
  • Otherwise default to ~/.monarch-mcp (always writable, independent of launch cwd)
  • mkdir(..., parents=True, exist_ok=True)

This makes the published uvx monarch-mcp-jamiew config work out of the box in Claude Desktop and any client with a non-writable cwd. Docs that referenced the old .mm/ location are updated.

Testing

uv run python scripts/ci.py — ruff, ruff format, mypy, and pytest all pass (197 passed, 5 skipped).

🤖 Generated with Claude Code

The session directory was created at a relative `.mm` path, so it landed
in whatever working directory the MCP client launched the server from.
Clients like Claude Desktop launch with a read-only cwd (e.g. `/`), which
crashes startup before the server can connect:

    OSError: [Errno 30] Read-only file system: '.mm'

Resolve the session dir to an absolute path instead: honor a new
MONARCH_SESSION_DIR env var, otherwise default to ~/.monarch-mcp (always
writable regardless of launch cwd). Use parents=True on mkdir and update
the docs that referenced the old `.mm/` location.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jamiew

jamiew commented Jun 15, 2026

Copy link
Copy Markdown
Owner

THXU

@jamiew jamiew merged commit eb88ff4 into jamiew:main Jun 15, 2026
5 checks passed
@caseypugh caseypugh deleted the fix/session-dir-readonly-fs branch June 15, 2026 21:17
jamiew added a commit that referenced this pull request Jun 30, 2026
- transaction splitting tools (#13) and session-dir fix (#12), both from @caseypugh
- dependency refresh and fork-pin bump to 1.4.0
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