(value any, schema map[string]any)
| 395 | return coerceMCPValueForSchema(value, resolved, root) |
| 396 | } |
| 397 | return value |
| 398 | } |
| 399 | if variants, ok := schema["anyOf"].([]any); ok { |
| 400 | for _, variant := range variants { |
| 401 | variantSchema := mapFromAny(variant) |
| 402 | if len(variantSchema) == 0 { |
| 403 | continue |
| 404 | } |
| 405 | if typ, _ := variantSchema["type"].(string); typ == "null" { |
| 406 | continue |
| 407 | } |
| 408 | return coerceMCPValueForSchema(value, variantSchema, root) |
| 409 | } |
| 410 | } |
| 411 | jsonType, _ := mcpJSONType(schema["type"], inferMCPType(schema)) |
| 412 | switch jsonType { |
| 413 | case "object": |
| 414 | valueMap, ok := value.(map[string]any) |
| 415 | if !ok { |
| 416 | return value |
| 417 | } |
| 418 | props := mapFromAny(schema["properties"]) |
| 419 | if len(props) == 0 { |
| 420 | return value |
| 421 | } |
| 422 | out := make(map[string]any, len(valueMap)) |
| 423 | for key, rawValue := range valueMap { |
| 424 | if propSchema := mapFromAny(props[key]); len(propSchema) > 0 { |
| 425 | out[key] = coerceMCPValueForSchema(rawValue, propSchema, root) |
| 426 | } else { |
no test coverage detected