claude-code - 💡(How to fix) Fix Feature request: Lazy/on-demand MCP server connections

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

  • Manually editing settings per session — works but tedious and error-prone

Code Example

{
  "mcpServers": {
    "essential-server": {
      "command": "...",
      "autoConnect": true
    },
    "occasionally-used-server": {
      "command": "...",
      "autoConnect": false
    }
  }
}
RAW_BUFFERClick to expand / collapse

Problem

When multiple MCP servers are configured, all of them connect at session startup regardless of whether they'll be used in that session. This causes significant memory/RAM consumption and slower startup times, especially for users who have several MCP servers configured across different services.

Tool search already defers tool definitions (schema loading) until needed, which helps with context window usage — but the underlying server processes still launch and hold open connections at startup, consuming system resources.

Proposed Solution

Add a per-server configuration option (e.g., "autoConnect": false or "lazyConnect": true) that defers the actual server process launch and connection until one of its tools is first invoked.

Example:

{
  "mcpServers": {
    "essential-server": {
      "command": "...",
      "autoConnect": true
    },
    "occasionally-used-server": {
      "command": "...",
      "autoConnect": false
    }
  }
}

Servers with autoConnect: false would:

  • NOT spawn a process or establish a connection at session start
  • Only connect when the user explicitly asks to use one of their tools (or when tool search resolves to one of their tools)
  • Still appear in /mcp status (shown as "not connected" or "on-demand")

Use Case

Users who work across multiple projects and cloud services often configure many MCP servers (monitoring, databases, version control, project management, cloud storage, etc.). In any given session, only a subset of these are actually needed. Spawning all server processes upfront wastes memory and can cause performance issues on resource-constrained machines.

Alternatives Considered

  • Manually editing settings per session — works but tedious and error-prone
  • Using project-scoped settings — helps somewhat but doesn't solve it when multiple servers are needed in the same project
  • Tool search — already implemented but only defers schema definitions, not the actual connections

Additional Context

This would complement the existing tool search feature nicely — tool search optimizes context window usage, while lazy connections would optimize system resource usage.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING