MCPcopy Create free account
hub / github.com/github/gh-aw / validateStringProperty

Function validateStringProperty

pkg/workflow/mcp_property_validation.go:26–45  ·  view source on GitHub ↗

validateStringProperty validates that a property is a string and returns appropriate error message

(toolName, propertyName string, value any, exists bool)

Source from the content-addressed store, hash-verified

24
25// validateStringProperty validates that a property is a string and returns appropriate error message
26func validateStringProperty(toolName, propertyName string, value any, exists bool) error {
27 field := fmt.Sprintf("mcp-servers.%s.%s", toolName, propertyName)
28 if !exists {
29 return NewValidationError(
30 field,
31 "",
32 fmt.Sprintf("missing required property '%s'; expected this field in MCP configuration", propertyName),
33 fmt.Sprintf("Example:\n\ntools:\n %s:\n %s: \"value\"\n\nSee: %s", toolName, propertyName, constants.DocsToolsURL),
34 )
35 }
36 if _, ok := value.(string); !ok {
37 return NewValidationError(
38 field,
39 fmt.Sprintf("%v", value),
40 fmt.Sprintf("'%s' must be a string, got %T", propertyName, value),
41 fmt.Sprintf("Example:\n\ntools:\n %s:\n %s: \"my-value\"\n\nSee: %s", toolName, propertyName, constants.DocsToolsURL),
42 )
43 }
44 return nil
45}
46
47// validateMCPRequirements validates the specific requirements for MCP configuration
48func validateMCPRequirements(toolName string, mcpConfig map[string]any, toolConfig map[string]any) error {

Calls 1

NewValidationErrorFunction · 0.70