Skip to content

fix: MCP server CWD and config loading (v0.5.5)#59

Merged
padak merged 3 commits into
mainfrom
feature/mcp-installation-ux
Nov 7, 2025
Merged

fix: MCP server CWD and config loading (v0.5.5)#59
padak merged 3 commits into
mainfrom
feature/mcp-installation-ux

Conversation

@padak

@padak padak commented Nov 7, 2025

Copy link
Copy Markdown
Member

Summary

Fixes critical P1 issue identified by Codex: MCP server must change working directory to OSIRIS_HOME to properly load project configuration.

Problem (Codex P1 Review)

The new client config now launches the server directly via python -m osiris.cli.mcp_entrypoint --base-path <path> without changing into <path>. Most runtime configuration loaders inside the server still look for osiris.yaml relative to Path.cwd(). When Claude or any MCP client executes this command from its own working directory (e.g. the app's config directory), the server will never read the project's osiris.yaml and will run with default paths and no connection definitions, breaking real projects.

Root cause:

  • MCP clients launch server from their own CWD (e.g., ~/Library/Application Support/Claude)
  • Config loaders search for osiris.yaml relative to Path.cwd()
  • Server ran with defaults, missing project config and connections

Solution

Added os.chdir(osiris_home) in setup_environment() after resolving OSIRIS_HOME:

# Create OSIRIS_HOME if it doesn't exist
osiris_home.mkdir(parents=True, exist_ok=True)

# Change working directory to OSIRIS_HOME
# This ensures all relative path lookups (osiris.yaml, osiris_connections.yaml, etc.)
# work correctly when MCP client launches server from a different CWD
os.chdir(osiris_home)

Verification

Tested server startup from different CWD:

# Start from /tmp, but load config from /private/tmp/test-mcp-project
cd /tmp
python -m osiris.cli.mcp_entrypoint --base-path /private/tmp/test-mcp-project --selftest

Results:

INFO: MCP filesystem config loaded from osiris.yaml
INFO:   base_path: /private/tmp/test-mcp-project
INFO:   mcp_logs_dir: /private/tmp/test-mcp-project/.osiris/mcp/logs
✅ All tests PASSED

Config successfully loaded despite running from different directory! ✅

All Changes in This PR

  1. Portable MCP config - Removed bash wrapper, added --base-path parameter
  2. Config-first detection - Loads from osiris.yaml for pip installs
  3. Import ordering - Fixed isort warnings
  4. CWD fix - Server changes to OSIRIS_HOME before loading config (this commit)

Testing

  • ✅ Server started from /tmp with --base-path /project
  • ✅ Config loaded from correct project directory
  • ✅ Selftest passes with proper config values
  • ✅ Multiple MCP servers can coexist

Version

v0.5.5

🤖 Generated with Claude Code

padak and others added 3 commits November 7, 2025 13:38
Addresses P1 review from Codex: MCP server must change working
directory to OSIRIS_HOME before loading configuration.

Problem:
- MCP clients (Claude Desktop) launch server from their own CWD
- Config loaders search for osiris.yaml relative to Path.cwd()
- Server ran with defaults, missing project config and connections

Solution:
- Added os.chdir(osiris_home) in setup_environment()
- Ensures all relative path lookups work correctly
- Config files (osiris.yaml, osiris_connections.yaml) now found

Verified:
- Server started from /tmp with --base-path /project
- Config successfully loaded from project directory
- Selftest passes with correct config values

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Configuration details now shown only with --verbose or -v flag.

Default output:
- Clean JSON snippet
- Helpful tip about multiple servers
- No debugging information

With --verbose:
- Shows installation type, config source, paths
- Useful for troubleshooting configuration issues

Example:
  osiris mcp clients          # Clean output
  osiris mcp clients -v       # With details
  osiris mcp clients --verbose # With details

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@padak padak merged commit 69f08b2 into main Nov 7, 2025
3 checks passed
@padak padak deleted the feature/mcp-installation-ux branch November 7, 2025 21:58
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.

1 participant