Publisher-managed "deleted" support (#893)

(Updated auto-generated PR description from @tadasant / Claude on Feb
22, 2026)

## Motivation and Context

Fixes #637

Server lifecycle management (deprecation and yanking) is a standard
requirement for package registries. Use cases like rebranding, security
vulnerabilities, and end-of-life servers demand the ability to mark
servers as deprecated or deleted, with optional messaging to guide
consumers toward alternatives.

## Changes

### New API endpoints

- **`PATCH /v0/servers/{serverName}/versions/{version}/status`** —
Update the lifecycle status of a single server version
- **`PATCH /v0/servers/{serverName}/status`** — Update the lifecycle
status of all versions of a server in a single transaction

Both endpoints accept:
```json
{
  "status": "active|deprecated|deleted",
  "statusMessage": "Optional message (max 500 chars) explaining the change"
}
```

### New CLI command

- **`mcp-publisher status <serverName> [version]`** — Update server
lifecycle status from the command line
  - `--status` (required): `active`, `deprecated`, or `deleted`
  - `--message`: Optional status message
- `--all-versions`: Apply to all versions of the server (replaces the
`<version>` argument)

### API response changes

`RegistryExtensions` now includes two new fields:
- `statusChangedAt` — Timestamp of the last status change
- `statusMessage` — Optional free-form message (e.g., deprecation
reason, migration guidance)

### List endpoint changes

- New `include_deleted` query parameter on `GET /v0/servers` — defaults
to `false`, hiding deleted servers from listings
- When `updated_since` is provided, `include_deleted` is automatically
set to `true` for incremental sync

### Database

- Migration `013_add_status_fields.sql`: Adds `status_changed_at` (NOT
NULL, initialized from `published_at`) and `status_message` columns to
the `servers` table

### Design decisions (from review discussion)

- **Dedicated status endpoints** rather than overloading the existing
edit endpoint
- **Bidirectional status transitions** — all transitions between
`active`, `deprecated`, and `deleted` are allowed
- **`statusMessage` as free-form text** — no structured `nextName` or
`alternativeUrl` fields (per maintainer feedback, to avoid complexity
around chaining, trust transfer, etc.)
- **Publish permission** grants status change access (not limited to
admin/edit)
- **Status message auto-cleared** when transitioning back to `active`
Good, now I have the full picture. Here's the addendum:

### Consumer-facing API changes

The new status fields live inside
`_meta["io.modelcontextprotocol.registry/official"]` on every
`ServerResponse`. This is the existing `RegistryExtensions` object — two
new fields are added alongside the existing ones:

**Before:**
```json
{
  "server": { "name": "com.example/my-server", "...": "..." },
  "_meta": {
    "io.modelcontextprotocol.registry/official": {
      "status": "active",
      "publishedAt": "2025-06-01T00:00:00Z",
      "updatedAt": "2025-06-15T00:00:00Z",
      "isLatest": true
    }
  }
}
```

**After:**
```json
{
  "server": { "name": "com.example/my-server", "...": "..." },
  "_meta": {
    "io.modelcontextprotocol.registry/official": {
      "status": "deprecated",
      "statusChangedAt": "2026-02-01T12:00:00Z",
      "statusMessage": "Deprecated in favor of com.example/my-server-v2",
      "publishedAt": "2025-06-01T00:00:00Z",
      "updatedAt": "2026-02-01T12:00:00Z",
      "isLatest": true
    }
  }
}
```

| New field | Type | Present when |
|-----------|------|-------------|
| `statusChangedAt` | `string` (RFC3339) | Always — initialized to
`publishedAt` for existing records |
| `statusMessage` | `string` (max 500 chars) | Only when set —
`null`/omitted for active servers (auto-cleared on transition to active)
|

These fields appear on **every endpoint that returns a
`ServerResponse`**: `GET /v0/servers`, `GET /v0/servers/{name}`, `GET
/v0/servers/{name}/versions/{version}`, and the new PATCH status
endpoints.

### List endpoint filtering

`GET /v0/servers` gains an `include_deleted` query parameter:

| Scenario | Behavior |
|----------|----------|
| No `include_deleted` param | Deleted servers hidden (default `false`)
|
| `include_deleted=true` | Deleted servers included in results |
| `updated_since` provided | `include_deleted` forced to `true` for
incremental sync |

## How Has This Been Tested?

- Unit tests for status handler (`status_test.go`) covering status
transitions, permission checks, validation errors, and the all-versions
endpoint
- Unit tests for the CLI command (`status_test.go`)
- Integration with existing server/edit handler tests
- Database layer tests for the new status update and query methods
- Tested locally with `make dev-compose`

## Types of changes

- [x] New feature (non-breaking change which adds functionality)

## Checklist

- [x] I have read the [MCP
Documentation](https://modelcontextprotocol.io)
- [x] My code follows the repository's style guidelines
- [x] New and existing tests pass locally
- [x] I have added appropriate error handling
- [x] I have added or updated documentation as needed

## Open items from review

- [ ] `include_deleted` silent override: When `updated_since` is
provided and `include_deleted=false` is explicitly passed, should return
a 400 error rather than silently overriding
([thread](https://github.com/modelcontextprotocol/registry/pull/893#discussion_r2100879360))
— agreed upon but may not yet be implemented
This commit is contained in:
Preeti Dewani 2026-02-27 22:30:07 +05:30 • committed by GitHub
commit bb84ea69e8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -71,25 +71,6 @@ func TestEditServerEndpoint(t *testing.T) {
require.NoError(t, err)
}
// Create a deleted server for undelete testing
deletedServer := &apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "io.github.testuser/deleted-server",
Description: "Server that was deleted",
Version: "1.0.0",
Repository: &model.Repository{
URL: "https://github.com/testuser/deleted-server",
Source: "github",
ID: "testuser/deleted-server",
},
}
_, err = registryService.CreateServer(context.Background(), deletedServer)
require.NoError(t, err)
// Set the server to deleted status
_, err = registryService.UpdateServer(context.Background(), deletedServer.Name, deletedServer.Version, deletedServer, stringPtr(string(model.StatusDeleted)))
require.NoError(t, err)
// Create a server with build metadata for URL encoding test
buildMetadataServer := &apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
@ -112,7 +93,6 @@ func TestEditServerEndpoint(t *testing.T) {
authClaims *auth.JWTClaims
authHeader string
requestBody apiv0.ServerJSON
statusParam string
expectedStatus int
expectedError string
checkResult func(*testing.T, *apiv0.ServerResponse)
@ -148,31 +128,6 @@ func TestEditServerEndpoint(t *testing.T) {
assert.NotNil(t, resp.Meta.Official)
},
},
{
name: "successful edit with status change",
serverName: "io.github.testuser/editable-server",
version: "1.0.0",
authClaims: &auth.JWTClaims{
AuthMethod: auth.MethodGitHubAT,
AuthMethodSubject: "testuser",
Permissions: []auth.Permission{
{Action: auth.PermissionActionEdit, ResourcePattern: "io.github.testuser/*"},
},
},
requestBody: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "io.github.testuser/editable-server",
Description: "Server with status change",
Version: "1.0.0",
},
statusParam: "deprecated",
expectedStatus: http.StatusOK,
checkResult: func(t *testing.T, resp *apiv0.ServerResponse) {
t.Helper()
assert.Equal(t, "Server with status change", resp.Server.Description)
assert.Equal(t, model.StatusDeprecated, resp.Meta.Official.Status)
},
},
{
name: "missing authorization header",
serverName: "io.github.testuser/editable-server",
@ -310,27 +265,6 @@ func TestEditServerEndpoint(t *testing.T) {
expectedStatus: http.StatusBadRequest,
expectedError: "Version in request body must match URL path parameter",
},
{
name: "attempt to undelete server should fail",
serverName: "io.github.testuser/deleted-server",
version: "1.0.0",
authClaims: &auth.JWTClaims{
AuthMethod: auth.MethodGitHubAT,
AuthMethodSubject: "testuser",
Permissions: []auth.Permission{
{Action: auth.PermissionActionEdit, ResourcePattern: "io.github.testuser/*"},
},
},
requestBody: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "io.github.testuser/deleted-server",
Description: "Trying to undelete server",
Version: "1.0.0",
},
statusParam: "active", // Trying to change from deleted to active
expectedStatus: http.StatusBadRequest,
expectedError: "Cannot change status of deleted server",
},
{
name: "successful edit of version with build metadata (URL encoded)",
serverName: "io.github.testuser/build-metadata-server",
@ -381,9 +315,6 @@ func TestEditServerEndpoint(t *testing.T) {
encodedServerName := url.PathEscape(tc.serverName)
encodedVersion := url.PathEscape(tc.version)
requestURL := "/v0/servers/" + encodedServerName + "/versions/" + encodedVersion
if tc.statusParam != "" {
requestURL += "?status=" + tc.statusParam
}
req := httptest.NewRequest(http.MethodPut, requestURL, bytes.NewReader(requestBody))
req.Header.Set("Content-Type", "application/json")
@ -404,6 +335,9 @@ func TestEditServerEndpoint(t *testing.T) {
mux.ServeHTTP(w, req)
// Check response
if tc.expectedStatus != w.Code {
t.Logf("Response body: %s", w.Body.String())
}
assert.Equal(t, tc.expectedStatus, w.Code)
if tc.expectedError != "" {
@ -437,12 +371,10 @@ func TestEditServerEndpointEdgeCases(t *testing.T) {
testServers := []struct {
name string
version string
status model.Status
}{
{"com.example/active-server", "1.0.0", model.StatusActive},
{"com.example/deprecated-server", "1.0.0", model.StatusDeprecated},
{"com.example/multi-version-server", "1.0.0", model.StatusActive},
{"com.example/multi-version-server", "2.0.0", model.StatusActive},
{"com.example/active-server", "1.0.0"},
{"com.example/multi-version-server", "1.0.0"},
{"com.example/multi-version-server", "2.0.0"},
}
for _, server := range testServers {
@ -453,17 +385,6 @@ func TestEditServerEndpointEdgeCases(t *testing.T) {
Version: server.version,
})
require.NoError(t, err)
// Set specific status if not active
if server.status != model.StatusActive {
_, err = registryService.UpdateServer(context.Background(), server.name, server.version, &apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: server.name,
Description: "Test server for editing",
Version: server.version,
}, stringPtr(string(server.status)))
require.NoError(t, err)
}
}
// Create API
@ -471,95 +392,6 @@ func TestEditServerEndpointEdgeCases(t *testing.T) {
api := humago.New(mux, huma.DefaultConfig("Test API", "1.0.0"))
v0.RegisterEditEndpoints(api, "/v0", registryService, cfg)
t.Run("status transitions", func(t *testing.T) {
tests := []struct {
name string
serverName string
version string
fromStatus string
toStatus string
expectedStatus int
expectedError string
}{
{
name: "active to deprecated",
serverName: "com.example/active-server",
version: "1.0.0",
toStatus: "deprecated",
expectedStatus: http.StatusOK,
},
{
name: "deprecated to active",
serverName: "com.example/deprecated-server",
version: "1.0.0",
toStatus: "active",
expectedStatus: http.StatusOK,
},
{
name: "active to deleted",
serverName: "com.example/active-server",
version: "1.0.0",
toStatus: "deleted",
expectedStatus: http.StatusOK,
},
{
name: "invalid status",
serverName: "com.example/active-server",
version: "1.0.0",
toStatus: "invalid_status",
expectedStatus: http.StatusUnprocessableEntity,
expectedError: "validation failed",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
requestBody := apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: tt.serverName,
Description: "Status transition test",
Version: tt.version,
}
bodyBytes, err := json.Marshal(requestBody)
require.NoError(t, err)
encodedName := url.PathEscape(tt.serverName)
requestURL := "/v0/servers/" + encodedName + "/versions/" + tt.version + "?status=" + tt.toStatus
req := httptest.NewRequest(http.MethodPut, requestURL, bytes.NewReader(bodyBytes))
req.Header.Set("Content-Type", "application/json")
// Generate admin token
jwtManager := auth.NewJWTManager(cfg)
tokenResponse, err := jwtManager.GenerateTokenResponse(context.Background(), auth.JWTClaims{
AuthMethod: auth.MethodNone,
Permissions: []auth.Permission{
{Action: auth.PermissionActionEdit, ResourcePattern: "*"},
},
})
require.NoError(t, err)
req.Header.Set("Authorization", "Bearer "+tokenResponse.RegistryToken)
w := httptest.NewRecorder()
mux.ServeHTTP(w, req)
assert.Equal(t, tt.expectedStatus, w.Code)
if tt.expectedError != "" {
assert.Contains(t, w.Body.String(), tt.expectedError)
}
if tt.expectedStatus == http.StatusOK {
var response apiv0.ServerResponse
err := json.NewDecoder(w.Body).Decode(&response)
require.NoError(t, err)
assert.Equal(t, model.Status(tt.toStatus), response.Meta.Official.Status)
}
})
}
})
t.Run("URL encoding edge cases", func(t *testing.T) {
// Create server with special characters
specialServerName := "io.dots.and-dashes/server_with_underscores"
@ -651,13 +483,70 @@ func TestEditServerEndpointEdgeCases(t *testing.T) {
assert.Equal(t, "1.0.0", response.Server.Version)
// Verify the other version wasn't affected
otherVersion, err := registryService.GetServerByNameAndVersion(context.Background(), "com.example/multi-version-server", "2.0.0")
otherVersion, err := registryService.GetServerByNameAndVersion(context.Background(), "com.example/multi-version-server", "2.0.0", false)
require.NoError(t, err)
assert.NotEqual(t, "Updated v1.0.0 specifically", otherVersion.Server.Description)
})
}
// Helper function
func stringPtr(s string) *string {
return &s
t.Run("edit preserves status metadata", func(t *testing.T) {
// Create a server and set it to deprecated using the service directly
deprecatedServer := &apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/deprecated-for-edit-test",
Description: "Server to test edit preserves status",
Version: "1.0.0",
}
_, err := registryService.CreateServer(context.Background(), deprecatedServer)
require.NoError(t, err)
// Set to deprecated status using UpdateServerStatus
statusMsg := "This server is deprecated"
_, err = registryService.UpdateServerStatus(context.Background(), deprecatedServer.Name, deprecatedServer.Version, &service.StatusChangeRequest{
NewStatus: model.StatusDeprecated,
StatusMessage: &statusMsg,
})
require.NoError(t, err)
// Now edit the server description
requestBody := apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/deprecated-for-edit-test",
Description: "Updated description but status should remain deprecated",
Version: "1.0.0",
}
bodyBytes, err := json.Marshal(requestBody)
require.NoError(t, err)
encodedName := url.PathEscape("com.example/deprecated-for-edit-test")
requestURL := "/v0/servers/" + encodedName + "/versions/1.0.0"
req := httptest.NewRequest(http.MethodPut, requestURL, bytes.NewReader(bodyBytes))
req.Header.Set("Content-Type", "application/json")
jwtManager := auth.NewJWTManager(cfg)
tokenResponse, err := jwtManager.GenerateTokenResponse(context.Background(), auth.JWTClaims{
AuthMethod: auth.MethodNone,
Permissions: []auth.Permission{
{Action: auth.PermissionActionEdit, ResourcePattern: "*"},
},
})
require.NoError(t, err)
req.Header.Set("Authorization", "Bearer "+tokenResponse.RegistryToken)
w := httptest.NewRecorder()
mux.ServeHTTP(w, req)
assert.Equal(t, http.StatusOK, w.Code)
var response apiv0.ServerResponse
err = json.NewDecoder(w.Body).Decode(&response)
require.NoError(t, err)
assert.Equal(t, "Updated description but status should remain deprecated", response.Server.Description)
// Status should still be deprecated
assert.Equal(t, model.StatusDeprecated, response.Meta.Official.Status)
// Status message should be preserved
assert.NotNil(t, response.Meta.Official.StatusMessage)
assert.Equal(t, "This server is deprecated", *response.Meta.Official.StatusMessage)
})
}