Skip to content

Commit 63f18be

Browse files
authored
Add --tools build flag. (github#33)
1 parent d6e2d11 commit 63f18be

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

cmd/build/main.go

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@ import (
1010
"path/filepath"
1111
"strings"
1212

13+
"github.com/docker/mcp-registry/internal/mcp"
1314
"github.com/docker/mcp-registry/pkg/github"
1415
"github.com/docker/mcp-registry/pkg/servers"
1516
)
1617

1718
func main() {
19+
listTools := flag.Bool("tools", false, "List the tools")
20+
1821
flag.Parse()
1922
args := flag.Args()
2023

@@ -23,12 +26,12 @@ func main() {
2326
os.Exit(1)
2427
}
2528

26-
if err := run(context.Background(), args[0]); err != nil {
29+
if err := run(context.Background(), args[0], *listTools); err != nil {
2730
log.Fatal(err)
2831
}
2932
}
3033

31-
func run(ctx context.Context, name string) error {
34+
func run(ctx context.Context, name string, listTools bool) error {
3235
server, err := servers.Read(filepath.Join("servers", name, "server.yaml"))
3336
if err != nil {
3437
if os.IsNotExist(err) {
@@ -88,6 +91,22 @@ func run(ctx context.Context, name string) error {
8891
return err
8992
}
9093

94+
if listTools {
95+
tools, err := mcp.Tools(ctx, server, false, false, false)
96+
if err != nil {
97+
return err
98+
}
99+
100+
if len(tools) == 0 {
101+
fmt.Println()
102+
fmt.Println("No tools found.")
103+
} else {
104+
fmt.Println()
105+
fmt.Println(len(tools), "tools found.")
106+
}
107+
}
108+
fmt.Printf("\n-----------------------------------------\n\n")
109+
91110
fmt.Println("✅ Image built as", server.Image)
92111

93112
return nil

0 commit comments

Comments
 (0)