MCP on_session_start lifecycle hook for session context restoration

Resolved 💬 3 comments Opened Mar 24, 2026 by briantopping Closed Mar 27, 2026

Use case

When a session starts (new or resumed) with a remote MCP server configured, there's no way for the MCP server to proactively provide context to the session. The session has to know what to search for, but a just-started session doesn't know what it doesn't know.

Proposed solution

Add an optional MCP lifecycle hook: when a session connects to a remote MCP server, automatically call a designated tool (e.g. on_session_start) if the server exposes one. The server returns context relevant to the connecting session — unread messages, status updates, recent changes in the session's domain, or a context summary from a previous session under the same actor identity.

Why this matters

This enables MCP servers to act as persistence layers across sessions. An actor (human or agent) that closed a session yesterday can resume today and immediately receive relevant context from the MCP server without manually searching. Combined with server-initiated notifications (#36665), this completes the session lifecycle: wake → get context → work → receive push updates → hibernate.

Current workaround

Sessions must be instructed (via CLAUDE.md or human prompting) to call specific MCP tools at startup. This is fragile — new sessions don't know what to call, and the instructions add to the system prompt size.

View original on GitHub ↗

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