Skip to content

Commit d9f0cf2

Browse files
tadasantclaude
andcommitted
revert: remove additional formatting-only changes
Remove more whitespace alignment and spacing changes that don't affect functionality. This further reduces PR noise to focus on ServerID/VersionID consistency changes. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent f8a8133 commit d9f0cf2

File tree

8 files changed

+51
-51
lines changed

8 files changed

+51
-51
lines changed

internal/api/handlers/v0/publish.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,14 @@ func buildPermissionErrorMessage(attemptedResource string, permissions []auth.Pe
7575
permissionStrs = append(permissionStrs, perm.ResourcePattern)
7676
}
7777
}
78-
78+
7979
errorMsg := "You do not have permission to publish this server"
8080
if len(permissionStrs) > 0 {
8181
errorMsg += ". You have permission to publish: " + strings.Join(permissionStrs, ", ")
8282
} else {
8383
errorMsg += ". You do not have any publish permissions"
8484
}
8585
errorMsg += ". Attempting to publish: " + attemptedResource
86-
86+
8787
return errorMsg
8888
}

internal/api/handlers/v0/publish_integration_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ func TestPublishIntegration(t *testing.T) {
160160

161161
t.Run("publish fails with invalid token", func(t *testing.T) {
162162
publishReq := apiv0.ServerJSON{
163-
Name: "io.github.domdomegg/test-server",
164-
Description: "Test server",
165-
Version: "1.0.0",
163+
Name: "io.github.domdomegg/test-server",
164+
Description: "Test server",
165+
Version: "1.0.0",
166166
}
167167

168168
body, err := json.Marshal(publishReq)
@@ -183,7 +183,7 @@ func TestPublishIntegration(t *testing.T) {
183183
publishReq := apiv0.ServerJSON{
184184
Name: "io.github.other/test-server",
185185
Description: "A test server",
186-
Version: "1.0.0",
186+
Version: "1.0.0",
187187
Repository: model.Repository{
188188
URL: "https://github.com/example/test-server",
189189
Source: "github",
@@ -219,8 +219,8 @@ func TestPublishIntegration(t *testing.T) {
219219
publishReq := apiv0.ServerJSON{
220220
Name: "io.github.domdomegg/airtable-mcp-server",
221221
Description: "A test server with MCPB package",
222-
Version: "1.7.2",
223-
Status: model.StatusActive,
222+
Version: "1.7.2",
223+
Status: model.StatusActive,
224224
Packages: []model.Package{
225225
{
226226
RegistryType: model.RegistryTypeMCPB,

internal/api/handlers/v0/publish_registry_validation_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func TestPublishRegistryValidation(t *testing.T) {
4747
publishReq := apiv0.ServerJSON{
4848
Name: "com.example/test-server-with-npm",
4949
Description: "A test server with invalid npm package reference",
50-
Version: "1.0.0",
50+
Version: "1.0.0",
5151
Packages: []model.Package{
5252
{
5353
RegistryType: model.RegistryTypeNPM,
@@ -88,7 +88,7 @@ func TestPublishRegistryValidation(t *testing.T) {
8888
publishReq := apiv0.ServerJSON{
8989
Name: "com.example/test-server-mcpb-validation",
9090
Description: "A test server with MCPB package and registry validation enabled",
91-
Version: "0.0.36",
91+
Version: "0.0.36",
9292
Packages: []model.Package{
9393
{
9494
RegistryType: model.RegistryTypeMCPB,
@@ -138,7 +138,7 @@ func TestPublishRegistryValidation(t *testing.T) {
138138
publishReq := apiv0.ServerJSON{
139139
Name: "com.example/test-server-multiple-packages",
140140
Description: "A test server with multiple packages where second fails",
141-
Version: "1.0.0",
141+
Version: "1.0.0",
142142
Packages: []model.Package{
143143
{
144144
RegistryType: model.RegistryTypeMCPB,
@@ -189,7 +189,7 @@ func TestPublishRegistryValidation(t *testing.T) {
189189
publishReq := apiv0.ServerJSON{
190190
Name: "com.example/test-server-first-package-fails",
191191
Description: "A test server where first package fails",
192-
Version: "1.0.0",
192+
Version: "1.0.0",
193193
Packages: []model.Package{
194194
{
195195
RegistryType: model.RegistryTypeNPM,

internal/api/handlers/v0/publish_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ func TestPublishEndpoint(t *testing.T) {
113113
{
114114
name: "invalid authorization header format",
115115
requestBody: apiv0.ServerJSON{
116-
Name: "io.github.domdomegg/test-server",
117-
Description: "Test server",
118-
Version: "1.0.0",
116+
Name: "io.github.domdomegg/test-server",
117+
Description: "Test server",
118+
Version: "1.0.0",
119119
},
120120
authHeader: "InvalidFormat",
121121
setupRegistryService: func(_ service.RegistryService) {
@@ -129,7 +129,7 @@ func TestPublishEndpoint(t *testing.T) {
129129
requestBody: apiv0.ServerJSON{
130130
Name: "test-server",
131131
Description: "A test server",
132-
Version: "1.0.0",
132+
Version: "1.0.0",
133133
},
134134
authHeader: "Bearer invalidToken",
135135
setupRegistryService: func(_ service.RegistryService) {
@@ -143,7 +143,7 @@ func TestPublishEndpoint(t *testing.T) {
143143
requestBody: apiv0.ServerJSON{
144144
Name: "io.github.other/test-server",
145145
Description: "A test server",
146-
Version: "1.0.0",
146+
Version: "1.0.0",
147147
Repository: model.Repository{
148148
URL: "https://github.com/example/test-server",
149149
Source: "github",
@@ -167,7 +167,7 @@ func TestPublishEndpoint(t *testing.T) {
167167
requestBody: apiv0.ServerJSON{
168168
Name: "example/test-server",
169169
Description: "A test server",
170-
Version: "1.0.0",
170+
Version: "1.0.0",
171171
Repository: model.Repository{
172172
URL: "https://github.com/example/test-server",
173173
Source: "github",
@@ -185,7 +185,7 @@ func TestPublishEndpoint(t *testing.T) {
185185
existingServer := apiv0.ServerJSON{
186186
Name: "example/test-server",
187187
Description: "Existing test server",
188-
Version: "1.0.0",
188+
Version: "1.0.0",
189189
Repository: model.Repository{
190190
URL: "https://github.com/example/test-server-existing",
191191
Source: "github",
@@ -202,7 +202,7 @@ func TestPublishEndpoint(t *testing.T) {
202202
requestBody: apiv0.ServerJSON{
203203
Name: "com.example/test-server-mcpb",
204204
Description: "A test server with MCPB package",
205-
Version: "1.0.0",
205+
Version: "1.0.0",
206206
Packages: []model.Package{
207207
{
208208
RegistryType: model.RegistryTypeMCPB,

internal/api/server.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ func TrailingSlashMiddleware(next http.Handler) http.Handler {
2323
// Create a copy of the URL and remove the trailing slash
2424
newURL := *r.URL
2525
newURL.Path = strings.TrimSuffix(r.URL.Path, "/")
26-
26+
2727
// Use 308 Permanent Redirect to preserve the request method
2828
http.Redirect(w, r, newURL.String(), http.StatusPermanentRedirect)
2929
return
3030
}
31-
31+
3232
next.ServeHTTP(w, r)
3333
})
3434
}

internal/auth/jwt_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -300,9 +300,9 @@ func TestJWTManager_BlockedNamespaces(t *testing.T) {
300300
originalBlocked := auth.BlockedNamespaces
301301
auth.BlockedNamespaces = []string{"io.github.spammer"}
302302
defer func() { auth.BlockedNamespaces = originalBlocked }()
303-
303+
304304
jwtManager := auth.NewJWTManager(cfg)
305-
305+
306306
claims := auth.JWTClaims{
307307
AuthMethod: auth.MethodGitHubAT,
308308
AuthMethodSubject: "spammer",
@@ -325,9 +325,9 @@ func TestJWTManager_BlockedNamespaces(t *testing.T) {
325325
originalBlocked := auth.BlockedNamespaces
326326
auth.BlockedNamespaces = []string{"io.github.spammer"}
327327
defer func() { auth.BlockedNamespaces = originalBlocked }()
328-
328+
329329
jwtManager := auth.NewJWTManager(cfg)
330-
330+
331331
claims := auth.JWTClaims{
332332
AuthMethod: auth.MethodGitHubAT,
333333
AuthMethodSubject: "gooduser",
@@ -349,9 +349,9 @@ func TestJWTManager_BlockedNamespaces(t *testing.T) {
349349
originalBlocked := auth.BlockedNamespaces
350350
auth.BlockedNamespaces = []string{"io.github.badorg"}
351351
defer func() { auth.BlockedNamespaces = originalBlocked }()
352-
352+
353353
jwtManager := auth.NewJWTManager(cfg)
354-
354+
355355
claims := auth.JWTClaims{
356356
AuthMethod: auth.MethodGitHubAT,
357357
AuthMethodSubject: "user",
@@ -378,9 +378,9 @@ func TestJWTManager_BlockedNamespaces(t *testing.T) {
378378
originalBlocked := auth.BlockedNamespaces
379379
auth.BlockedNamespaces = []string{"io.github.spammer"}
380380
defer func() { auth.BlockedNamespaces = originalBlocked }()
381-
381+
382382
jwtManager := auth.NewJWTManager(cfg)
383-
383+
384384
claims := auth.JWTClaims{
385385
AuthMethod: auth.MethodNone,
386386
AuthMethodSubject: "admin",

internal/service/registry_service_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func TestValidateNoDuplicateRemoteURLs(t *testing.T) {
1818
"existing1": {
1919
Name: "com.example/existing-server",
2020
Description: "An existing server",
21-
Version: "1.0.0",
21+
Version: "1.0.0",
2222
Remotes: []model.Transport{
2323
{Type: "streamable-http", URL: "https://api.example.com/mcp"},
2424
{Type: "sse", URL: "https://webhook.example.com/sse"},
@@ -27,7 +27,7 @@ func TestValidateNoDuplicateRemoteURLs(t *testing.T) {
2727
"existing2": {
2828
Name: "com.microsoft/another-server",
2929
Description: "Another existing server",
30-
Version: "1.0.0",
30+
Version: "1.0.0",
3131
Remotes: []model.Transport{
3232
{Type: "streamable-http", URL: "https://api.microsoft.com/mcp"},
3333
},
@@ -55,8 +55,8 @@ func TestValidateNoDuplicateRemoteURLs(t *testing.T) {
5555
serverDetail: apiv0.ServerJSON{
5656
Name: "com.example/new-server",
5757
Description: "A new server with no remotes",
58-
Version: "1.0.0",
59-
Remotes: []model.Transport{},
58+
Version: "1.0.0",
59+
Remotes: []model.Transport{},
6060
},
6161
expectError: false,
6262
},
@@ -65,7 +65,7 @@ func TestValidateNoDuplicateRemoteURLs(t *testing.T) {
6565
serverDetail: apiv0.ServerJSON{
6666
Name: "com.example/new-server",
6767
Description: "A new server",
68-
Version: "1.0.0",
68+
Version: "1.0.0",
6969
Remotes: []model.Transport{
7070
{Type: "streamable-http", URL: "https://new.example.com/mcp"},
7171
{Type: "sse", URL: "https://unique.example.com/sse"},
@@ -78,7 +78,7 @@ func TestValidateNoDuplicateRemoteURLs(t *testing.T) {
7878
serverDetail: apiv0.ServerJSON{
7979
Name: "com.example/new-server",
8080
Description: "A new server with duplicate URL",
81-
Version: "1.0.0",
81+
Version: "1.0.0",
8282
Remotes: []model.Transport{
8383
{Type: "streamable-http", URL: "https://api.example.com/mcp"}, // This URL already exists
8484
},
@@ -91,7 +91,7 @@ func TestValidateNoDuplicateRemoteURLs(t *testing.T) {
9191
serverDetail: apiv0.ServerJSON{
9292
Name: "com.example/existing-server", // Same name as existing
9393
Description: "Updated existing server",
94-
Version: "1.1.0",
94+
Version: "1.1.0",
9595
Remotes: []model.Transport{
9696
{Type: "streamable-http", URL: "https://api.example.com/mcp"}, // Same URL as before
9797
},

internal/validators/utils.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func HasNoSpaces(s string) bool {
3535
func extractTemplateVariables(url string) []string {
3636
re := regexp.MustCompile(`\{([^}]+)\}`)
3737
matches := re.FindAllStringSubmatch(url, -1)
38-
38+
3939
var variables []string
4040
for _, match := range matches {
4141
if len(match) > 1 {
@@ -55,24 +55,24 @@ func replaceTemplateVariables(rawURL string) string {
5555
"{protocol}": "http",
5656
"{scheme}": "http",
5757
}
58-
58+
5959
result := rawURL
6060
for placeholder, replacement := range templateReplacements {
6161
result = strings.ReplaceAll(result, placeholder, replacement)
6262
}
63-
63+
6464
// Handle any remaining {variable} patterns with generic placeholder
6565
re := regexp.MustCompile(`\{[^}]+\}`)
6666
result = re.ReplaceAllString(result, "placeholder")
67-
67+
6868
return result
6969
}
7070

7171
// IsValidURL checks if a URL is in valid format (basic structure validation)
7272
func IsValidURL(rawURL string) bool {
7373
// Replace template variables with placeholders for parsing
7474
testURL := replaceTemplateVariables(rawURL)
75-
75+
7676
// Parse the URL
7777
u, err := url.Parse(testURL)
7878
if err != nil {
@@ -131,19 +131,19 @@ func IsValidRemoteURL(rawURL string) bool {
131131
if !IsValidURL(rawURL) {
132132
return false
133133
}
134-
134+
135135
// Parse the URL to check for localhost restriction
136136
u, err := url.Parse(rawURL)
137137
if err != nil {
138138
return false
139139
}
140-
140+
141141
// Reject localhost URLs for remotes (security/production concerns)
142142
hostname := u.Hostname()
143143
if hostname == "localhost" || hostname == "127.0.0.1" || strings.HasSuffix(hostname, ".localhost") {
144144
return false
145145
}
146-
146+
147147
return true
148148
}
149149

@@ -155,31 +155,31 @@ func IsValidTemplatedURL(rawURL string, availableVariables []string, allowTempla
155155
if !IsValidURL(rawURL) {
156156
return false
157157
}
158-
158+
159159
// Extract template variables from URL
160160
templateVars := extractTemplateVariables(rawURL)
161-
161+
162162
// If no templates are found, it's a valid static URL
163163
if len(templateVars) == 0 {
164164
return true
165165
}
166-
166+
167167
// If templates are not allowed (e.g., for remotes), reject URLs with templates
168168
if !allowTemplates {
169169
return false
170170
}
171-
171+
172172
// Validate that all template variables are available
173173
availableSet := make(map[string]bool)
174174
for _, v := range availableVariables {
175175
availableSet[v] = true
176176
}
177-
177+
178178
for _, templateVar := range templateVars {
179179
if !availableSet[templateVar] {
180180
return false
181181
}
182182
}
183-
183+
184184
return true
185185
}

0 commit comments

Comments
 (0)