Add dynamic loading/unloading of MCP servers during active sessions

Resolved 💬 15 comments Opened Aug 27, 2025 by izpavlovich Closed Feb 14, 2026

Problem Statement

Currently, MCP servers are loaded at session start and remain in the context window for the entire session, consuming tokens even when not
actively needed. This is particularly problematic for specialized tools like Linear that are heavily used during planning phases but rarely
needed during implementation.

Current behavior:

  • Linear MCP server: ~14k tokens (7% of 200k context window)
  • Loaded for entire session regardless of usage
  • No way to dynamically enable/disable during session

## Use Case

Typical development workflow:

  1. Planning phase (5-15 minutes): Heavy Linear usage - create issues, update tickets, organize work
  2. Implementation phase (1-3 hours): Primarily coding - Linear context unused but consuming tokens
  3. Occasional planning (sporadic): Brief Linear usage for updates

Current workarounds are suboptimal:

  • Session restarts lose conversation context
  • Separate sessions fragment workflow
  • Manual MCP add/remove requires CLI context switching

## Proposed Solution

Add dynamic MCP server management with session commands:

/mcp enable linear # Load MCP server mid-session
/mcp disable linear # Unload and free context tokens
/mcp list # Show active/available servers
/mcp status # Show token usage by server

Benefits:

  • Preserve conversation context while managing resources
  • Optimize context window usage for long development sessions
  • Enable phase-based workflows (planning → implementation → review)
  • Maintain security controls (approval prompts still apply)

## Implementation Considerations

  • Context cleanup: Properly remove server tools/schema from context
  • State management: Handle graceful enable/disable without breaking ongoing conversations
  • Security: Maintain existing approval workflows for project-scoped servers
  • UI feedback: Clear indication of active/inactive servers in status line
  • Persistence: Remember user preferences per session

## Alternative Solutions Considered

  1. Improved scoping: More granular scope controls (feature-based, time-based)
  2. Lazy loading: Load servers on first use rather than session start
  3. Context compression: Compress unused MCP server definitions

## Related Issues

  • #4986 (Dynamic Subagent Loading) - Shows interest in dynamic loading concepts
  • #6632, #6616, #6621 - Context optimization concerns from users

## Impact

This feature would significantly improve context efficiency for users with multiple MCP servers, especially in long development sessions where
tool usage patterns change over time.

View original on GitHub ↗

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