Skip to content

Conversation

@npolshakova
Copy link
Contributor

Description

Adds configuration for stateful/stateless mcp backends

Change Type

/kind feature

Changelog

Added configuration for stateful/stateless session routng for mcp backends. 

Copilot AI review requested due to automatic review settings December 23, 2025 21:57
@npolshakova npolshakova requested a review from a team as a code owner December 23, 2025 21:57
@gateway-bot gateway-bot added kind/feature Categorizes issue or PR as related to a new feature. release-note labels Dec 23, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds configuration for stateful/stateless session routing for MCP backends. The new sessionRouting field allows users to specify whether requests from a session should be routed to the same backend replica (Stateful) or can be distributed across replicas (Stateless), with Stateful being the default behavior.

  • Added SessionRouting type and field to MCPBackend struct in API
  • Updated translation logic to convert sessionRouting configuration to statefulMode in backend output
  • Updated CRD template to include the new enum field with validation

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
api/v1alpha1/agentgateway/agentgateway_backend_types.go Defines the new SessionRouting type with Stateful/Stateless constants and adds the sessionRouting field to MCPBackend
pkg/kgateway/agentgatewaysyncer/backend/translate.go Implements translation logic to convert sessionRouting API field to statefulMode backend field with STATEFUL as the default
install/helm/agentgateway-crds/templates/agentgateway.dev_agentgatewaybackends.yaml Adds CRD validation for the new sessionRouting enum field
pkg/kgateway/agentgatewaysyncer/backend/testdata/backend/mcp-static-no-protocol.yaml Updates test to verify Stateless session routing configuration
pkg/kgateway/agentgatewaysyncer/backend/testdata/backend/mcp-service-selector-sse.yaml Updates test to verify Stateless session routing configuration with service selector

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@howardjohn howardjohn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM just nitpick on the docs

// +required
Targets []McpTargetSelector `json:"targets"`

// SessionRouting configures whether to ensure all requests from a session go to the same backend replica
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This description is slightly inaccurate IMO. The primary aspect of Stateful mode is that an mcp-session will be created (via mcp-session-id). In order to make that behave properly we also then pin requests to a specific backend replica, but that is more of the secondary goal of the toggle -- the mcp session is user-facing while the pinning is internal.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay reworded here: b5416ee Let me know what you think!

Signed-off-by: npolshakova <[email protected]>
@howardjohn howardjohn added this pull request to the merge queue Dec 30, 2025
Merged via the queue into kgateway-dev:main with commit 97ef4f4 Dec 30, 2025
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/feature Categorizes issue or PR as related to a new feature. release-note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants