feat: Add support for MCP Bundles (MCPB) in registry (#295)

## Motivation and Context
- Add MCPB as a new registry_name option
- Add file_hashes field to package model for integrity verification
- Implement URL validation restricting MCPB packages to GitHub/GitLab
hosts
- Require SHA-256 hash for all MCPB packages
- Add example MCPB package in documentation
- Update schemas and OpenAPI specification

See issue #260

## How Has This Been Tested?
<!-- Have you tested this in a real application? Which scenarios were
tested? -->

## Breaking Changes
N/A, registry has not yet been launched

## Types of changes
<!-- What types of changes does your code introduce? Put an `x` in all
the boxes that apply: -->
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Documentation update

## Checklist
<!-- Go over all the following points, and put an `x` in all the boxes
that apply. -->
- [x] I have read the [MCP
Documentation](https://modelcontextprotocol.io)
- [ ] My code follows the repository's style guidelines
- [ ] New and existing tests pass locally
- [ ] I have added appropriate error handling
- [x] I have added or updated documentation as needed

---------

Co-authored-by: Adam Jones <adamj+git@anthropic.com>
This commit is contained in:
joan-anthropic 2025-08-26 20:44:53 -07:00 • committed by GitHub
commit 57efb58143
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -98,6 +98,14 @@ func TestReadSeedFile_RegistryURL(t *testing.T) {
Server: model.ServerDetail{
Name: "Test Server 1",
Description: "First test server",
Packages: []model.Package{
{
RegistryType: "npm",
RegistryBaseURL: "https://registry.npmjs.org",
Identifier: "test-package-1",
Version: "1.0.0",
},
},
},
XIOModelContextProtocolRegistry: map[string]interface{}{
"id": "server-1",
@ -109,6 +117,14 @@ func TestReadSeedFile_RegistryURL(t *testing.T) {
Server: model.ServerDetail{
Name: "Test Server 2",
Description: "Second test server",
Packages: []model.Package{
{
RegistryType: "npm",
RegistryBaseURL: "https://registry.npmjs.org",
Identifier: "test-package-2",
Version: "2.0.0",
},
},
},
XIOModelContextProtocolRegistry: map[string]interface{}{
"id": "server-2",
@ -118,24 +134,26 @@ func TestReadSeedFile_RegistryURL(t *testing.T) {
}
serverDetail1 := model.ServerDetail{
Name: "Test Server 1",
Name: "Test Server 1",
Description: "First test server",
Packages: []model.Package{
{
RegistryName: "npm",
Name: "test-package-1",
Version: "1.0.0",
RegistryType: "npm",
RegistryBaseURL: "https://registry.npmjs.org",
Identifier: "test-package-1",
Version: "1.0.0",
},
},
}
serverDetail2 := model.ServerDetail{
Name: "Test Server 2",
Name: "Test Server 2",
Description: "Second test server",
Packages: []model.Package{
{
RegistryName: "npm",
Name: "test-package-2",
Version: "2.0.0",
RegistryType: "npm",
RegistryBaseURL: "https://registry.npmjs.org",
Identifier: "test-package-2",
Version: "2.0.0",
},
},
}
@ -177,6 +195,12 @@ func TestReadSeedFile_RegistryURL(t *testing.T) {
// No NextCursor means end of pagination
},
}
default:
// No more pages
response = PaginatedResponse{
Servers: []model.ServerResponse{},
Metadata: &Metadata{},
}
}
w.Header().Set("Content-Type", "application/json")
@ -212,6 +236,16 @@ func TestReadSeedFile_RegistryURL(t *testing.T) {
assert.Equal(t, "Test Server 1", result[0].ServerJSON.Name)
assert.Equal(t, "Test Server 2", result[1].ServerJSON.Name)
// Verify packages were imported with new schema
assert.Len(t, result[0].ServerJSON.Packages, 1)
assert.Equal(t, "npm", result[0].ServerJSON.Packages[0].RegistryType)
assert.Equal(t, "https://registry.npmjs.org", result[0].ServerJSON.Packages[0].RegistryBaseURL)
assert.Equal(t, "test-package-1", result[0].ServerJSON.Packages[0].Identifier)
assert.Len(t, result[1].ServerJSON.Packages, 1)
assert.Equal(t, "npm", result[1].ServerJSON.Packages[0].RegistryType)
assert.Equal(t, "https://registry.npmjs.org", result[1].ServerJSON.Packages[0].RegistryBaseURL)
assert.Equal(t, "test-package-2", result[1].ServerJSON.Packages[0].Identifier)
// Verify metadata was extracted
assert.Equal(t, "server-1", result[0].RegistryMetadata.ID)
assert.Equal(t, "server-2", result[1].RegistryMetadata.ID)