feat: add admin edit endpoint for server moderation (#315)

## Summary

Implements `PUT /v0/servers/{id}` admin edit endpoint to address part of
issue #182, providing an API-based solution for server moderation
without requiring direct database access.

- **New endpoint**: `PUT /v0/servers/{id}` for editing existing servers
- **Security**: Uses existing JWT auth with `PermissionActionEdit`
permissions
- **Anti-undelete protection**: Added `ServerStatusDeleted` status that
cannot be reverted
- **Full implementation**: Database, service, API, and comprehensive
test coverage

## Key Use Cases

- Mark malicious servers as `deleted` for takedown
- Update server metadata for moderation actions

Related to: https://github.com/modelcontextprotocol/registry/issues/182
(but that is not _done_ yet because we need admins to be able to login
(probably with #283), and need to add docs on how to do the takedown,
and probably guidelines on what we will/won't takedown)
This commit is contained in:
adam jones 2025-08-27 21:28:04 +01:00 • committed by GitHub
commit 6431f23107
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -31,10 +31,9 @@ const (
type ServerStatus string
const (
// ServerStatusActive represents an actively maintained server (as asserted by the publisher)
ServerStatusActive ServerStatus = "active"
// ServerStatusDeprecated represents a server that is no longer actively maintained
ServerStatusActive ServerStatus = "active"
ServerStatusDeprecated ServerStatus = "deprecated"
ServerStatusDeleted ServerStatus = "deleted"
)
// Repository represents a source code repository as defined in the spec
@ -91,17 +90,17 @@ type Argument struct {
type Package struct {
// RegistryType indicates how to download packages (e.g., "npm", "pypi", "docker-hub", "mcpb")
RegistryType string `json:"registry_type,omitempty" bson:"registry_type,omitempty"`
RegistryType string `json:"registry_type,omitempty" bson:"registry_type,omitempty"`
// RegistryBaseURL is the base URL of the package registry
RegistryBaseURL string `json:"registry_base_url,omitempty" bson:"registry_base_url,omitempty"`
RegistryBaseURL string `json:"registry_base_url,omitempty" bson:"registry_base_url,omitempty"`
// Identifier is the package identifier - either a package name (for registries) or URL (for direct downloads)
Identifier string `json:"identifier,omitempty" bson:"identifier,omitempty"`
Version string `json:"version,omitempty" bson:"version,omitempty"`
FileSHA256 string `json:"file_sha256,omitempty" bson:"file_sha256,omitempty"`
RunTimeHint string `json:"runtime_hint,omitempty" bson:"runtime_hint,omitempty"`
RuntimeArguments []Argument `json:"runtime_arguments,omitempty" bson:"runtime_arguments,omitempty"`
PackageArguments []Argument `json:"package_arguments,omitempty" bson:"package_arguments,omitempty"`
EnvironmentVariables []KeyValueInput `json:"environment_variables,omitempty" bson:"environment_variables,omitempty"`
Identifier string `json:"identifier,omitempty" bson:"identifier,omitempty"`
Version string `json:"version,omitempty" bson:"version,omitempty"`
FileSHA256 string `json:"file_sha256,omitempty" bson:"file_sha256,omitempty"`
RunTimeHint string `json:"runtime_hint,omitempty" bson:"runtime_hint,omitempty"`
RuntimeArguments []Argument `json:"runtime_arguments,omitempty" bson:"runtime_arguments,omitempty"`
PackageArguments []Argument `json:"package_arguments,omitempty" bson:"package_arguments,omitempty"`
EnvironmentVariables []KeyValueInput `json:"environment_variables,omitempty" bson:"environment_variables,omitempty"`
}
// Remote represents a remote connection endpoint