@@ -13,54 +13,11 @@ import (
13
13
"os"
14
14
"strings"
15
15
16
+ "github.com/modelcontextprotocol/registry/internal/model"
16
17
"github.com/modelcontextprotocol/registry/tools/publisher/auth"
17
18
"github.com/modelcontextprotocol/registry/tools/publisher/auth/github"
18
19
)
19
20
20
- // Server structure types for JSON generation
21
- type Repository struct {
22
- URL string `json:"url"`
23
- Source string `json:"source"`
24
- }
25
-
26
- type VersionDetail struct {
27
- Version string `json:"version"`
28
- }
29
-
30
- type EnvironmentVariable struct {
31
- Name string `json:"name"`
32
- Description string `json:"description"`
33
- }
34
-
35
- type RuntimeArgument struct {
36
- Description string `json:"description"`
37
- IsRequired bool `json:"is_required"`
38
- Format string `json:"format"`
39
- Value string `json:"value"`
40
- Default string `json:"default"`
41
- Type string `json:"type"`
42
- ValueHint string `json:"value_hint"`
43
- }
44
-
45
- type Package struct {
46
- RegistryName string `json:"registry_name"`
47
- Name string `json:"name"`
48
- Version string `json:"version"`
49
- RuntimeHint string `json:"runtime_hint,omitempty"`
50
- RuntimeArguments []RuntimeArgument `json:"runtime_arguments,omitempty"`
51
- PackageArguments []RuntimeArgument `json:"package_arguments,omitempty"`
52
- EnvironmentVariables []EnvironmentVariable `json:"environment_variables,omitempty"`
53
- }
54
-
55
- type ServerJSON struct {
56
- Name string `json:"name"`
57
- Description string `json:"description"`
58
- Status string `json:"status,omitempty"`
59
- Repository Repository `json:"repository"`
60
- VersionDetail VersionDetail `json:"version_detail"`
61
- Packages []Package `json:"packages"`
62
- }
63
-
64
21
func main () {
65
22
if len (os .Args ) < 2 {
66
23
printUsage ()
@@ -361,27 +318,29 @@ func publishToRegistry(registryURL string, mcpData []byte, token string) error {
361
318
}
362
319
363
320
func createServerStructure (name , description , version , repoURL , repoSource , registryName ,
364
- packageName , packageVersion , runtimeHint , execute string , envVars []string , packageArgs []string , status string ) ServerJSON {
321
+ packageName , packageVersion , runtimeHint , execute string , envVars []string , packageArgs []string , status string ) model. ServerDetail {
365
322
// Parse environment variables
366
- var environmentVariables []EnvironmentVariable
323
+ var environmentVariables []model. KeyValueInput
367
324
for _ , envVar := range envVars {
368
325
parts := strings .SplitN (envVar , ":" , 2 )
326
+ envVarName := parts [0 ]
327
+ envVarDesc := fmt .Sprintf ("Environment variable for %s" , parts [0 ])
369
328
if len (parts ) == 2 {
370
- environmentVariables = append (environmentVariables , EnvironmentVariable {
371
- Name : parts [0 ],
372
- Description : parts [1 ],
373
- })
374
- } else {
375
- // If no description provided, use a default
376
- environmentVariables = append (environmentVariables , EnvironmentVariable {
377
- Name : parts [0 ],
378
- Description : fmt .Sprintf ("Environment variable for %s" , parts [0 ]),
379
- })
329
+ envVarDesc = parts [1 ]
380
330
}
331
+
332
+ environmentVariables = append (environmentVariables , model.KeyValueInput {
333
+ Name : envVarName ,
334
+ InputWithVariables : model.InputWithVariables {
335
+ Input : model.Input {
336
+ Description : envVarDesc ,
337
+ },
338
+ },
339
+ })
381
340
}
382
341
383
342
// Parse package arguments
384
- var packageArguments []RuntimeArgument
343
+ var packageArguments []model. Argument
385
344
for i , pkgArg := range packageArgs {
386
345
parts := strings .SplitN (pkgArg , ":" , 2 )
387
346
value := parts [0 ]
@@ -390,19 +349,23 @@ func createServerStructure(name, description, version, repoURL, repoSource, regi
390
349
description = parts [1 ]
391
350
}
392
351
393
- packageArguments = append (packageArguments , RuntimeArgument {
394
- Description : description ,
395
- IsRequired : true , // Package arguments are typically required
396
- Format : "string" ,
397
- Value : value ,
398
- Default : value ,
399
- Type : "positional" ,
400
- ValueHint : value ,
352
+ packageArguments = append (packageArguments , model.Argument {
353
+ InputWithVariables : model.InputWithVariables {
354
+ Input : model.Input {
355
+ Description : description ,
356
+ IsRequired : true , // Package arguments are typically required
357
+ Format : model .FormatString ,
358
+ Value : value ,
359
+ Default : value ,
360
+ },
361
+ },
362
+ Type : model .ArgumentTypePositional ,
363
+ ValueHint : value ,
401
364
})
402
365
}
403
366
404
367
// Parse execute command to create runtime arguments
405
- var runtimeArguments []RuntimeArgument
368
+ var runtimeArguments []model. Argument
406
369
if execute != "" {
407
370
// Split the execute command into parts, handling quoted strings
408
371
parts := smartSplit (execute )
@@ -423,43 +386,53 @@ func createServerStructure(name, description, version, repoURL, repoSource, regi
423
386
description = fmt .Sprintf ("Value for %s" , parts [i ])
424
387
}
425
388
426
- runtimeArguments = append (runtimeArguments , RuntimeArgument {
427
- Description : description ,
428
- IsRequired : false ,
429
- Format : "string" ,
430
- Value : arg ,
431
- Default : arg ,
432
- Type : "positional" ,
433
- ValueHint : arg ,
389
+ runtimeArguments = append (runtimeArguments , model.Argument {
390
+ InputWithVariables : model.InputWithVariables {
391
+ Input : model.Input {
392
+ Description : description ,
393
+ IsRequired : false ,
394
+ Format : model .FormatString ,
395
+ Value : arg ,
396
+ Default : arg ,
397
+ },
398
+ },
399
+ Type : model .ArgumentTypePositional ,
400
+ ValueHint : arg ,
434
401
})
435
402
}
436
403
}
437
404
}
438
405
439
406
// Create package
440
- pkg := Package {
407
+ pkg := model. Package {
441
408
RegistryName : registryName ,
442
409
Name : packageName ,
443
410
Version : packageVersion ,
444
- RuntimeHint : runtimeHint ,
411
+ RunTimeHint : runtimeHint ,
445
412
RuntimeArguments : runtimeArguments ,
446
413
PackageArguments : packageArguments ,
447
414
EnvironmentVariables : environmentVariables ,
448
415
}
449
416
450
- // Create server structure
451
- return ServerJSON {
452
- Name : name ,
453
- Description : description ,
454
- Status : status ,
455
- Repository : Repository {
456
- URL : repoURL ,
457
- Source : repoSource ,
458
- },
459
- VersionDetail : VersionDetail {
460
- Version : version ,
417
+ // Create server structure using model types
418
+ // Note: We only populate the fields we need for publishing
419
+ return model.ServerDetail {
420
+ Server : model.Server {
421
+ Name : name ,
422
+ Description : description ,
423
+ Status : model .ServerStatus (status ),
424
+ Repository : model.Repository {
425
+ URL : repoURL ,
426
+ Source : repoSource ,
427
+ // Should we allow setting the ID here, or it will be generated by the registry?
428
+ },
429
+ VersionDetail : model.VersionDetail {
430
+ Version : version ,
431
+ // ReleaseDate and IsLatest will be set by the registry
432
+ },
461
433
},
462
- Packages : []Package {pkg },
434
+ Packages : []model.Package {pkg },
435
+ // Remotes can be empty for basic server definitions
463
436
}
464
437
}
465
438
0 commit comments