[BUG] MCP Server (mcp-obsidian) BrokenPipeError in Claude Code CLI

Resolved 💬 3 comments Opened Oct 8, 2025 by MA-Ambrose Closed Oct 12, 2025

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:

  1. Claude Code requests MCP server connection
  2. Claude Code launches the server process
  3. Claude Code immediately closes stdin/stdout pipes (possibly during startup validation)
  4. Server tries to flush stdout during initialization
  5. 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)

  1. Using uvx with --quiet flag to reduce output
  2. Setting PYTHONUNBUFFERED=1 to prevent buffering
  3. Installing globally with uv tool install and using direct binary path
  4. 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

  1. Review Claude Code's MCP server startup sequence
  2. Compare with Claude Desktop's implementation
  3. Check if pipes are being closed prematurely during validation/health checks
  4. 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

  1. Install mcp-obsidian: uv tool install mcp-obsidian
  2. Configure in ~/Library/Application Support/Claude/claude_desktop_config.json with API key
  3. Start Claude Code CLI
  4. Attempt to list MCP resources or use any MCP tool
  5. 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_

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗