Skip to content

Commit 0f46fa0

Browse files
committed
Fix linting errors
Signed-off-by: Radoslav Dimitrov <[email protected]>
1 parent ef470ca commit 0f46fa0

File tree

4 files changed

+24
-24
lines changed

4 files changed

+24
-24
lines changed

cmd/registry-builder/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ func init() {
8686

8787
// Build command flags
8888
buildCmd.Flags().StringVarP(&outputDir, "output-dir", "o", "build", "Output directory for built registry files")
89-
buildCmd.Flags().StringVarP(&outputFormat, "format", "f", "toolhive", fmt.Sprintf("Output format (%s, %s, %s)", RegistryToolHiveFormat, RegistryOfficialMCPRegistry, RegistryAllFormats))
89+
buildCmd.Flags().StringVarP(&outputFormat, "format", "f", "toolhive",
90+
fmt.Sprintf("Output format (%s, %s, %s)", RegistryToolHiveFormat, RegistryOfficialMCPRegistry, RegistryAllFormats))
9091

9192
// Add commands
9293
rootCmd.AddCommand(buildCmd)

pkg/registry/official.go

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"github.com/stacklok/toolhive-registry/pkg/types"
1616
)
1717

18+
// OfficialRegistry handles building and writing the toolhive MCP registry based on the official server format
1819
type OfficialRegistry struct {
1920
loader *Loader
2021
}
@@ -26,12 +27,10 @@ func NewOfficialRegistry(loader *Loader) *OfficialRegistry {
2627
}
2728
}
2829

30+
// WriteJSON builds the official MCP registry and writes it to the specified path
2931
func (or *OfficialRegistry) WriteJSON(path string) error {
3032
// Build the registry structure
31-
registry, err := or.build()
32-
if err != nil {
33-
return fmt.Errorf("failed to build official registry: %w", err)
34-
}
33+
registry := or.build()
3534

3635
// Create the directory if it doesn't exist
3736
dir := filepath.Dir(path)
@@ -54,7 +53,7 @@ func (or *OfficialRegistry) WriteJSON(path string) error {
5453
}
5554

5655
// build creates the ToolHiveRegistryType structure from loaded entries
57-
func (or *OfficialRegistry) build() (*ToolHiveRegistryType, error) {
56+
func (or *OfficialRegistry) build() *ToolHiveRegistryType {
5857
entries := or.loader.GetEntries()
5958

6059
// Get sorted entry names for consistent output
@@ -68,10 +67,7 @@ func (or *OfficialRegistry) build() (*ToolHiveRegistryType, error) {
6867
var servers []upstream.ServerJSON
6968
for _, name := range names {
7069
entry := entries[name]
71-
serverJSON, err := or.transformEntry(name, entry)
72-
if err != nil {
73-
return nil, fmt.Errorf("failed to transform entry %s: %w", name, err)
74-
}
70+
serverJSON := or.transformEntry(name, entry)
7571
servers = append(servers, serverJSON)
7672
}
7773

@@ -87,11 +83,11 @@ func (or *OfficialRegistry) build() (*ToolHiveRegistryType, error) {
8783
},
8884
}
8985

90-
return registry, nil
86+
return registry
9187
}
9288

9389
// transformEntry converts a ToolHive RegistryEntry to an official MCP ServerJSON
94-
func (or *OfficialRegistry) transformEntry(name string, entry *types.RegistryEntry) (upstream.ServerJSON, error) {
90+
func (or *OfficialRegistry) transformEntry(name string, entry *types.RegistryEntry) upstream.ServerJSON {
9591
// Create the flattened server JSON with _meta extensions
9692
serverJSON := upstream.ServerJSON{
9793
Name: name,
@@ -105,7 +101,7 @@ func (or *OfficialRegistry) transformEntry(name string, entry *types.RegistryEnt
105101
// They are generated by the registry system.
106102
// We include them here so we can start using them in toolhive,
107103
// and they are available when we support an official MCP registry.
108-
IOModelContextProtocolRegistry: or.createRegistryExtensions(name, entry),
104+
IOModelContextProtocolRegistry: or.createRegistryExtensions(),
109105
},
110106
}
111107

@@ -119,11 +115,11 @@ func (or *OfficialRegistry) transformEntry(name string, entry *types.RegistryEnt
119115
serverJSON.Remotes = or.createRemotes(entry)
120116
}
121117

122-
return serverJSON, nil
118+
return serverJSON
123119
}
124120

125121
// createRepository creates repository information from entry
126-
func (or *OfficialRegistry) createRepository(entry *types.RegistryEntry) model.Repository {
122+
func (*OfficialRegistry) createRepository(entry *types.RegistryEntry) model.Repository {
127123
var repositoryURL string
128124

129125
if entry.IsImage() && entry.ImageMetadata.RepositoryURL != "" {
@@ -143,14 +139,14 @@ func (or *OfficialRegistry) createRepository(entry *types.RegistryEntry) model.R
143139
}
144140

145141
// createVersionDetail creates version information (fixed at 1.0.0 for now)
146-
func (or *OfficialRegistry) createVersionDetail() model.VersionDetail {
142+
func (*OfficialRegistry) createVersionDetail() model.VersionDetail {
147143
return model.VersionDetail{
148144
Version: "1.0.0",
149145
}
150146
}
151147

152148
// createPackages creates Package entries for image-based servers
153-
func (or *OfficialRegistry) createPackages(entry *types.RegistryEntry) []model.Package {
149+
func (*OfficialRegistry) createPackages(entry *types.RegistryEntry) []model.Package {
154150
if !entry.IsImage() || entry.Image == "" {
155151
return nil
156152
}
@@ -181,7 +177,7 @@ func (or *OfficialRegistry) createPackages(entry *types.RegistryEntry) []model.P
181177
}
182178

183179
// createRemotes creates Remote entries for remote servers
184-
func (or *OfficialRegistry) createRemotes(entry *types.RegistryEntry) []model.Remote {
180+
func (*OfficialRegistry) createRemotes(entry *types.RegistryEntry) []model.Remote {
185181
if !entry.IsRemote() || entry.URL == "" {
186182
return nil
187183
}
@@ -211,7 +207,7 @@ func (or *OfficialRegistry) createRemotes(entry *types.RegistryEntry) []model.Re
211207
}
212208

213209
// createRegistryExtensions creates registry-generated metadata
214-
func (or *OfficialRegistry) createRegistryExtensions(name string, entry *types.RegistryEntry) *upstream.RegistryExtensions {
210+
func (*OfficialRegistry) createRegistryExtensions() *upstream.RegistryExtensions {
215211
now := time.Now().UTC()
216212
return &upstream.RegistryExtensions{
217213
ID: uuid.NewString(),
@@ -275,7 +271,7 @@ func (or *OfficialRegistry) createToolHiveExtensions(entry *types.RegistryEntry)
275271
}
276272

277273
// addImageSpecificExtensions adds image-specific ToolHive extensions
278-
func (or *OfficialRegistry) addImageSpecificExtensions(extensions map[string]interface{}, entry *types.RegistryEntry) {
274+
func (*OfficialRegistry) addImageSpecificExtensions(extensions map[string]interface{}, entry *types.RegistryEntry) {
279275
if entry.ImageMetadata == nil {
280276
return
281277
}
@@ -307,7 +303,7 @@ func (or *OfficialRegistry) addImageSpecificExtensions(extensions map[string]int
307303
}
308304

309305
// addRemoteSpecificExtensions adds remote-specific ToolHive extensions
310-
func (or *OfficialRegistry) addRemoteSpecificExtensions(extensions map[string]interface{}, entry *types.RegistryEntry) {
306+
func (*OfficialRegistry) addRemoteSpecificExtensions(extensions map[string]interface{}, entry *types.RegistryEntry) {
311307
if entry.RemoteServerMetadata == nil {
312308
return
313309
}
@@ -329,7 +325,7 @@ func (or *OfficialRegistry) addRemoteSpecificExtensions(extensions map[string]in
329325
}
330326

331327
// addCommonExtensions adds extensions common to both image and remote servers
332-
func (or *OfficialRegistry) addCommonExtensions(extensions map[string]interface{}, entry *types.RegistryEntry) {
328+
func (*OfficialRegistry) addCommonExtensions(extensions map[string]interface{}, entry *types.RegistryEntry) {
333329
// Add examples if present
334330
if len(entry.Examples) > 0 {
335331
extensions["examples"] = entry.Examples
@@ -342,7 +338,7 @@ func (or *OfficialRegistry) addCommonExtensions(extensions map[string]interface{
342338
}
343339

344340
// convertStatus converts ToolHive status to MCP model.Status
345-
func (or *OfficialRegistry) convertStatus(status string) model.Status {
341+
func (*OfficialRegistry) convertStatus(status string) model.Status {
346342
switch status {
347343
case types.StatusActive, "":
348344
return model.StatusActive

pkg/registry/official_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ type ToolHiveRegistryType struct {
1818
type Group struct {
1919
}
2020

21+
// Data holds the servers and groups in the registry
2122
type Data struct {
2223
Servers []upstream.ServerJSON `json:"servers" yaml:"servers"`
2324
Groups []Group `json:"groups" yaml:"groups"`
2425
}
2526

27+
// Meta contains metadata about the registry
2628
type Meta struct {
2729
// LastUpdated is the timestamp when the registry was last updated, in RFC3339 format
2830
LastUpdated string `json:"last_updated" yaml:"last_updated"`

pkg/registry/toolhive.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ import (
88
"sort"
99
"time"
1010

11-
"github.com/stacklok/toolhive-registry/pkg/types"
1211
"github.com/stacklok/toolhive/pkg/permissions"
1312
toolhiveRegistry "github.com/stacklok/toolhive/pkg/registry"
13+
14+
"github.com/stacklok/toolhive-registry/pkg/types"
1415
)
1516

1617
// Builder builds the final registry JSON from loaded entries

0 commit comments

Comments
 (0)