(ctx context.Context, name string, r map[string]any)
| 487 | } |
| 488 | |
| 489 | func UnmarshalYAMLPromptConfig(ctx context.Context, name string, r map[string]any) (prompts.PromptConfig, error) { |
| 490 | // Look for the 'type' field. If it's not present, typeStr will be an |
| 491 | // empty string, which prompts.DecodeConfig will correctly default to "custom". |
| 492 | var resourceType string |
| 493 | if typeVal, ok := r["type"]; ok { |
| 494 | var isString bool |
| 495 | resourceType, isString = typeVal.(string) |
| 496 | if !isString { |
| 497 | return nil, fmt.Errorf("invalid 'type' field for prompt %q (must be a string)", name) |
| 498 | } |
| 499 | } |
| 500 | dec, err := util.NewStrictDecoder(r) |
| 501 | if err != nil { |
| 502 | return nil, fmt.Errorf("error creating decoder: %s", err) |
| 503 | } |
| 504 | |
| 505 | // Use the central registry to decode the prompt based on its type. |
| 506 | promptCfg, err := prompts.DecodeConfig(ctx, resourceType, name, dec) |
| 507 | if err != nil { |
| 508 | return nil, err |
| 509 | } |
| 510 | return promptCfg, nil |
| 511 | } |
| 512 | |
| 513 | // Tools naming validation is added in the MCP v2025-11-25, but we'll be |
| 514 | // implementing it across Toolbox |
no test coverage detected