Skip to content

Commit 6107e0e

Browse files
committed
Use a sqlite database for working sets. Add import/export commands.
1 parent bea14e9 commit 6107e0e

File tree

10 files changed

+481
-225
lines changed

10 files changed

+481
-225
lines changed
Lines changed: 16 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package commands
22

33
import (
4-
"fmt"
5-
4+
"github.com/docker/mcp-gateway/pkg/db"
65
"github.com/docker/mcp-gateway/pkg/workingset"
76
"github.com/spf13/cobra"
87
)
@@ -13,57 +12,36 @@ func workingSetCommand() *cobra.Command {
1312
Short: "Manage working sets",
1413
}
1514

16-
// TODO clean these up
17-
cmd.AddCommand(testWriteWorkingSetCommand())
18-
cmd.AddCommand(testReadWorkingSetCommand())
15+
cmd.AddCommand(exportWorkingSetCommand())
16+
cmd.AddCommand(importWorkingSetCommand())
1917

2018
return cmd
2119
}
2220

23-
func testWriteWorkingSetCommand() *cobra.Command {
21+
func exportWorkingSetCommand() *cobra.Command {
2422
return &cobra.Command{
25-
Use: "test-write",
26-
Short: "Test write working set",
23+
Use: "export <working-set-id> <output-file>",
24+
Short: "Export working set",
2725
RunE: func(cmd *cobra.Command, args []string) error {
28-
return workingset.Write(workingset.WorkingSet{
29-
ID: "test",
30-
Name: "My working set",
31-
Servers: []workingset.Server{
32-
{
33-
Type: "registry",
34-
Source: "https://example-registry.com/v0/servers/312e45a4-2216-4b21-b9a8-0f1a51425073",
35-
Config: map[string]interface{}{
36-
"username": "bobbarker",
37-
},
38-
Secrets: "default",
39-
},
40-
{
41-
Type: "image",
42-
Image: "mcp/notion:v0.1.0",
43-
Tools: []string{"do_something"},
44-
},
45-
},
46-
Secrets: map[string]workingset.Secret{
47-
"default": {
48-
Provider: "docker-desktop-store",
49-
},
50-
},
51-
})
26+
dao, err := db.New()
27+
if err != nil {
28+
return err
29+
}
30+
return workingset.Export(cmd.Context(), dao, args[0], args[1])
5231
},
5332
}
5433
}
5534

56-
func testReadWorkingSetCommand() *cobra.Command {
35+
func importWorkingSetCommand() *cobra.Command {
5736
return &cobra.Command{
58-
Use: "test-read",
59-
Short: "Test read working set",
37+
Use: "import <input-file>",
38+
Short: "Import working set",
6039
RunE: func(cmd *cobra.Command, args []string) error {
61-
ws, err := workingset.Read("test")
40+
dao, err := db.New()
6241
if err != nil {
6342
return err
6443
}
65-
fmt.Println(ws)
66-
return nil
44+
return workingset.Import(cmd.Context(), dao, args[0])
6745
},
6846
}
6947
}

go.mod

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ require (
99
github.com/distribution/reference v0.6.0
1010
github.com/docker/cli v28.2.2+incompatible
1111
github.com/docker/cli-docs-tool v0.10.0
12-
github.com/docker/docker v28.2.2+incompatible
12+
github.com/docker/docker v28.3.3+incompatible
1313
github.com/docker/docker-credential-helpers v0.9.3
1414
github.com/fsnotify/fsnotify v1.9.0
15+
github.com/golang-migrate/migrate/v4 v4.19.0
1516
github.com/google/go-containerregistry v0.20.6
1617
github.com/google/jsonschema-go v0.3.0
1718
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
19+
github.com/jmoiron/sqlx v1.4.0
1820
github.com/mikefarah/yq/v4 v4.45.4
1921
github.com/modelcontextprotocol/go-sdk v1.0.0
2022
github.com/opencontainers/go-digest v1.0.0
@@ -25,14 +27,25 @@ require (
2527
github.com/spf13/cobra v1.9.1
2628
github.com/spf13/pflag v1.0.6
2729
github.com/stretchr/testify v1.10.0
28-
go.opentelemetry.io/otel v1.36.0
29-
go.opentelemetry.io/otel/metric v1.36.0
30+
go.opentelemetry.io/otel v1.37.0
31+
go.opentelemetry.io/otel/metric v1.37.0
3032
go.opentelemetry.io/otel/sdk v1.36.0
3133
go.opentelemetry.io/otel/sdk/metric v1.36.0
32-
go.opentelemetry.io/otel/trace v1.36.0
33-
golang.org/x/sync v0.15.0
34+
go.opentelemetry.io/otel/trace v1.37.0
35+
golang.org/x/sync v0.16.0
3436
gopkg.in/op/go-logging.v1 v1.0.0-20160211212156-b2cb9fa56473
3537
gopkg.in/yaml.v3 v3.0.1
38+
modernc.org/sqlite v1.39.1
39+
)
40+
41+
require (
42+
github.com/hashicorp/errwrap v1.1.0 // indirect
43+
github.com/hashicorp/go-multierror v1.1.1 // indirect
44+
github.com/ncruces/go-strftime v0.1.9 // indirect
45+
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
46+
modernc.org/libc v1.66.10 // indirect
47+
modernc.org/mathutil v1.7.1 // indirect
48+
modernc.org/memory v1.11.0 // indirect
3649
)
3750

3851
require (
@@ -116,7 +129,7 @@ require (
116129
github.com/onsi/gomega v1.37.0 // indirect
117130
github.com/open-policy-agent/opa v1.5.1 // indirect
118131
github.com/opentracing/opentracing-go v1.2.0 // indirect
119-
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
132+
github.com/pelletier/go-toml/v2 v2.2.4
120133
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
121134
github.com/prometheus/client_model v0.6.2 // indirect
122135
github.com/rivo/uniseg v0.4.7 // indirect
@@ -157,13 +170,13 @@ require (
157170
go.opentelemetry.io/proto/otlp v1.7.0 // indirect
158171
go.uber.org/multierr v1.11.0 // indirect
159172
go.uber.org/zap v1.27.0 // indirect
160-
golang.org/x/crypto v0.39.0 // indirect
161-
golang.org/x/exp v0.0.0-20250606033433-dcc06ee1d476 // indirect
162-
golang.org/x/mod v0.25.0 // indirect
163-
golang.org/x/net v0.41.0 // indirect
164-
golang.org/x/sys v0.33.0 // indirect
165-
golang.org/x/term v0.32.0 // indirect
166-
golang.org/x/text v0.26.0 // indirect
173+
golang.org/x/crypto v0.41.0 // indirect
174+
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b // indirect
175+
golang.org/x/mod v0.27.0 // indirect
176+
golang.org/x/net v0.43.0 // indirect
177+
golang.org/x/sys v0.36.0 // indirect
178+
golang.org/x/term v0.34.0 // indirect
179+
golang.org/x/text v0.28.0 // indirect
167180
google.golang.org/genproto/googleapis/api v0.0.0-20250603155806-513f23925822 // indirect
168181
google.golang.org/genproto/googleapis/rpc v0.0.0-20250603155806-513f23925822 // indirect
169182
google.golang.org/grpc v1.73.0 // indirect

0 commit comments

Comments
 (0)