diff --git a/internal/validators/validators.go b/internal/validators/validators.go index 4ce0869..8bab80f 100644 --- a/internal/validators/validators.go +++ b/internal/validators/validators.go @@ -34,7 +34,7 @@ func ValidateServerJSON(serverJSON *apiv0.ServerJSON) error { // Validate all remotes for _, remote := range serverJSON.Remotes { - if err := validateTransport(&remote); err != nil { + if err := validateRemoteTransport(&remote); err != nil { return err } } @@ -178,7 +178,10 @@ func validatePackageTransport(transport *model.Transport, availableVariables []s // Validate transport type is supported switch transport.Type { case model.TransportTypeStdio: - // No additional validation needed for stdio - URL should be empty + // Validate that URL is empty for stdio transport + if transport.URL != "" { + return fmt.Errorf("url must be empty for %s transport type, got: %s", transport.Type, transport.URL) + } return nil case model.TransportTypeStreamableHTTP, model.TransportTypeSSE: // URL is required for streamable-http and sse @@ -201,8 +204,8 @@ func validatePackageTransport(transport *model.Transport, availableVariables []s } } -// validateTransport validates a remote transport (no templating allowed) -func validateTransport(obj *model.Transport) error { +// validateRemoteTransport validates a remote transport (no templating allowed) +func validateRemoteTransport(obj *model.Transport) error { // Validate transport type is supported - remotes only support streamable-http and sse switch obj.Type { case model.TransportTypeStreamableHTTP, model.TransportTypeSSE: diff --git a/internal/validators/validators_test.go b/internal/validators/validators_test.go index f878cb8..35e654e 100644 --- a/internal/validators/validators_test.go +++ b/internal/validators/validators_test.go @@ -832,7 +832,7 @@ func TestValidate_TransportValidation(t *testing.T) { }{ // Package transport tests - stdio (no URL required) { - name: "package transport stdio without URL", + name: "package transport stdio without URL should pass", serverDetail: apiv0.ServerJSON{ Name: "com.example/test-server", Description: "A test server", @@ -852,7 +852,7 @@ func TestValidate_TransportValidation(t *testing.T) { expectedError: "", }, { - name: "package transport stdio with URL (should still work)", + name: "package transport stdio with URL (should fail)", serverDetail: apiv0.ServerJSON{ Name: "com.example/test-server", Description: "A test server", @@ -870,7 +870,7 @@ func TestValidate_TransportValidation(t *testing.T) { }, }, }, - expectedError: "", + expectedError: "url must be empty for stdio transport type", }, // Package transport tests - streamable-http (URL required) { @@ -1270,9 +1270,9 @@ func createValidServerWithArgument(arg model.Argument) apiv0.ServerJSON { }, Packages: []model.Package{ { - Identifier: "test-package", - RegistryType: "npm", - RegistryBaseURL: "https://registry.npmjs.org", + Identifier: "test-package", + RegistryType: "npm", + RegistryBaseURL: "https://registry.npmjs.org", Transport: model.Transport{ Type: "stdio", },