[FEATURE] MCP `on_session_start` hook for session context restoration
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
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.
Alternative Solutions
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.
Priority
Medium - Would be very helpful
Feature Category
MCP server integration
Use Case Example
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.
Additional Context
This was previously opened as #38095 and auto closed, but it was not a duplicate of #32843. They have a different solution space. This issue proposes having a well-known API call that is always called on every MCP that it exists in to compose the startup context.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗