Skip to content

ConnectionMonitor closes server after ~70s of inactivity, breaking Claude Desktop integration #37

@glib-sudo

Description

@glib-sudo

Bug Description

The ConnectionMonitor class aggressively closes the MCP server after approximately 70 seconds of inactivity (30s grace period + 60s inactivity timeout). This causes the server to become unresponsive when used with Claude Desktop.

Steps to Reproduce

  1. Install obsidian-mcp@1.0.6 globally via npm
  2. Configure Claude Desktop to use the server
  3. Open Claude Desktop — tools list loads successfully
  4. Wait ~70 seconds without making a tool call
  5. Attempt any tool call (e.g., list-available-vaults)
  6. Request hangs, no response. Claude Desktop shows timeout after ~4 minutes.

Root Cause

In build/main.js (line ~12066), ConnectionMonitor is instantiated with default parameters:

this.connectionMonitor = new ConnectionMonitor;

The default grace period is 30 seconds and inactivity timeout is 60 seconds. After tools/list is processed on startup, the monitor detects "inactivity" and calls this.server.close(), which closes the stdin transport. The Node.js process stays alive (zombie) but no longer listens for incoming MCP requests.

Log evidence (before fix):

12:19:55 — Server started
12:19:56 — client sends initialize
12:20:09 — Server transport closed unexpectedly (crash after ~12s)

After fix — server ran stable for 9.5+ hours with 277 tool calls, average response time 42ms.

Workaround

Patch build/main.js line ~12066:

// Before:
this.connectionMonitor = new ConnectionMonitor;

// After:
this.connectionMonitor = new ConnectionMonitor(Number.MAX_SAFE_INTEGER, 30000);

Suggestion

Consider either:

  • Removing the inactivity timeout entirely for stdio transport (Claude Desktop can be idle for minutes between calls)
  • Making the timeout configurable via environment variable or CLI argument
  • Disabling ConnectionMonitor by default

Environment

  • obsidian-mcp: 1.0.6
  • Node.js: v22.x
  • OS: Windows 11
  • Client: Claude Desktop (latest)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions