Skip to content

Commit 2ee6e00

Browse files
feat: add PackageLocation
1 parent 212bccd commit 2ee6e00

File tree

7 files changed

+134
-47
lines changed

7 files changed

+134
-47
lines changed

docs/server-json/examples.md

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,10 @@ The `dnx` tool ships with the .NET 10 SDK, starting with Preview 6.
228228
},
229229
"packages": [
230230
{
231-
"registry_name": "nuget",
232-
"name": "Knapcode.SampleMcpServer",
231+
"location": {
232+
"registry_name": "nuget",
233+
"name": "Knapcode.SampleMcpServer"
234+
},
233235
"version": "0.5.0",
234236
"runtime_hint": "dnx",
235237
"environment_variables": [
@@ -261,8 +263,10 @@ The `dnx` tool ships with the .NET 10 SDK, starting with Preview 6.
261263
},
262264
"packages": [
263265
{
264-
"registry_name": "docker",
265-
"name": "mcp/database-manager",
266+
"location": {
267+
"registry_name": "docker",
268+
"name": "mcp/database-manager"
269+
},
266270
"version": "3.1.0",
267271
"runtime_arguments": [
268272
{
@@ -347,8 +351,10 @@ The `dnx` tool ships with the .NET 10 SDK, starting with Preview 6.
347351
},
348352
"packages": [
349353
{
350-
"registry_name": "npm",
351-
"name": "@example/hybrid-mcp-server",
354+
"location": {
355+
"registry_name": "npm",
356+
"name": "@example/hybrid-mcp-server"
357+
},
352358
"version": "1.5.0",
353359
"runtime_hint": "npx",
354360
"package_arguments": [
@@ -405,8 +411,10 @@ The `dnx` tool ships with the .NET 10 SDK, starting with Preview 6.
405411
},
406412
"packages": [
407413
{
408-
"registry_name": "mcpb",
409-
"name": "https://github.com/modelcontextprotocol/text-editor-mcpb/releases/download/v1.0.2/text-editor.mcpb",
414+
"location": {
415+
"type": "mcpb",
416+
"url": "https://github.com/modelcontextprotocol/text-editor-mcpb/releases/download/v1.0.2/text-editor.mcpb"
417+
},
410418
"version": "1.0.2",
411419
"file_hashes": {
412420
"sha-256": "fe333e598595000ae021bd27117db32ec69af6987f507ba7a63c90638ff633ce"
@@ -438,8 +446,10 @@ This example shows an MCPB (MCP Bundle) package that:
438446
},
439447
"packages": [
440448
{
441-
"registry_name": "npm",
442-
"name": "@legacy/old-weather-server",
449+
"location": {
450+
"registry_name": "npm",
451+
"name": "@legacy/old-weather-server"
452+
},
443453
"version": "0.9.5",
444454
"environment_variables": [
445455
{

docs/server-json/schema.json

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,23 +74,52 @@
7474
}
7575
}
7676
},
77+
"PackageLocation": {
78+
"type": "object",
79+
"oneOf": [
80+
{
81+
"type": "object",
82+
"required": ["registry_name", "name"],
83+
"properties": {
84+
"registry_name": {
85+
"type": "string",
86+
"description": "Package registry type",
87+
"example": "npm"
88+
},
89+
"name": {
90+
"type": "string",
91+
"description": "Package name in the registry",
92+
"example": "@modelcontextprotocol/server-filesystem"
93+
}
94+
}
95+
},
96+
{
97+
"type": "object",
98+
"required": ["type", "url"],
99+
"properties": {
100+
"type": {
101+
"type": "string",
102+
"enum": ["mcpb"],
103+
"description": "Package location type for direct URL references"
104+
},
105+
"url": {
106+
"type": "string",
107+
"format": "uri",
108+
"description": "Direct URL to the package file",
109+
"example": "https://github.com/modelcontextprotocol/text-editor-mcpb/releases/download/v1.0.2/text-editor.mcpb"
110+
}
111+
}
112+
}
113+
]
114+
},
77115
"Package": {
78116
"type": "object",
79117
"required": [
80-
"registry_name",
81-
"name",
82-
"version"
118+
"location"
83119
],
84120
"properties": {
85-
"registry_name": {
86-
"type": "string",
87-
"description": "Package registry type",
88-
"example": "npm"
89-
},
90-
"name": {
91-
"type": "string",
92-
"description": "Package name in the registry",
93-
"example": "io.modelcontextprotocol/filesystem"
121+
"location": {
122+
"$ref": "#/$defs/PackageLocation"
94123
},
95124
"version": {
96125
"type": "string",

docs/server-registry-api/openapi.yaml

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -166,21 +166,44 @@ components:
166166
description: Number of items in current page
167167
example: 30
168168

169+
PackageLocation:
170+
type: object
171+
oneOf:
172+
- type: object
173+
required:
174+
- registry_name
175+
- name
176+
properties:
177+
registry_name:
178+
type: string
179+
description: Package registry type
180+
example: "npm"
181+
name:
182+
type: string
183+
description: Package name in the registry
184+
example: "@modelcontextprotocol/server-filesystem"
185+
- type: object
186+
required:
187+
- type
188+
- url
189+
properties:
190+
type:
191+
type: string
192+
enum: ["mcpb"]
193+
description: Package location type for direct URL references
194+
url:
195+
type: string
196+
format: uri
197+
description: Direct URL to the package file
198+
example: "https://github.com/modelcontextprotocol/text-editor-mcpb/releases/download/v1.0.2/text-editor.mcpb"
199+
169200
Package:
170201
type: object
171202
required:
172-
- registry_name
173-
- name
174-
- version
203+
- location
175204
properties:
176-
registry_name:
177-
type: string
178-
description: Package registry type
179-
example: "npm"
180-
name:
181-
type: string
182-
description: Package name in the registry
183-
example: "io.modelcontextprotocol/filesystem"
205+
location:
206+
$ref: '#/components/schemas/PackageLocation'
184207
version:
185208
type: string
186209
description: Package version

internal/model/model.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,20 @@ type Argument struct {
8686
ValueHint string `json:"value_hint,omitempty" bson:"value_hint,omitempty"`
8787
}
8888

89+
// PackageLocation represents the location of a package
90+
type PackageLocation struct {
91+
// For registry-based packages
92+
RegistryName string `json:"registry_name,omitempty" bson:"registry_name,omitempty"`
93+
Name string `json:"name,omitempty" bson:"name,omitempty"`
94+
95+
// For direct URL packages (e.g., MCPB)
96+
Type string `json:"type,omitempty" bson:"type,omitempty"`
97+
URL string `json:"url,omitempty" bson:"url,omitempty"`
98+
}
99+
89100
type Package struct {
90-
RegistryName string `json:"registry_name" bson:"registry_name"`
91-
Name string `json:"name" bson:"name"`
92-
Version string `json:"version" bson:"version"`
101+
Location PackageLocation `json:"location" bson:"location"`
102+
Version string `json:"version,omitempty" bson:"version,omitempty"`
93103
FileHashes map[string]string `json:"file_hashes,omitempty" bson:"file_hashes,omitempty"`
94104
RunTimeHint string `json:"runtime_hint,omitempty" bson:"runtime_hint,omitempty"`
95105
RuntimeArguments []Argument `json:"runtime_arguments,omitempty" bson:"runtime_arguments,omitempty"`

internal/service/registry_service.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func (s *registryServiceImpl) GetByID(id string) (*model.ServerDetail, error) {
9090
// validateMCPBPackage validates MCPB packages to ensure they meet requirements
9191
func validateMCPBPackage(pkg *model.Package) error {
9292
// Validate that the URL is from an allowlisted host
93-
parsedURL, err := url.Parse(pkg.Name)
93+
parsedURL, err := url.Parse(pkg.Location.URL)
9494
if err != nil {
9595
return fmt.Errorf("invalid MCPB package URL: %w", err)
9696
}
@@ -144,7 +144,7 @@ func (s *registryServiceImpl) Publish(serverDetail *model.ServerDetail) error {
144144

145145
// Validate MCPB packages
146146
for _, pkg := range serverDetail.Packages {
147-
if strings.ToLower(pkg.RegistryName) == "mcpb" {
147+
if strings.ToLower(pkg.Location.Type) == "mcpb" {
148148
if err := validateMCPBPackage(&pkg); err != nil {
149149
return fmt.Errorf("validation failed: %w", err)
150150
}

tools/publisher/main.go

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,19 @@ type RuntimeArgument struct {
4141
ValueHint string `json:"value_hint"`
4242
}
4343

44+
type PackageLocation struct {
45+
// For registry-based packages
46+
RegistryName string `json:"registry_name,omitempty"`
47+
Name string `json:"name,omitempty"`
48+
49+
// For direct URL packages (e.g., MCPB)
50+
Type string `json:"type,omitempty"`
51+
URL string `json:"url,omitempty"`
52+
}
53+
4454
type Package struct {
45-
RegistryName string `json:"registry_name"`
46-
Name string `json:"name"`
47-
Version string `json:"version"`
55+
Location PackageLocation `json:"location"`
56+
Version string `json:"version,omitempty"`
4857
RuntimeHint string `json:"runtime_hint,omitempty"`
4958
RuntimeArguments []RuntimeArgument `json:"runtime_arguments,omitempty"`
5059
PackageArguments []RuntimeArgument `json:"package_arguments,omitempty"`
@@ -451,8 +460,10 @@ func createServerStructure(
451460

452461
// Create package
453462
pkg := Package{
454-
RegistryName: registryName,
455-
Name: packageName,
463+
Location: PackageLocation{
464+
RegistryName: registryName,
465+
Name: packageName,
466+
},
456467
Version: packageVersion,
457468
RuntimeHint: runtimeHint,
458469
RuntimeArguments: runtimeArguments,

tools/publisher/server.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
"status": "active",
55
"packages": [
66
{
7-
"registry_name": "npm",
8-
"name": "io.github.<owner>/<server-name>",
7+
"location": {
8+
"registry_name": "npm",
9+
"name": "io.github.<owner>/<server-name>"
10+
},
911
"version": "0.2.23",
1012
"package_arguments": [
1113
{
@@ -25,8 +27,10 @@
2527
}
2628
]
2729
},{
28-
"registry_name": "docker",
29-
"name": "io.github.<owner>/<server-name>-cli",
30+
"location": {
31+
"registry_name": "docker",
32+
"name": "io.github.<owner>/<server-name>-cli"
33+
},
3034
"version": "0.123.223",
3135
"runtime_hint": "docker",
3236
"runtime_arguments": [

0 commit comments

Comments
 (0)