[BUG] MCP Server (mcp-obsidian) BrokenPipeError in Claude Code CLI
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Summary
MCP server mcp-obsidian works correctly in Claude Desktop but fails with BrokenPipeError in Claude Code CLI. The server starts but Claude Code immediately closes the connection before the server can initialize, causing the pipe to break.
Environment
- Claude Code Version: 2.0.9
- macOS Version: 15.7 (24G222)
- MCP Server: mcp-obsidian v0.2.2
- uv Version: 0.9.0 (Homebrew 2025-10-07)
- Python Version: 3.13.8
Configuration
Config location: ~/Library/Application Support/Claude/claude_desktop_config.json
Current config (direct binary):
{
"mcpServers": {
"mcp-obsidian": {
"command": "/Users/usr/.local/bin/mcp-obsidian",
"env": {
"OBSIDIAN_API_KEY": "key"
}
}
}
}
Previously tried config (with uvx):
{
"mcpServers": {
"mcp-obsidian": {
"command": "/opt/homebrew/bin/uvx",
"args": ["--quiet", "mcp-obsidian"],
"env": {
"OBSIDIAN_API_KEY": "key",
"PYTHONUNBUFFERED": "1"
}
}
}
}
Both configurations fail with the same error.
Actual Behavior
- Server starts but immediately receives
BrokenPipeError - Connection is closed before server initialization completes
- Main log shows: "Launching MCP Server: mcp-obsidian" followed immediately by connection loss
- Server is never available for tool calls
Log Evidence
From ~/Library/Logs/Claude/mcp-server-mcp-obsidian.log:
BrokenPipeError: [Errno 32] Broken pipe
ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
+-+---------------- 1 ----------------
| Traceback (most recent call last):
| File "/Users/usr/.cache/uv/archive-v0/PY7dyLlFj2ftrkTZIT_Qe/lib/python3.13/site-packages/mcp/server/stdio.py", line 81, in stdout_writer
| await stdout.flush()
| File "/Users/usr/.cache/uv/archive-v0/PY7dyLlFj2ftrkTZIT_Qe/lib/python3.13/site-packages/anyio/_core/_fileio.py", line 140, in flush
| return await to_thread.run_sync(self._fp.flush)
| BrokenPipeError: [Errno 32] Broken pipe
From ~/Library/Logs/Claude/main.log:
2025-10-08 19:46:12 [info] MCP Server connection requested for: mcp-obsidian
2025-10-08 19:46:12 [info] Launching MCP Server: mcp-obsidian
2025-10-08 19:46:12 [info] Checking if UtilityProcess should be used for extension mcp-obsidian
2025-10-08 19:46:12 [warn] UtilityProcess Check: Extension mcp-obsidian not found in installed extensions
Analysis
The issue appears to be in Claude Code's MCP server lifecycle management:
- Claude Code requests MCP server connection
- Claude Code launches the server process
- Claude Code immediately closes stdin/stdout pipes (possibly during startup validation)
- Server tries to flush stdout during initialization
- Server crashes with BrokenPipeError because pipe is already closed
The same server works in Claude Desktop, indicating the issue is specific to how Claude Code CLI manages the server process lifecycle, not the server itself.
Attempted Fixes (All Failed)
- Using
uvxwith--quietflag to reduce output - Setting
PYTHONUNBUFFERED=1to prevent buffering - Installing globally with
uv tool installand using direct binary path - Removing unnecessary environment variables
Workaround
Use Claude Desktop instead of Claude Code CLI for Obsidian MCP functionality.
Additional Context
- This issue persisted across 7 debugging sessions
- Other MCP servers (e.g., zotero) may have similar issues
- The warning "Extension mcp-obsidian not found in installed extensions" suggests Claude Code might be treating MCP servers differently than Claude Desktop
Suggested Investigation
- Review Claude Code's MCP server startup sequence
- Compare with Claude Desktop's implementation
- Check if pipes are being closed prematurely during validation/health checks
- Add startup delay or keep-alive mechanism for MCP servers in Claude Code
What Should Happen?
Expected Behavior
- MCP server should start and remain running
- Server should respond to tool calls from Claude Code CLI
- Works correctly in Claude Desktop with identical configuration
Error Messages/Logs
Steps to Reproduce
Reproduction Steps
- Install mcp-obsidian:
uv tool install mcp-obsidian - Configure in
~/Library/Application Support/Claude/claude_desktop_config.jsonwith API key - Start Claude Code CLI
- Attempt to list MCP resources or use any MCP tool
- Check logs at
~/Library/Logs/Claude/mcp-server-mcp-obsidian.log
Claude Model
Sonnet (default)
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
2.0.9
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗