Allow for vendor extensions on servers (#298)

<!-- Provide a brief summary of your changes -->
This PR serves as a placeholder and brings together all of the changes
related to supporting vendor extensions passed through the API. The idea
is to have a single place to track and review the work as it comes
together (even if it’s still a bit of a work in progress).

**The changes in this PR cover:**
* Updates on the data model
* Updates on both databases (in-memory and postgresql), added a new
table to PSQL for tracking the extensions leaving the server table only
for the clean server.json properties
* Updates the seed.json file (thus the big line change)
* Adds a seed-migrate tool to help migrating an existing seed file to
the new format
* Updates the seed import mechanism to support this
* Updates the existing tests - unit, integration and validation tests
* Adds the publish handler to the OpenAPI spec (it was missing)
* Fixes linting errors
* Updates on the API side on (publish, list, get) to support the new
format of `ServerResponse` -
```
{
  "server": {},
  "x-io.modelcontextprotocol.registry": {}, /*not available for publish since this gets populated by the registry*/
  "x-publisher": {}
}
```

## Motivation and Context
<!-- Why is this change needed? What problem does it solve? -->
Motivated by the discussions in:
https://github.com/modelcontextprotocol/registry/discussions/284

## How Has This Been Tested?
<!-- Have you tested this in a real application? Which scenarios were
tested? -->
Locally and by running all of the tests

## Breaking Changes
<!-- Will users need to update their code or configurations? -->
Yes, it changes both the API and the format of the seed file
 
## 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)
- [ ] New feature (non-breaking change which adds functionality)
- [x] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Documentation update

---

Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
Co-authored-by: adam jones <domdomegg+git@gmail.com>
This commit is contained in:
Radoslav Dimitrov 2025-08-23 11:59:03 +03:00 • committed by GitHub
commit 8d7e471fd3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 19980 additions and 15589 deletions

View file

@ -2,6 +2,7 @@ package v0
import (
"context"
"encoding/json"
"net/http"
"strings"
@ -15,7 +16,7 @@ import (
// PublishServerInput represents the input for publishing a server
type PublishServerInput struct {
Authorization string `header:"Authorization" doc:"Registry JWT token (obtained from /v0/auth/token/github)" required:"true"`
Body model.PublishRequest
RawBody []byte `body:"raw"`
}
// RegisterPublishEndpoint registers the publish endpoint
@ -33,7 +34,7 @@ func RegisterPublishEndpoint(api huma.API, registry service.RegistryService, cfg
Security: []map[string][]string{
{"bearer": {}},
},
}, func(ctx context.Context, input *PublishServerInput) (*Response[model.Server], error) {
}, func(ctx context.Context, input *PublishServerInput) (*Response[model.ServerResponse], error) {
// Extract bearer token
const bearerPrefix = "Bearer "
authHeader := input.Authorization
@ -48,30 +49,34 @@ func RegisterPublishEndpoint(api huma.API, registry service.RegistryService, cfg
return nil, huma.Error401Unauthorized("Invalid or expired Registry JWT token", err)
}
// Convert PublishRequest body to ServerDetail
serverDetail := input.Body.ServerDetail
// Validate that only allowed extension fields are present
if err := model.ValidatePublishRequestExtensions(input.RawBody); err != nil {
return nil, huma.Error400BadRequest("Invalid request format", err)
}
// Parse the validated request body
var publishRequest model.PublishRequest
if err := json.Unmarshal(input.RawBody, &publishRequest); err != nil {
return nil, huma.Error400BadRequest("Invalid JSON format", err)
}
// Get server details from request body
serverDetail := publishRequest.Server
// Verify that the token's repository matches the server being published
if !jwtManager.HasPermission(serverDetail.Name, auth.PermissionActionPublish, claims.Permissions) {
return nil, huma.Error403Forbidden("You do not have permission to publish this server")
}
// Publish the server details
err = registry.Publish(&serverDetail)
// Publish the server with extensions
publishedServer, err := registry.Publish(publishRequest)
if err != nil {
return nil, huma.Error500InternalServerError("Failed to publish server", err)
}
// Create response with the published server data
return &Response[model.Server]{
Body: model.Server{
ID: serverDetail.ID,
Name: serverDetail.Name,
Description: serverDetail.Description,
Status: serverDetail.Status,
Repository: serverDetail.Repository,
VersionDetail: serverDetail.VersionDetail,
},
// Return the published server in extension wrapper format
return &Response[model.ServerResponse]{
Body: *publishedServer,
}, nil
})
}

View file

@ -54,20 +54,17 @@ func TestPublishIntegration(t *testing.T) {
t.Run("successful publish with GitHub auth", func(t *testing.T) {
publishReq := model.PublishRequest{
ServerDetail: model.ServerDetail{
Server: model.Server{
Name: "io.github.testuser/test-mcp-server",
Description: "A test MCP server for integration testing",
Repository: model.Repository{
URL: "https://github.com/testuser/test-mcp-server",
Source: "github",
ID: "testuser/test-mcp-server",
},
VersionDetail: model.VersionDetail{
Version: "1.0.0",
},
Server: model.ServerDetail{
Name: "io.github.testuser/test-mcp-server",
Description: "A test MCP server for integration testing",
Repository: model.Repository{
URL: "https://github.com/testuser/test-mcp-server",
Source: "github",
ID: "testuser/test-mcp-server",
},
VersionDetail: model.VersionDetail{
Version: "1.0.0",
},
// Packages field removed as it depends on the actual model.Package structure
},
}
@ -94,28 +91,26 @@ func TestPublishIntegration(t *testing.T) {
assert.Equal(t, http.StatusOK, rr.Code)
var response model.Server
var response model.ServerResponse
err = json.Unmarshal(rr.Body.Bytes(), &response)
require.NoError(t, err)
assert.Equal(t, publishReq.Name, response.Name)
assert.Equal(t, publishReq.VersionDetail.Version, response.VersionDetail.Version)
assert.Equal(t, publishReq.Server.Name, response.Server.Name)
assert.Equal(t, publishReq.Server.VersionDetail.Version, response.Server.VersionDetail.Version)
})
t.Run("successful publish without auth (no prefix)", func(t *testing.T) {
publishReq := model.PublishRequest{
ServerDetail: model.ServerDetail{
Server: model.Server{
Name: "test-mcp-server-no-auth",
Description: "A test MCP server without authentication",
Repository: model.Repository{
URL: "https://example.com/test-mcp-server",
Source: "example",
ID: "test-mcp-server",
},
VersionDetail: model.VersionDetail{
Version: "1.0.0",
},
Server: model.ServerDetail{
Name: "test-mcp-server-no-auth",
Description: "A test MCP server without authentication",
Repository: model.Repository{
URL: "https://example.com/test-mcp-server",
Source: "example",
ID: "test-mcp-server",
},
VersionDetail: model.VersionDetail{
Version: "1.0.0",
},
},
}
@ -142,19 +137,17 @@ func TestPublishIntegration(t *testing.T) {
assert.Equal(t, http.StatusOK, rr.Code)
var response model.Server
var response model.ServerResponse
err = json.Unmarshal(rr.Body.Bytes(), &response)
require.NoError(t, err)
assert.Equal(t, publishReq.Name, response.Name)
assert.Equal(t, publishReq.Server.Name, response.Server.Name)
})
t.Run("publish fails with missing authorization header", func(t *testing.T) {
publishReq := model.PublishRequest{
ServerDetail: model.ServerDetail{
Server: model.Server{
Name: "test-server",
},
Server: model.ServerDetail{
Name: "test-server",
},
}
@ -174,10 +167,8 @@ func TestPublishIntegration(t *testing.T) {
t.Run("publish fails with invalid token", func(t *testing.T) {
publishReq := model.PublishRequest{
ServerDetail: model.ServerDetail{
Server: model.Server{
Name: "test-server",
},
Server: model.ServerDetail{
Name: "test-server",
},
}
@ -197,13 +188,11 @@ func TestPublishIntegration(t *testing.T) {
t.Run("publish fails when permission denied", func(t *testing.T) {
publishReq := model.PublishRequest{
ServerDetail: model.ServerDetail{
Server: model.Server{
Name: "io.github.other/test-server",
Description: "A test server",
VersionDetail: model.VersionDetail{
Version: "1.0.0",
},
Server: model.ServerDetail{
Name: "io.github.other/test-server",
Description: "A test server",
VersionDetail: model.VersionDetail{
Version: "1.0.0",
},
},
}

View file

@ -28,22 +28,25 @@ type MockRegistryService struct {
mock.Mock
}
func (m *MockRegistryService) List(cursor string, limit int) ([]model.Server, string, error) {
func (m *MockRegistryService) List(cursor string, limit int) ([]model.ServerResponse, string, error) {
args := m.Called(cursor, limit)
return args.Get(0).([]model.Server), args.String(1), args.Error(2)
return args.Get(0).([]model.ServerResponse), args.String(1), args.Error(2)
}
func (m *MockRegistryService) GetByID(id string) (*model.ServerDetail, error) {
func (m *MockRegistryService) GetByID(id string) (*model.ServerResponse, error) {
args := m.Called(id)
if args.Get(0) == nil {
return nil, args.Error(1)
}
return args.Get(0).(*model.ServerDetail), args.Error(1)
return args.Get(0).(*model.ServerResponse), args.Error(1)
}
func (m *MockRegistryService) Publish(serverDetail *model.ServerDetail) error {
args := m.Called(serverDetail)
return args.Error(0)
func (m *MockRegistryService) Publish(request model.PublishRequest) (*model.ServerResponse, error) {
args := m.Called(request)
if args.Get(0) == nil {
return nil, args.Error(1)
}
return args.Get(0).(*model.ServerResponse), args.Error(1)
}
// Helper function to generate a valid JWT token for testing
@ -77,21 +80,16 @@ func TestPublishEndpoint(t *testing.T) {
{
name: "successful publish with GitHub auth",
requestBody: model.PublishRequest{
ServerDetail: model.ServerDetail{
Server: model.Server{
ID: "test-id",
Name: "io.github.example/test-server",
Description: "A test server",
Repository: model.Repository{
URL: "https://github.com/example/test-server",
Source: "github",
ID: "example/test-server",
},
VersionDetail: model.VersionDetail{
Version: "1.0.0",
ReleaseDate: "2025-05-25T00:00:00Z",
IsLatest: true,
},
Server: model.ServerDetail{
Name: "io.github.example/test-server",
Description: "A test server",
Repository: model.Repository{
URL: "https://github.com/example/test-server",
Source: "github",
ID: "example/test-server",
},
VersionDetail: model.VersionDetail{
Version: "1.0.0",
},
},
},
@ -103,28 +101,23 @@ func TestPublishEndpoint(t *testing.T) {
},
},
setupMocks: func(registry *MockRegistryService) {
registry.On("Publish", mock.AnythingOfType("*model.ServerDetail")).Return(nil)
registry.On("Publish", mock.AnythingOfType("model.PublishRequest")).Return(&model.ServerResponse{}, nil)
},
expectedStatus: http.StatusOK,
},
{
name: "successful publish with no auth (AuthMethodNone)",
requestBody: model.PublishRequest{
ServerDetail: model.ServerDetail{
Server: model.Server{
ID: "test-id-2",
Name: "example/test-server",
Description: "A test server without auth",
Repository: model.Repository{
URL: "https://example.com/test-server",
Source: "example",
ID: "example/test-server",
},
VersionDetail: model.VersionDetail{
Version: "1.0.0",
ReleaseDate: "2025-05-25T00:00:00Z",
IsLatest: true,
},
Server: model.ServerDetail{
Name: "example/test-server",
Description: "A test server without auth",
Repository: model.Repository{
URL: "https://example.com/test-server",
Source: "example",
ID: "example/test-server",
},
VersionDetail: model.VersionDetail{
Version: "1.0.0",
},
},
},
@ -135,7 +128,7 @@ func TestPublishEndpoint(t *testing.T) {
},
},
setupMocks: func(registry *MockRegistryService) {
registry.On("Publish", mock.AnythingOfType("*model.ServerDetail")).Return(nil)
registry.On("Publish", mock.AnythingOfType("model.PublishRequest")).Return(&model.ServerResponse{}, nil)
},
expectedStatus: http.StatusOK,
},
@ -158,13 +151,11 @@ func TestPublishEndpoint(t *testing.T) {
{
name: "invalid token",
requestBody: model.PublishRequest{
ServerDetail: model.ServerDetail{
Server: model.Server{
Name: "test-server",
Description: "A test server",
VersionDetail: model.VersionDetail{
Version: "1.0.0",
},
Server: model.ServerDetail{
Name: "test-server",
Description: "A test server",
VersionDetail: model.VersionDetail{
Version: "1.0.0",
},
},
},
@ -176,13 +167,11 @@ func TestPublishEndpoint(t *testing.T) {
{
name: "permission denied",
requestBody: model.PublishRequest{
ServerDetail: model.ServerDetail{
Server: model.Server{
Name: "io.github.other/test-server",
Description: "A test server",
VersionDetail: model.VersionDetail{
Version: "1.0.0",
},
Server: model.ServerDetail{
Name: "io.github.other/test-server",
Description: "A test server",
VersionDetail: model.VersionDetail{
Version: "1.0.0",
},
},
},
@ -199,13 +188,11 @@ func TestPublishEndpoint(t *testing.T) {
{
name: "registry service error",
requestBody: model.PublishRequest{
ServerDetail: model.ServerDetail{
Server: model.Server{
Name: "example/test-server",
Description: "A test server",
VersionDetail: model.VersionDetail{
Version: "1.0.0",
},
Server: model.ServerDetail{
Name: "example/test-server",
Description: "A test server",
VersionDetail: model.VersionDetail{
Version: "1.0.0",
},
},
},
@ -216,7 +203,7 @@ func TestPublishEndpoint(t *testing.T) {
},
},
setupMocks: func(registry *MockRegistryService) {
registry.On("Publish", mock.AnythingOfType("*model.ServerDetail")).Return(errors.New("database error"))
registry.On("Publish", mock.AnythingOfType("model.PublishRequest")).Return(nil, errors.New("database error"))
},
expectedStatus: http.StatusInternalServerError,
expectedError: "Failed to publish server",

View file

@ -25,8 +25,8 @@ type ListServersInput struct {
// ListServersBody represents the paginated server list response body
type ListServersBody struct {
Servers []model.Server `json:"servers" doc:"List of MCP servers"`
Metadata *Metadata `json:"metadata,omitempty" doc:"Pagination metadata"`
Servers []model.ServerResponse `json:"servers" doc:"List of MCP servers with extensions"`
Metadata *Metadata `json:"metadata,omitempty" doc:"Pagination metadata"`
}
// ServerDetailInput represents the input for getting server details
@ -85,7 +85,7 @@ func RegisterServersEndpoints(api huma.API, registry service.RegistryService) {
Summary: "Get MCP server details",
Description: "Get detailed information about a specific MCP server",
Tags: []string{"servers"},
}, func(_ context.Context, input *ServerDetailInput) (*Response[model.ServerDetail], error) {
}, func(_ context.Context, input *ServerDetailInput) (*Response[model.ServerResponse], error) {
// Get the server details from the registry service
serverDetail, err := registry.GetByID(input.ID)
if err != nil {
@ -95,7 +95,7 @@ func RegisterServersEndpoints(api huma.API, registry service.RegistryService) {
return nil, huma.Error500InternalServerError("Failed to get server details", err)
}
return &Response[model.ServerDetail]{
return &Response[model.ServerResponse]{
Body: *serverDetail,
}, nil
})

View file

@ -23,16 +23,55 @@ func TestServersListEndpoint(t *testing.T) {
queryParams string
setupMocks func(*MockRegistryService)
expectedStatus int
expectedServers []model.Server
expectedServers []model.ServerResponse
expectedMeta *v0.Metadata
expectedError string
}{
{
name: "successful list with default parameters",
setupMocks: func(registry *MockRegistryService) {
servers := []model.Server{
servers := []model.ServerResponse{
{
ID: "550e8400-e29b-41d4-a716-446655440001",
Server: model.ServerDetail{
Name: "test-server-1",
Description: "First test server",
Repository: model.Repository{
URL: "https://github.com/example/test-server-1",
Source: "github",
ID: "example/test-server-1",
},
VersionDetail: model.VersionDetail{
Version: "1.0.0",
},
},
XIOModelContextProtocolRegistry: map[string]interface{}{
"id": "550e8400-e29b-41d4-a716-446655440001",
},
},
{
Server: model.ServerDetail{
Name: "test-server-2",
Description: "Second test server",
Repository: model.Repository{
URL: "https://github.com/example/test-server-2",
Source: "github",
ID: "example/test-server-2",
},
VersionDetail: model.VersionDetail{
Version: "2.0.0",
},
},
XIOModelContextProtocolRegistry: map[string]interface{}{
"id": "550e8400-e29b-41d4-a716-446655440002",
},
},
}
registry.Mock.On("List", "", 30).Return(servers, "", nil)
},
expectedStatus: http.StatusOK,
expectedServers: []model.ServerResponse{
{
Server: model.ServerDetail{
Name: "test-server-1",
Description: "First test server",
Repository: model.Repository{
@ -41,13 +80,15 @@ func TestServersListEndpoint(t *testing.T) {
ID: "example/test-server-1",
},
VersionDetail: model.VersionDetail{
Version: "1.0.0",
ReleaseDate: "2025-05-25T00:00:00Z",
IsLatest: true,
Version: "1.0.0",
},
},
{
ID: "550e8400-e29b-41d4-a716-446655440002",
XIOModelContextProtocolRegistry: map[string]interface{}{
"id": "550e8400-e29b-41d4-a716-446655440001",
},
},
{
Server: model.ServerDetail{
Name: "test-server-2",
Description: "Second test server",
Repository: model.Repository{
@ -56,44 +97,11 @@ func TestServersListEndpoint(t *testing.T) {
ID: "example/test-server-2",
},
VersionDetail: model.VersionDetail{
Version: "2.0.0",
ReleaseDate: "2025-05-26T00:00:00Z",
IsLatest: true,
Version: "2.0.0",
},
},
}
registry.Mock.On("List", "", 30).Return(servers, "", nil)
},
expectedStatus: http.StatusOK,
expectedServers: []model.Server{
{
ID: "550e8400-e29b-41d4-a716-446655440001",
Name: "test-server-1",
Description: "First test server",
Repository: model.Repository{
URL: "https://github.com/example/test-server-1",
Source: "github",
ID: "example/test-server-1",
},
VersionDetail: model.VersionDetail{
Version: "1.0.0",
ReleaseDate: "2025-05-25T00:00:00Z",
IsLatest: true,
},
},
{
ID: "550e8400-e29b-41d4-a716-446655440002",
Name: "test-server-2",
Description: "Second test server",
Repository: model.Repository{
URL: "https://github.com/example/test-server-2",
Source: "github",
ID: "example/test-server-2",
},
VersionDetail: model.VersionDetail{
Version: "2.0.0",
ReleaseDate: "2025-05-26T00:00:00Z",
IsLatest: true,
XIOModelContextProtocolRegistry: map[string]interface{}{
"id": "550e8400-e29b-41d4-a716-446655440002",
},
},
},
@ -102,9 +110,32 @@ func TestServersListEndpoint(t *testing.T) {
name: "successful list with cursor and limit",
queryParams: "?cursor=550e8400-e29b-41d4-a716-446655440000&limit=10",
setupMocks: func(registry *MockRegistryService) {
servers := []model.Server{
servers := []model.ServerResponse{
{
ID: "550e8400-e29b-41d4-a716-446655440003",
Server: model.ServerDetail{
Name: "test-server-3",
Description: "Third test server",
Repository: model.Repository{
URL: "https://github.com/example/test-server-3",
Source: "github",
ID: "example/test-server-3",
},
VersionDetail: model.VersionDetail{
Version: "1.5.0",
},
},
XIOModelContextProtocolRegistry: map[string]interface{}{
"id": "550e8400-e29b-41d4-a716-446655440003",
},
},
}
nextCursor := uuid.New().String()
registry.Mock.On("List", mock.AnythingOfType("string"), 10).Return(servers, nextCursor, nil)
},
expectedStatus: http.StatusOK,
expectedServers: []model.ServerResponse{
{
Server: model.ServerDetail{
Name: "test-server-3",
Description: "Third test server",
Repository: model.Repository{
@ -113,30 +144,11 @@ func TestServersListEndpoint(t *testing.T) {
ID: "example/test-server-3",
},
VersionDetail: model.VersionDetail{
Version: "1.5.0",
ReleaseDate: "2025-05-27T00:00:00Z",
IsLatest: true,
Version: "1.5.0",
},
},
}
nextCursor := uuid.New().String()
registry.Mock.On("List", mock.AnythingOfType("string"), 10).Return(servers, nextCursor, nil)
},
expectedStatus: http.StatusOK,
expectedServers: []model.Server{
{
ID: "550e8400-e29b-41d4-a716-446655440003",
Name: "test-server-3",
Description: "Third test server",
Repository: model.Repository{
URL: "https://github.com/example/test-server-3",
Source: "github",
ID: "example/test-server-3",
},
VersionDetail: model.VersionDetail{
Version: "1.5.0",
ReleaseDate: "2025-05-27T00:00:00Z",
IsLatest: true,
XIOModelContextProtocolRegistry: map[string]interface{}{
"id": "550e8400-e29b-41d4-a716-446655440003",
},
},
},
@ -183,7 +195,7 @@ func TestServersListEndpoint(t *testing.T) {
{
name: "registry service error",
setupMocks: func(registry *MockRegistryService) {
registry.Mock.On("List", "", 30).Return([]model.Server{}, "", errors.New("database connection error"))
registry.Mock.On("List", "", 30).Return([]model.ServerResponse{}, "", errors.New("database connection error"))
},
expectedStatus: http.StatusInternalServerError,
expectedError: "Failed to get registry list",
@ -220,8 +232,8 @@ func TestServersListEndpoint(t *testing.T) {
// Parse response body
var resp struct {
Servers []model.Server `json:"servers"`
Metadata *v0.Metadata `json:"metadata,omitempty"`
Servers []model.ServerResponse `json:"servers"`
Metadata *v0.Metadata `json:"metadata,omitempty"`
}
err := json.NewDecoder(w.Body).Decode(&resp)
assert.NoError(t, err)
@ -255,16 +267,15 @@ func TestServersDetailEndpoint(t *testing.T) {
serverID string
setupMocks func(*MockRegistryService, string)
expectedStatus int
expectedServer *model.ServerDetail
expectedServer *model.ServerResponse
expectedError string
}{
{
name: "successful get server detail",
serverID: uuid.New().String(),
setupMocks: func(registry *MockRegistryService, serverID string) {
serverDetail := &model.ServerDetail{
Server: model.Server{
ID: serverID,
serverDetail := &model.ServerResponse{
Server: model.ServerDetail{
Name: "test-server-detail",
Description: "Test server detail",
Repository: model.Repository{
@ -273,11 +284,12 @@ func TestServersDetailEndpoint(t *testing.T) {
ID: "example/test-server-detail",
},
VersionDetail: model.VersionDetail{
Version: "2.0.0",
ReleaseDate: "2025-05-27T12:00:00Z",
IsLatest: true,
Version: "2.0.0",
},
},
XIOModelContextProtocolRegistry: map[string]interface{}{
"id": serverID,
},
}
registry.Mock.On("GetByID", serverID).Return(serverDetail, nil)
},
@ -339,13 +351,12 @@ func TestServersDetailEndpoint(t *testing.T) {
assert.Equal(t, "application/json", w.Header().Get("Content-Type"))
// Parse response body
var serverDetailResp model.ServerDetail
var serverDetailResp model.ServerResponse
err := json.NewDecoder(w.Body).Decode(&serverDetailResp)
assert.NoError(t, err)
// Check that we got a valid response
assert.NotEmpty(t, serverDetailResp.ID)
assert.NotEmpty(t, serverDetailResp.Name)
assert.NotEmpty(t, serverDetailResp.Server.Name)
} else if tc.expectedError != "" {
// Check error message for non-200 responses
assert.Contains(t, w.Body.String(), tc.expectedError)
@ -364,26 +375,29 @@ func TestServersEndpointsIntegration(t *testing.T) {
// Test data
serverID := uuid.New().String()
servers := []model.Server{
servers := []model.ServerResponse{
{
ID: serverID,
Name: "integration-test-server",
Description: "Integration test server",
Repository: model.Repository{
URL: "https://github.com/example/integration-test",
Source: "github",
ID: "example/integration-test",
Server: model.ServerDetail{
Name: "integration-test-server",
Description: "Integration test server",
Repository: model.Repository{
URL: "https://github.com/example/integration-test",
Source: "github",
ID: "example/integration-test",
},
VersionDetail: model.VersionDetail{
Version: "1.0.0",
},
},
VersionDetail: model.VersionDetail{
Version: "1.0.0",
ReleaseDate: "2025-05-27T00:00:00Z",
IsLatest: true,
XIOModelContextProtocolRegistry: map[string]interface{}{
"id": serverID,
},
},
}
serverDetail := &model.ServerDetail{
Server: servers[0],
serverDetail := &model.ServerResponse{
Server: servers[0].Server,
XIOModelContextProtocolRegistry: servers[0].XIOModelContextProtocolRegistry,
}
// Setup mocks
@ -424,7 +438,7 @@ func TestServersEndpointsIntegration(t *testing.T) {
// Parse response body
var listResp struct {
Servers []model.Server `json:"servers"`
Servers []model.ServerResponse `json:"servers"`
}
err = json.NewDecoder(resp.Body).Decode(&listResp)
assert.NoError(t, err)
@ -455,7 +469,7 @@ func TestServersEndpointsIntegration(t *testing.T) {
assert.Equal(t, "application/json", resp.Header.Get("Content-Type"))
// Parse response body
var serverDetailResp model.ServerDetail
var serverDetailResp model.ServerResponse
err = json.NewDecoder(resp.Body).Decode(&serverDetailResp)
assert.NoError(t, err)
@ -465,4 +479,4 @@ func TestServersEndpointsIntegration(t *testing.T) {
// Verify mock expectations
mockRegistry.AssertExpectations(t)
}
}

View file

@ -19,9 +19,8 @@ import (
)
func mockServerEndpoint(registry *MockRegistryService, serverID string) {
serverDetail := &model.ServerDetail{
Server: model.Server{
ID: serverID,
serverDetail := &model.ServerResponse{
Server: model.ServerDetail{
Name: "test-server-detail",
Description: "Test server detail",
Repository: model.Repository{
@ -30,11 +29,12 @@ func mockServerEndpoint(registry *MockRegistryService, serverID string) {
ID: "example/test-server-detail",
},
VersionDetail: model.VersionDetail{
Version: "2.0.0",
ReleaseDate: "2025-05-27T12:00:00Z",
IsLatest: true,
Version: "2.0.0",
},
},
XIOModelContextProtocolRegistry: map[string]interface{}{
"id": serverID,
},
}
registry.Mock.On("GetByID", serverID).Return(serverDetail, nil)
}