Skip to content

MCP: expose backend notification-stream lifecycle and failure metrics #2725

Description

@lucazz

Business Value

Operators need to distinguish a healthy MCP notification stream from an unsupported, rejected, disconnected, or stalled backend stream without relying on log searches.

Current behavior

The composite session opens one Streamable HTTP GET notification stream per initialized backend. Stream setup failures and non-success responses are returned to sendToBackendsFiltered, where they are logged as failed to collect messages from MCP backend. When every backend stream ends, the client-facing stream stays open for gateway heartbeats and route-level tool-change notifications.

The existing MCP metrics cover method counts, request and initialization duration, capabilities, and progress notifications. They do not expose whether a backend notification stream opened, is active, closed normally, returned an unsupported status such as 405, or failed.

A client-facing SSE connection can therefore look healthy while every upstream backend notification stream has ended.

Suggested behavior

Add backend-scoped metrics for:

  • stream open attempts and outcomes;
  • currently active streams;
  • normal close or cancellation;
  • unsupported/no-stream responses such as 204, 405, or accepted responses with no stream;
  • transport and HTTP failures, including the status class where available;
  • stream lifetime.

Tests should cover one healthy stream alongside one rejected or closed backend stream, plus the case where all backend streams end while the gateway keeps the client-facing heartbeat stream open.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/mcpMCP proxy, MCPRoute, and MCP spec conformancearea/observabilityMetrics, tracing, logging, GenAI observabilityenhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions