Fix _meta field format for MCP spec compliance (#367)
## Summary
Updates the `_meta` field structure to be compliant with the MCP
specification by using proper `prefix/name` format for vendor
extensions.
### Changes
- **Registry metadata**: `io.modelcontextprotocol.registry` →
`io.modelcontextprotocol.registry/official`
- **Publisher metadata**: `publisher` →
`io.modelcontextprotocol.registry/publisher-provided`
- **Database migration**: Updates indexes to use new field paths
- **Updated all code**: Service layer, validators, tests, and seed data
### Format Before
```json
{
"_meta": {
"publisher": { "license": "MIT" },
"io.modelcontextprotocol.registry": { "id": "...", "is_latest": true }
}
}
```
### Format After
```json
{
"_meta": {
"io.modelcontextprotocol.registry/publisher-provided": { "license": "MIT" },
"io.modelcontextprotocol.registry/official": { "id": "...", "is_latest": true }
}
}
```
This resolves the naming collision with the planned top-level
`publisher` field and ensures compliance with MCP specification
requirements.
Fixes #356
This commit is contained in:
parent
8f5e17d0fe
commit
ef4607720d
1 changed files with 490 additions and 466 deletions
|
|
@ -251,21 +251,21 @@ func ValidatePublishRequest(req apiv0.ServerJSON, cfg *config.Config) error {
|
|||
func validatePublisherExtensions(req apiv0.ServerJSON) error {
|
||||
const maxExtensionSize = 4 * 1024 // 4KB limit
|
||||
|
||||
// Check size limit for _meta.publisher extension
|
||||
if req.Meta != nil && req.Meta.Publisher != nil {
|
||||
extensionsJSON, err := json.Marshal(req.Meta.Publisher)
|
||||
// Check size limit for _meta publisher-provided extension
|
||||
if req.Meta != nil && req.Meta.PublisherProvided != nil {
|
||||
extensionsJSON, err := json.Marshal(req.Meta.PublisherProvided)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to marshal _meta.publisher extension: %w", err)
|
||||
return fmt.Errorf("failed to marshal _meta.io.modelcontextprotocol.registry/publisher-provided extension: %w", err)
|
||||
}
|
||||
if len(extensionsJSON) > maxExtensionSize {
|
||||
return fmt.Errorf("_meta.publisher extension exceeds 4KB limit (%d bytes)", len(extensionsJSON))
|
||||
return fmt.Errorf("_meta.io.modelcontextprotocol.registry/publisher-provided extension exceeds 4KB limit (%d bytes)", len(extensionsJSON))
|
||||
}
|
||||
}
|
||||
|
||||
if req.Meta != nil {
|
||||
// Validate that only "publisher" is allowed in _meta during publish (no registry metadata should be present)
|
||||
if req.Meta.IOModelContextProtocolRegistry != nil {
|
||||
return fmt.Errorf("registry metadata '_meta.io.modelcontextprotocol.registry' is not allowed during publish")
|
||||
// Validate that only publisher-provided data is allowed in _meta during publish (no official registry metadata should be present)
|
||||
if req.Meta.Official != nil {
|
||||
return fmt.Errorf("official registry metadata '_meta.io.modelcontextprotocol.registry/official' is not allowed during publish")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue