Add app-server MCP event streaming (#39761)

## What changed

- Add experimental `mcpServer/event/stream/start` and `mcpServer/event/stream/stop` requests for hosted apps, plus `mcpServer/event/stream/notification` forwarding.
- Scope subscriptions to the owning app-server connection and subscribed thread, enforce unique IDs and a per-connection limit, and clean them up when the thread is unsubscribed or the connection closes.
- Wait for the MCP active notification before completing startup, retry streams that close immediately, and terminate them when authentication or hosted runtime ownership changes.

## Testing

- Add an app-server integration test covering activation, event forwarding, duplicate subscription rejection, and explicit cancellation.

GitOrigin-RevId: 8a6fc1615adfc5af7e67def3b824fa5909ab3e7b
This commit is contained in:
victor-openai authored and copyberry committed 2026-08-20 17:49:35 +00:00
1 parent 8a40095ea3
commit 097825f75a
30 files changed
+1043 -66

No files matched your search

+5 -5
View File
@@ -1176,11 +1176,11 @@ pub async fn run_main_with_transport_options(
};
if !shutdown_state.forced() {
futures::future::join_all(
connections
.values()
.map(|connection_state| connection_state.session.rpc_gate.shutdown()),
)
futures::future::join_all(connections.iter().map(
|(&connection_id, connection_state)| {
processor.connection_closed(connection_id, &connection_state.session)
},
))
.await;
connection_cleanup_tasks.drain().await;
processor.drain_background_tasks().await;