Skip to content

Commit 49ea119

Browse files
committed
fix: Revert Go types to use base Transport with Variables field
- Add Variables field back to base Transport struct for compatibility - Revert API types to use []model.Transport for remotes - Keep schema separation with LocalTransport and RemoteTransport - This maintains schema benefits while fixing validation issue
1 parent 0e219a0 commit 49ea119

File tree

6 files changed

+38
-37
lines changed

6 files changed

+38
-37
lines changed

internal/api/handlers/v0/publish_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ func TestPublishEndpoint(t *testing.T) {
335335
},
336336
},
337337
},
338-
Remotes: []model.RemoteTransport{
338+
Remotes: []model.Transport{
339339
{
340340
Type: model.TransportTypeStreamableHTTP,
341341
URL: "https://example.com/api",

internal/service/registry_service_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func TestValidateNoDuplicateRemoteURLs(t *testing.T) {
2121
Name: "com.example/existing-server",
2222
Description: "An existing server",
2323
Version: "1.0.0",
24-
Remotes: []model.RemoteTransport{
24+
Remotes: []model.Transport{
2525
{Type: "streamable-http", URL: "https://api.example.com/mcp"},
2626
{Type: "sse", URL: "https://webhook.example.com/sse"},
2727
},
@@ -30,7 +30,7 @@ func TestValidateNoDuplicateRemoteURLs(t *testing.T) {
3030
Name: "com.microsoft/another-server",
3131
Description: "Another existing server",
3232
Version: "1.0.0",
33-
Remotes: []model.RemoteTransport{
33+
Remotes: []model.Transport{
3434
{Type: "streamable-http", URL: "https://api.microsoft.com/mcp"},
3535
},
3636
},
@@ -58,7 +58,7 @@ func TestValidateNoDuplicateRemoteURLs(t *testing.T) {
5858
Name: "com.example/new-server",
5959
Description: "A new server with no remotes",
6060
Version: "1.0.0",
61-
Remotes: []model.RemoteTransport{},
61+
Remotes: []model.Transport{},
6262
},
6363
expectError: false,
6464
},
@@ -68,7 +68,7 @@ func TestValidateNoDuplicateRemoteURLs(t *testing.T) {
6868
Name: "com.example/new-server",
6969
Description: "A new server",
7070
Version: "1.0.0",
71-
Remotes: []model.RemoteTransport{
71+
Remotes: []model.Transport{
7272
{Type: "streamable-http", URL: "https://new.example.com/mcp"},
7373
{Type: "sse", URL: "https://unique.example.com/sse"},
7474
},
@@ -81,7 +81,7 @@ func TestValidateNoDuplicateRemoteURLs(t *testing.T) {
8181
Name: "com.example/new-server",
8282
Description: "A new server with duplicate URL",
8383
Version: "1.0.0",
84-
Remotes: []model.RemoteTransport{
84+
Remotes: []model.Transport{
8585
{Type: "streamable-http", URL: "https://api.example.com/mcp"}, // This URL already exists
8686
},
8787
},
@@ -94,7 +94,7 @@ func TestValidateNoDuplicateRemoteURLs(t *testing.T) {
9494
Name: "com.example/existing-server", // Same name as existing
9595
Description: "Updated existing server",
9696
Version: "1.1.0",
97-
Remotes: []model.RemoteTransport{
97+
Remotes: []model.Transport{
9898
{Type: "streamable-http", URL: "https://api.example.com/mcp"}, // Same URL as before
9999
},
100100
},

internal/validators/validators.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ func collectAvailableVariables(pkg *model.Package) []string {
293293
}
294294

295295
// collectRemoteTransportVariables extracts available variable names from a remote transport
296-
func collectRemoteTransportVariables(transport *model.RemoteTransport) []string {
296+
func collectRemoteTransportVariables(transport *model.Transport) []string {
297297
var variables []string
298298

299299
// Add variable names from the Variables map
@@ -338,7 +338,7 @@ func validatePackageTransport(transport *model.Transport, availableVariables []s
338338
}
339339

340340
// validateRemoteTransport validates a remote transport with optional templating
341-
func validateRemoteTransport(obj *model.RemoteTransport) error {
341+
func validateRemoteTransport(obj *model.Transport) error {
342342
// Validate transport type is supported - remotes only support streamable-http and sse
343343
switch obj.Type {
344344
case model.TransportTypeStreamableHTTP, model.TransportTypeSSE:

internal/validators/validators_test.go

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ func TestValidate(t *testing.T) {
213213
},
214214
},
215215
},
216-
Remotes: []model.RemoteTransport{
216+
Remotes: []model.Transport{
217217
{
218218
Type: "streamable-http",
219219
URL: "https://example.com/remote",
@@ -531,7 +531,7 @@ func TestValidate(t *testing.T) {
531531
Source: "github",
532532
},
533533
Version: "1.0.0",
534-
Remotes: []model.RemoteTransport{
534+
Remotes: []model.Transport{
535535
{
536536
Type: "streamable-http",
537537
URL: "not-a-valid-url",
@@ -550,7 +550,7 @@ func TestValidate(t *testing.T) {
550550
Source: "github",
551551
},
552552
Version: "1.0.0",
553-
Remotes: []model.RemoteTransport{
553+
Remotes: []model.Transport{
554554
{
555555
Type: "streamable-http",
556556
URL: "example.com/remote",
@@ -569,7 +569,7 @@ func TestValidate(t *testing.T) {
569569
Source: "github",
570570
},
571571
Version: "1.0.0",
572-
Remotes: []model.RemoteTransport{
572+
Remotes: []model.Transport{
573573
{
574574
Type: "streamable-http",
575575
URL: "http://localhost",
@@ -588,7 +588,7 @@ func TestValidate(t *testing.T) {
588588
Source: "github",
589589
},
590590
Version: "1.0.0",
591-
Remotes: []model.RemoteTransport{
591+
Remotes: []model.Transport{
592592
{
593593
Type: "streamable-http",
594594
URL: "http://localhost:3000",
@@ -607,7 +607,7 @@ func TestValidate(t *testing.T) {
607607
Source: "github",
608608
},
609609
Version: "1.0.0",
610-
Remotes: []model.RemoteTransport{
610+
Remotes: []model.Transport{
611611
{
612612
Type: "streamable-http",
613613
URL: "https://valid.com/remote",
@@ -646,7 +646,7 @@ func TestValidate(t *testing.T) {
646646
},
647647
Version: "1.0.0",
648648
Packages: []model.Package{},
649-
Remotes: []model.RemoteTransport{},
649+
Remotes: []model.Transport{},
650650
},
651651
expectedError: "",
652652
},
@@ -677,7 +677,7 @@ func TestValidate_RemoteNamespaceMatch(t *testing.T) {
677677
name: "valid match - example.com domain",
678678
serverDetail: apiv0.ServerJSON{
679679
Name: "com.example/test-server",
680-
Remotes: []model.RemoteTransport{
680+
Remotes: []model.Transport{
681681
{
682682
Type: "streamable-http",
683683
URL: "https://example.com/mcp",
@@ -690,7 +690,7 @@ func TestValidate_RemoteNamespaceMatch(t *testing.T) {
690690
name: "valid match - subdomain mcp.example.com",
691691
serverDetail: apiv0.ServerJSON{
692692
Name: "com.example/test-server",
693-
Remotes: []model.RemoteTransport{
693+
Remotes: []model.Transport{
694694
{
695695
Type: "streamable-http",
696696
URL: "https://mcp.example.com/endpoint",
@@ -703,7 +703,7 @@ func TestValidate_RemoteNamespaceMatch(t *testing.T) {
703703
name: "valid match - api subdomain",
704704
serverDetail: apiv0.ServerJSON{
705705
Name: "com.example/api-server",
706-
Remotes: []model.RemoteTransport{
706+
Remotes: []model.Transport{
707707
{
708708
Type: "streamable-http",
709709
URL: "https://api.example.com/mcp",
@@ -716,7 +716,7 @@ func TestValidate_RemoteNamespaceMatch(t *testing.T) {
716716
name: "invalid - wrong domain",
717717
serverDetail: apiv0.ServerJSON{
718718
Name: "com.example/test-server",
719-
Remotes: []model.RemoteTransport{
719+
Remotes: []model.Transport{
720720
{
721721
Type: "streamable-http",
722722
URL: "https://google.com/mcp",
@@ -730,7 +730,7 @@ func TestValidate_RemoteNamespaceMatch(t *testing.T) {
730730
name: "invalid - different domain entirely",
731731
serverDetail: apiv0.ServerJSON{
732732
Name: "com.microsoft/server",
733-
Remotes: []model.RemoteTransport{
733+
Remotes: []model.Transport{
734734
{
735735
Type: "streamable-http",
736736
URL: "https://api.github.com/endpoint",
@@ -744,7 +744,7 @@ func TestValidate_RemoteNamespaceMatch(t *testing.T) {
744744
name: "invalid URL format",
745745
serverDetail: apiv0.ServerJSON{
746746
Name: "com.example/test",
747-
Remotes: []model.RemoteTransport{
747+
Remotes: []model.Transport{
748748
{
749749
Type: "streamable-http",
750750
URL: "not-a-valid-url",
@@ -758,15 +758,15 @@ func TestValidate_RemoteNamespaceMatch(t *testing.T) {
758758
name: "empty remotes array",
759759
serverDetail: apiv0.ServerJSON{
760760
Name: "com.example/test",
761-
Remotes: []model.RemoteTransport{},
761+
Remotes: []model.Transport{},
762762
},
763763
expectError: false,
764764
},
765765
{
766766
name: "multiple valid remotes - different subdomains",
767767
serverDetail: apiv0.ServerJSON{
768768
Name: "com.example/server",
769-
Remotes: []model.RemoteTransport{
769+
Remotes: []model.Transport{
770770
{
771771
Type: "streamable-http",
772772
URL: "https://api.example.com/sse",
@@ -783,7 +783,7 @@ func TestValidate_RemoteNamespaceMatch(t *testing.T) {
783783
name: "one valid, one invalid remote",
784784
serverDetail: apiv0.ServerJSON{
785785
Name: "com.example/server",
786-
Remotes: []model.RemoteTransport{
786+
Remotes: []model.Transport{
787787
{
788788
Type: "streamable-http",
789789
URL: "https://example.com/sse",
@@ -1351,7 +1351,7 @@ func TestValidate_TransportValidation(t *testing.T) {
13511351
Name: "com.example/test-server",
13521352
Description: "A test server",
13531353
Version: "1.0.0",
1354-
Remotes: []model.RemoteTransport{
1354+
Remotes: []model.Transport{
13551355
{
13561356
Type: "streamable-http",
13571357
URL: "https://example.com/mcp",
@@ -1366,7 +1366,7 @@ func TestValidate_TransportValidation(t *testing.T) {
13661366
Name: "com.example/test-server",
13671367
Description: "A test server",
13681368
Version: "1.0.0",
1369-
Remotes: []model.RemoteTransport{
1369+
Remotes: []model.Transport{
13701370
{
13711371
Type: "streamable-http",
13721372
},
@@ -1381,7 +1381,7 @@ func TestValidate_TransportValidation(t *testing.T) {
13811381
Name: "com.example/test-server",
13821382
Description: "A test server",
13831383
Version: "1.0.0",
1384-
Remotes: []model.RemoteTransport{
1384+
Remotes: []model.Transport{
13851385
{
13861386
Type: "sse",
13871387
URL: "https://example.com/events",
@@ -1396,7 +1396,7 @@ func TestValidate_TransportValidation(t *testing.T) {
13961396
Name: "com.example/test-server",
13971397
Description: "A test server",
13981398
Version: "1.0.0",
1399-
Remotes: []model.RemoteTransport{
1399+
Remotes: []model.Transport{
14001400
{
14011401
Type: "sse",
14021402
},
@@ -1411,7 +1411,7 @@ func TestValidate_TransportValidation(t *testing.T) {
14111411
Name: "com.example/test-server",
14121412
Description: "A test server",
14131413
Version: "1.0.0",
1414-
Remotes: []model.RemoteTransport{
1414+
Remotes: []model.Transport{
14151415
{
14161416
Type: "stdio",
14171417
},
@@ -1425,7 +1425,7 @@ func TestValidate_TransportValidation(t *testing.T) {
14251425
Name: "com.example/test-server",
14261426
Description: "A test server",
14271427
Version: "1.0.0",
1428-
Remotes: []model.RemoteTransport{
1428+
Remotes: []model.Transport{
14291429
{
14301430
Type: "websocket",
14311431
URL: "wss://example.com/ws",
@@ -1460,7 +1460,7 @@ func TestValidate_TransportValidation(t *testing.T) {
14601460
Name: "com.example/test-server",
14611461
Description: "A test server",
14621462
Version: "1.0.0",
1463-
Remotes: []model.RemoteTransport{
1463+
Remotes: []model.Transport{
14641464
{
14651465
Type: "streamable-http",
14661466
URL: "http://localhost:3000/mcp",
@@ -1584,7 +1584,7 @@ func createValidServerWithArgument(arg model.Argument) apiv0.ServerJSON {
15841584
RuntimeArguments: []model.Argument{arg},
15851585
},
15861586
},
1587-
Remotes: []model.RemoteTransport{
1587+
Remotes: []model.Transport{
15881588
{
15891589
Type: "streamable-http",
15901590
URL: "https://example.com/remote",

pkg/api/v0/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ type ServerJSON struct {
3737
Version string `json:"version"`
3838
WebsiteURL string `json:"websiteUrl,omitempty"`
3939
Packages []model.Package `json:"packages,omitempty"`
40-
Remotes []model.RemoteTransport `json:"remotes,omitempty"`
40+
Remotes []model.Transport `json:"remotes,omitempty"`
4141
Meta *ServerMeta `json:"_meta,omitempty"`
4242
}
4343

pkg/model/types.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ const (
1111

1212
// Transport represents transport configuration for Package context
1313
type Transport struct {
14-
Type string `json:"type"`
15-
URL string `json:"url,omitempty"`
16-
Headers []KeyValueInput `json:"headers,omitempty"`
14+
Type string `json:"type"`
15+
URL string `json:"url,omitempty"`
16+
Headers []KeyValueInput `json:"headers,omitempty"`
17+
Variables map[string]Input `json:"variables,omitempty"`
1718
}
1819

1920
// RemoteTransport represents transport configuration for Remote context with variables support

0 commit comments

Comments
 (0)