Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions internal/validators/registries/npm.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"net/http"
"net/url"
"time"

"github.com/modelcontextprotocol/registry/pkg/model"
Expand Down Expand Up @@ -42,8 +43,8 @@ func ValidateNPM(ctx context.Context, pkg model.Package, serverName string) erro

client := &http.Client{Timeout: 10 * time.Second}

url := pkg.RegistryBaseURL + "/" + pkg.Identifier + "/" + pkg.Version
req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
requestURL := pkg.RegistryBaseURL + "/" + url.PathEscape(pkg.Identifier) + "/" + url.PathEscape(pkg.Version)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, requestURL, nil)
if err != nil {
return fmt.Errorf("failed to create request: %w", err)
}
Expand Down
23 changes: 23 additions & 0 deletions internal/validators/registries/npm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,29 @@ func TestValidateNPM_RealPackages(t *testing.T) {
serverName: "io.github.domdomegg/airtable-mcp-server",
expectError: false,
},
{
name: "scoped package that doesn't exist should fail",
packageName: "@nonexistent-scope/nonexistent-package",
version: "1.0.0",
serverName: "com.example/test",
expectError: true,
errorMessage: "not found",
},
{
name: "scoped package without mcpName should fail",
packageName: "@types/node",
version: "20.0.0",
serverName: "com.example/test",
expectError: true,
errorMessage: "missing required 'mcpName' field",
},
{
name: "scoped package with mcpName should pass",
packageName: "@hellocoop/admin-mcp",
version: "1.5.7",
serverName: "io.github.hellocoop/admin-mcp",
expectError: false,
},
}

for _, tt := range tests {
Expand Down
Loading