Skip to content

Commit 887d698

Browse files
committed
Set a specific user agent
Signed-off-by: David Gageot <[email protected]>
1 parent fd621e2 commit 887d698

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

cmd/docker-mcp/internal/docker/client.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/docker/docker/api/types/network"
1111
"github.com/docker/docker/api/types/volume"
1212
"github.com/docker/docker/client"
13+
"github.com/docker/mcp-gateway/cmd/docker-mcp/version"
1314
)
1415

1516
type Client interface {
@@ -38,6 +39,13 @@ type dockerClient struct {
3839
func NewClient(cli command.Cli) Client {
3940
return &dockerClient{
4041
apiClient: sync.OnceValue(func() client.APIClient {
42+
_ = cli.Apply(func(cli *command.DockerCli) error {
43+
if mobyClient, ok := cli.Client().(*client.Client); ok {
44+
_ = client.WithUserAgent("mcp/" + version.Version)(mobyClient)
45+
}
46+
return nil
47+
})
48+
4149
return cli.Client()
4250
}),
4351
}

0 commit comments

Comments
 (0)