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