Skip to content

Commit dab4e69

Browse files
committed
fix(supervisor): accept mixed-case MCP version protocols
Validate materialized MCP version metadata through the parsed L7 protocol so supported mixed-case spellings remain valid. Cover YAML and protobuf ingress with pinned-default regression tests. Signed-off-by: Shiju <shiju@nvidia.com>
1 parent a6d4dc0 commit dab4e69

2 files changed

Lines changed: 16 additions & 10 deletions

File tree

crates/openshell-supervisor-network/src/l7/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,7 +1285,7 @@ pub fn validate_l7_policies(data_json: &serde_json::Value) -> (Vec<String>, Vec<
12851285
"{loc}: JSON-RPC-specific endpoint fields are ignored unless protocol is json-rpc or mcp"
12861286
));
12871287
}
1288-
validate_mcp_versions_field(&mut errors, &loc, ep, protocol);
1288+
validate_mcp_versions_field(&mut errors, &loc, ep, l7_protocol);
12891289
let has_mcp_strict_tool_names = ep.get("mcp_strict_tool_names").is_some();
12901290
let has_mcp_allow_all_known_mcp_methods =
12911291
ep.get("mcp_allow_all_known_mcp_methods").is_some();
@@ -1609,12 +1609,12 @@ fn validate_mcp_versions_field(
16091609
errors: &mut Vec<String>,
16101610
loc: &str,
16111611
endpoint: &serde_json::Value,
1612-
protocol: &str,
1612+
protocol: Option<L7Protocol>,
16131613
) {
16141614
let Some(value) = endpoint.get("mcp_versions") else {
16151615
return;
16161616
};
1617-
if protocol != "mcp" {
1617+
if protocol != Some(L7Protocol::Mcp) {
16181618
errors.push(format!(
16191619
"{loc}: mcp.versions is only valid for protocol mcp"
16201620
));

crates/openshell-supervisor-network/src/opa.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4930,15 +4930,15 @@ network_policies:
49304930
}
49314931

49324932
#[test]
4933-
fn l7_endpoint_config_materializes_default_mcp_versions_without_alias() {
4933+
fn yaml_load_accepts_mixed_case_mcp_protocol_with_default_versions() {
49344934
let data = r#"
49354935
network_policies:
49364936
mcp:
49374937
name: mcp
49384938
endpoints:
49394939
- host: mcp.example.com
49404940
port: 443
4941-
protocol: mcp
4941+
protocol: MCP
49424942
rules:
49434943
- allow:
49444944
method: tools/list
@@ -5485,11 +5485,17 @@ network_policies:
54855485
}
54865486

54875487
#[test]
5488-
fn proto_load_accepts_defaultable_mcp_versions() {
5489-
for policy in [
5490-
defaultable_mcp_proto(None),
5491-
defaultable_mcp_proto(Some(McpOptions::default())),
5492-
] {
5488+
fn proto_load_accepts_defaultable_mcp_versions_with_mixed_case_protocol() {
5489+
let mut implicit_defaults = defaultable_mcp_proto(None);
5490+
implicit_defaults
5491+
.network_policies
5492+
.get_mut("mcp")
5493+
.expect("defaultable MCP fixture contains the MCP policy")
5494+
.endpoints[0]
5495+
.protocol = "Mcp".to_string();
5496+
let explicit_defaults = defaultable_mcp_proto(Some(McpOptions::default()));
5497+
5498+
for policy in [implicit_defaults, explicit_defaults] {
54935499
let engine = OpaEngine::from_proto(&policy)
54945500
.expect("supervisor ingress must materialize the pinned MCP revision");
54955501
let input = NetworkInput {

0 commit comments

Comments
 (0)