Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions cmd/docker-mcp/client/connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,19 @@ import (

"github.com/docker/cli/cli/command"

"github.com/docker/mcp-gateway/pkg/client"

"github.com/docker/mcp-gateway/cmd/docker-mcp/hints"
"github.com/docker/mcp-gateway/pkg/client"
"github.com/docker/mcp-gateway/pkg/db"
)

func Connect(ctx context.Context, dockerCli command.Cli, cwd string, config client.Config, vendor string, global, quiet bool, workingSet string) error {
if err := client.Connect(ctx, cwd, config, vendor, global, workingSet); err != nil {
dao, err := db.New()
if err != nil {
return err
}
defer dao.Close()

if err := client.Connect(ctx, dao, cwd, config, vendor, global, workingSet); err != nil {
return err
}
if quiet {
Expand Down
6 changes: 3 additions & 3 deletions docs/generator/reference/docker_mcp_client_connect.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
command: docker mcp client connect
short: |
Connect the Docker MCP Toolkit to a client. Supported clients: claude-code claude-desktop codex continue cursor gemini goose gordon kiro lmstudio opencode sema4 vscode zed
Connect the Docker MCP Toolkit to a client. Supported clients: claude-code claude-desktop cline codex continue cursor gemini goose gordon kiro lmstudio opencode sema4 vscode zed
long: |
Connect the Docker MCP Toolkit to a client. Supported clients: claude-code claude-desktop codex continue cursor gemini goose gordon kiro lmstudio opencode sema4 vscode zed
Connect the Docker MCP Toolkit to a client. Supported clients: claude-code claude-desktop cline codex continue cursor gemini goose gordon kiro lmstudio opencode sema4 vscode zed
usage: |-
docker mcp client connect [OPTIONS] <mcp-client>

Supported clients: claude-code claude-desktop codex continue cursor gemini goose gordon kiro lmstudio opencode sema4 vscode zed
Supported clients: claude-code claude-desktop cline codex continue cursor gemini goose gordon kiro lmstudio opencode sema4 vscode zed
pname: docker mcp client
plink: docker_mcp_client.yaml
options:
Expand Down
6 changes: 3 additions & 3 deletions docs/generator/reference/docker_mcp_client_disconnect.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
command: docker mcp client disconnect
short: |
Disconnect the Docker MCP Toolkit from a client. Supported clients: claude-code claude-desktop codex continue cursor gemini goose gordon kiro lmstudio opencode sema4 vscode zed
Disconnect the Docker MCP Toolkit from a client. Supported clients: claude-code claude-desktop cline codex continue cursor gemini goose gordon kiro lmstudio opencode sema4 vscode zed
long: |
Disconnect the Docker MCP Toolkit from a client. Supported clients: claude-code claude-desktop codex continue cursor gemini goose gordon kiro lmstudio opencode sema4 vscode zed
Disconnect the Docker MCP Toolkit from a client. Supported clients: claude-code claude-desktop cline codex continue cursor gemini goose gordon kiro lmstudio opencode sema4 vscode zed
usage: |-
docker mcp client disconnect [OPTIONS] <mcp-client>

Supported clients: claude-code claude-desktop codex continue cursor gemini goose gordon kiro lmstudio opencode sema4 vscode zed
Supported clients: claude-code claude-desktop cline codex continue cursor gemini goose gordon kiro lmstudio opencode sema4 vscode zed
pname: docker mcp client
plink: docker_mcp_client.yaml
options:
Expand Down
10 changes: 5 additions & 5 deletions docs/generator/reference/mcp_client.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ Manage MCP clients

### Subcommands

| Name | Description |
|:-----------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [`connect`](mcp_client_connect.md) | Connect the Docker MCP Toolkit to a client. Supported clients: claude-code claude-desktop codex continue cursor gemini goose gordon kiro lmstudio opencode sema4 vscode zed |
| [`disconnect`](mcp_client_disconnect.md) | Disconnect the Docker MCP Toolkit from a client. Supported clients: claude-code claude-desktop codex continue cursor gemini goose gordon kiro lmstudio opencode sema4 vscode zed |
| [`ls`](mcp_client_ls.md) | List client configurations |
| Name | Description |
|:-----------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [`connect`](mcp_client_connect.md) | Connect the Docker MCP Toolkit to a client. Supported clients: claude-code claude-desktop cline codex continue cursor gemini goose gordon kiro lmstudio opencode sema4 vscode zed |
| [`disconnect`](mcp_client_disconnect.md) | Disconnect the Docker MCP Toolkit from a client. Supported clients: claude-code claude-desktop cline codex continue cursor gemini goose gordon kiro lmstudio opencode sema4 vscode zed |
| [`ls`](mcp_client_ls.md) | List client configurations |



Expand Down
2 changes: 1 addition & 1 deletion docs/generator/reference/mcp_client_connect.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# docker mcp client connect

<!---MARKER_GEN_START-->
Connect the Docker MCP Toolkit to a client. Supported clients: claude-code claude-desktop codex continue cursor gemini goose gordon kiro lmstudio opencode sema4 vscode zed
Connect the Docker MCP Toolkit to a client. Supported clients: claude-code claude-desktop cline codex continue cursor gemini goose gordon kiro lmstudio opencode sema4 vscode zed

### Options

Expand Down
2 changes: 1 addition & 1 deletion docs/generator/reference/mcp_client_disconnect.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# docker mcp client disconnect

<!---MARKER_GEN_START-->
Disconnect the Docker MCP Toolkit from a client. Supported clients: claude-code claude-desktop codex continue cursor gemini goose gordon kiro lmstudio opencode sema4 vscode zed
Disconnect the Docker MCP Toolkit from a client. Supported clients: claude-code claude-desktop cline codex continue cursor gemini goose gordon kiro lmstudio opencode sema4 vscode zed

### Options

Expand Down
24 changes: 24 additions & 0 deletions pkg/client/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,30 @@ system:
list: '.mcpServers | to_entries | map(.value + {"name": .key})'
set: .mcpServers[$NAME] = $JSON
del: del(.mcpServers[$NAME])
cline:
displayName: Cline
source: https://github.com/cline/cline
icon: https://raw.githubusercontent.com/cline/cline/main/assets/icons/icon.png
installCheckPaths:
- $HOME/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev
- $HOME/Library/Application Support/Cursor/User/globalStorage/saoudrizwan.claude-dev
- $HOME/.config/Code/User/globalStorage/saoudrizwan.claude-dev
- $APPDATA\Code\User\globalStorage\saoudrizwan.claude-dev
- $APPDATA\Cursor\User\globalStorage\saoudrizwan.claude-dev
paths:
linux:
- $HOME/.config/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
- $HOME/.config/Cursor/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
darwin:
- $HOME/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
- $HOME/Library/Application Support/Cursor/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
windows:
- $APPDATA\Code\User\globalStorage\saoudrizwan.claude-dev\settings\cline_mcp_settings.json
- $APPDATA\Cursor\User\globalStorage\saoudrizwan.claude-dev\settings\cline_mcp_settings.json
Comment on lines +46 to +61
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@slimslenderslacks - just wanted to confirm these are the expected paths

yq:
list: '.mcpServers | to_entries | map(.value + {"name": .key})'
set: .mcpServers[$NAME] = $JSON
del: del(.mcpServers[$NAME])
continue:
displayName: Continue.dev
source: https://www.continue.dev/
Expand Down
11 changes: 10 additions & 1 deletion pkg/client/connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,20 @@ import (
"context"
"errors"
"fmt"

"github.com/docker/mcp-gateway/pkg/db"
)

var ErrCodexOnlySupportsGlobalConfiguration = errors.New("codex only supports global configuration. Re-run with --global or -g")

func Connect(ctx context.Context, cwd string, config Config, vendor string, global bool, workingSet string) error {
func Connect(ctx context.Context, dao db.DAO, cwd string, config Config, vendor string, global bool, workingSet string) error {
if workingSet != "" {
_, err := dao.GetWorkingSet(ctx, workingSet)
if err != nil {
return fmt.Errorf("failed to get profile: %s", workingSet)
}
}

if vendor == VendorCodex {
if !global {
return ErrCodexOnlySupportsGlobalConfiguration
Expand Down
54 changes: 54 additions & 0 deletions pkg/client/connect_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package client

import (
"path/filepath"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/docker/mcp-gateway/pkg/db"
)

func setupTestDB(t *testing.T) db.DAO {
t.Helper()

tempDir := t.TempDir()
dbFile := filepath.Join(tempDir, "test.db")

dao, err := db.New(db.WithDatabaseFile(dbFile))
require.NoError(t, err)

t.Cleanup(func() {
dao.Close()
})

return dao
}

func TestConnectWithNonExistingProfile(t *testing.T) {
dao := setupTestDB(t)
ctx := t.Context()

err := Connect(ctx, dao, "/tmp", Config{}, "cursor", false, "nonexistent-profile")
require.Error(t, err)
assert.Contains(t, err.Error(), "failed to get profile: nonexistent-profile")
}

func TestConnectWithExistingProfile(t *testing.T) {
dao := setupTestDB(t)
ctx := t.Context()

workingSet := db.WorkingSet{
ID: "test-profile",
Name: "Test Profile",
Servers: db.ServerList{},
Secrets: db.SecretMap{},
}

err := dao.CreateWorkingSet(ctx, workingSet)
require.NoError(t, err)

err = Connect(ctx, dao, "/tmp", Config{}, "cursor", true, "test-profile")
assert.NotContains(t, err.Error(), "failed to get profile: test")
}
2 changes: 1 addition & 1 deletion pkg/workingset/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func Create(ctx context.Context, dao db.DAO, registryClient registryapi.Client,

if len(connectClients) > 0 {
for _, c := range connectClients {
if err := client.Connect(ctx, "", cfg, c, true, workingSet.ID); err != nil {
if err := client.Connect(ctx, dao, "", cfg, c, true, workingSet.ID); err != nil {
return fmt.Errorf("profile created, but failed to connect to client %s: %w", c, err)
}
}
Expand Down
Loading