From afd5f4c24845ac884a5ab8e1b020da1f801df2d3 Mon Sep 17 00:00:00 2001 From: "windmill-internal-app[bot]" <1429786+windmill-internal-app[bot]@users.noreply.github.com> Date: Wed, 13 May 2026 23:49:43 +0000 Subject: [PATCH] fix(mcp): sanitize type: resource and resourceType in nested schemas --- backend/windmill-mcp/src/common/schema.rs | 25 ++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/backend/windmill-mcp/src/common/schema.rs b/backend/windmill-mcp/src/common/schema.rs index 054b0e999a..19c65939ca 100644 --- a/backend/windmill-mcp/src/common/schema.rs +++ b/backend/windmill-mcp/src/common/schema.rs @@ -54,6 +54,7 @@ pub fn make_schema_compatible(schema: &mut Value) { // 1. Strip non-standard keywords that aren't part of JSON Schema obj.remove("originalType"); + obj.remove("resourceType"); // 2. Strip non-standard format values (resource-* is Windmill-internal) if obj @@ -74,15 +75,18 @@ pub fn make_schema_compatible(schema: &mut Value) { } } - // 4. Convert integer to number + // 4. Convert non-standard types if let Some(type_val) = obj.get_mut("type") { match type_val { Value::String(s) if s == "integer" => *s = "number".to_string(), + Value::String(s) if s == "resource" => *s = "string".to_string(), Value::Array(arr) => { for item in arr.iter_mut() { if let Value::String(s) = item { if s == "integer" { *s = "number".to_string(); + } else if s == "resource" { + *s = "string".to_string(); } } } @@ -368,4 +372,23 @@ mod tests { assert_eq!(schema["type"], json!("object")); } + + #[test] + fn converts_resource_type_in_array_items() { + let mut schema = json!({ + "type": "object", + "properties": { + "accounts": { + "type": "array", + "items": { + "type": "resource", + "resourceType": "c_aws_account" + } + } + } + }); + make_schema_compatible(&mut schema); + assert_eq!(schema["properties"]["accounts"]["items"]["type"], json!("string")); + assert!(schema["properties"]["accounts"]["items"].get("resourceType").is_none()); + } }