Repository: envoyproxy/envoy
File: api/envoy/extensions/filters/http/mcp/v3/mcp.proto (Protocol Buffers)

Code before:
  enum TrafficMode {
    // Proxies the HTTP request and response without MCP spec check.
    // This is the default mode.
    PASS_THROUGH = 0;

    // Reject requests that are not following MCP spec.
    // Valid MCP requests are:
    // - POST requests with JSON-RPC 2.0 messages
    // - GET requests for SSE streams (with Accept: text/event-stream)
    REJECT_NO_MCP = 1;
  }

  // Where to store parsed MCP request attributes.
  enum RequestStorageMode {
    // Unspecified. Uses default behavior (same as DYNAMIC_METADATA).
    MODE_UNSPECIFIED = 0;

    // Store request attributes in dynamic metadata only.
    // This is the default behavior.
    DYNAMIC_METADATA = 1;

    // Store request attributes in filter state only.
    FILTER_STATE = 2;

    // Store request attributes in both dynamic metadata and filter state.
    BOTH = 3;
  }

  // Configures how the filter handles non-MCP traffic.
  TrafficMode traffic_mode = 1 [(validate.rules).enum = {defined_only: true}];

  // When set to true, the filter will clear the route cache after setting dynamic metadata.
  // This allows the route to be re-selected based on the MCP metadata (e.g., method, params).
  // Defaults to false.
  bool clear_route_cache = 2;

  // Maximum size of the request body to buffer for JSON-RPC validation.
  // If the request body exceeds this size, the request is rejected with ``413 Payload Too Large``.
  // This limit applies to both ``REJECT_NO_MCP`` and ``PASS_THROUGH`` modes to prevent unbounded buffering.
  //
  // It defaults to 8KB (8192 bytes) and the maximum allowed value is 10MB (10485760 bytes).
  //
  // Setting it to 0 would disable the limit. It is not recommended to do so in production.
  google.protobuf.UInt32Value max_request_body_size = 3 [(validate.rules).uint32 = {lte: 10485760}];

  // Parser configuration, this provide the attribute extraction override.
  ParserConfig parser_config = 4;

  // Where to store parsed MCP request attributes.
  // Controls whether attributes are written to dynamic metadata, filter state, or both.
  // Default is DYNAMIC_METADATA when unspecified.

Review comment (suggestion):
Suggest calling this `DYNAMIC_METADATA_AND_FILTER_STATE`, so that if we ever add more options later, the semantics will still be clear.

Code after:
  enum TrafficMode {
    // Proxies the HTTP request and response without MCP spec check.
    // This is the default mode.
    PASS_THROUGH = 0;

    // Reject requests that are not following MCP spec.
    // Valid MCP requests are:
    // - POST requests with JSON-RPC 2.0 messages
    // - GET requests for SSE streams (with Accept: text/event-stream)
    REJECT_NO_MCP = 1;
  }

  // Where to store parsed MCP request attributes.
  enum RequestStorageMode {
    // Unspecified. Uses default behavior (same as DYNAMIC_METADATA).
    MODE_UNSPECIFIED = 0;

    // Store request attributes in dynamic metadata only.
    // This is the default behavior.
    DYNAMIC_METADATA = 1;

    // Store request attributes in filter state only.
    FILTER_STATE = 2;

    // Store request attributes in both dynamic metadata and filter state.
    DYNAMIC_METADATA_AND_FILTER_STATE = 3;
  }

  // Configures how the filter handles non-MCP traffic.
  TrafficMode traffic_mode = 1 [(validate.rules).enum = {defined_only: true}];

  // When set to true, the filter will clear the route cache after setting dynamic metadata.
  // This allows the route to be re-selected based on the MCP metadata (e.g., method, params).
  // Defaults to false.
  bool clear_route_cache = 2;

  // Maximum size of the request body to buffer for JSON-RPC validation.
  // If the request body exceeds this size, the request is rejected with ``413 Payload Too Large``.
  // This limit applies to both ``REJECT_NO_MCP`` and ``PASS_THROUGH`` modes to prevent unbounded buffering.
  //
  // It defaults to 8KB (8192 bytes) and the maximum allowed value is 10MB (10485760 bytes).
  //
  // Setting it to 0 would disable the limit. It is not recommended to do so in production.
  google.protobuf.UInt32Value max_request_body_size = 3 [(validate.rules).uint32 = {lte: 10485760}];

  // Parser configuration, this provide the attribute extraction override.
  ParserConfig parser_config = 4;

  // Where to store parsed MCP request attributes.
  // Controls whether attributes are written to dynamic metadata, filter state, or both.
  // Default is DYNAMIC_METADATA when unspecified.