Skip to content

Commit 989c5dc

Browse files
Merge pull request #323 from docker/slim/extra-hosts
Add support for extraHosts in MCP server catalog entries
2 parents 27ef36c + 93ae6e5 commit 989c5dc

File tree

4 files changed

+48
-0
lines changed

4 files changed

+48
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
registry:
2+
playwright:
3+
description: Playwright MCP server.
4+
title: Playwright
5+
type: server
6+
longLived: true
7+
dateAdded: "2025-05-05T20:04:34Z"
8+
image: mcp/playwright@sha256:53da89d1da3dfbb61c10f707c1713cfee1f870f7fba5334e126c6c765e37db56
9+
ref: ""
10+
readme: http://desktop.docker.com/mcp/catalog/v3/readme/playwright.md
11+
toolsUrl: http://desktop.docker.com/mcp/catalog/v3/tools/playwright.json
12+
source: https://github.com/microsoft/playwright-mcp/tree/64f65ccd105842204e3e1b1e1a7b28825492b089
13+
upstream: https://github.com/microsoft/playwright-mcp
14+
icon: https://avatars.githubusercontent.com/u/6154722?v=4
15+
extraHosts:
16+
- "myapp.local:192.168.1.100"
17+
- "testserver:10.0.0.5"

pkg/catalog/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ type Server struct {
3232
User string `yaml:"user,omitempty" json:"user,omitempty"`
3333
DisableNetwork bool `yaml:"disableNetwork,omitempty" json:"disableNetwork,omitempty"`
3434
AllowHosts []string `yaml:"allowHosts,omitempty" json:"allowHosts,omitempty"`
35+
ExtraHosts []string `yaml:"extraHosts,omitempty" json:"extraHosts,omitempty"`
3536
Tools []Tool `yaml:"tools,omitempty" json:"tools,omitempty"`
3637
Config []any `yaml:"config,omitempty" json:"config,omitempty"`
3738
Prefix string `yaml:"prefix,omitempty" json:"prefix,omitempty"`

pkg/gateway/clientpool.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,13 @@ func (cp *clientPool) argsAndEnv(serverConfig *catalog.ServerConfig, readOnly *b
383383
}
384384
}
385385

386+
// Extra hosts (for /etc/hosts entries)
387+
for _, host := range serverConfig.Spec.ExtraHosts {
388+
if host != "" {
389+
args = append(args, "--add-host", host)
390+
}
391+
}
392+
386393
return args, env
387394
}
388395

pkg/gateway/clientpool_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,29 @@ user: "1001:2002"
160160
assert.Empty(t, env)
161161
}
162162

163+
func TestApplyConfigExtraHosts(t *testing.T) {
164+
catalogYAML := `
165+
description: Playwright MCP server.
166+
title: Playwright
167+
type: server
168+
longLived: true
169+
image: mcp/playwright@sha256:53da89d1da3dfbb61c10f707c1713cfee1f870f7fba5334e126c6c765e37db56
170+
extraHosts:
171+
- "myhost:192.168.1.100"
172+
- "anotherhost:10.0.0.1"
173+
`
174+
175+
args, env := argsAndEnv(t, "playwright", catalogYAML, "", nil, nil)
176+
177+
assert.Equal(t, []string{
178+
"run", "--rm", "-i", "--init", "--security-opt", "no-new-privileges", "--cpus", "1", "--memory", "2Gb", "--pull", "never",
179+
"-l", "docker-mcp=true", "-l", "docker-mcp-tool-type=mcp", "-l", "docker-mcp-name=playwright", "-l", "docker-mcp-transport=stdio",
180+
"--add-host", "myhost:192.168.1.100",
181+
"--add-host", "anotherhost:10.0.0.1",
182+
}, args)
183+
assert.Empty(t, env)
184+
}
185+
163186
func TestApplyConfigLongLivedIgnoresReadOnly(t *testing.T) {
164187
catalogYAML := `
165188
longLived: true

0 commit comments

Comments
 (0)