Skip to content

Commit 4b739a8

Browse files
authored
Add container volume support for image-based MCP servers (#17)
1 parent f9418d9 commit 4b739a8

5 files changed

Lines changed: 40 additions & 7 deletions

File tree

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,15 @@ services:
389389
BRAVE_API_KEY: ${BRAVE_API_KEY}
390390
labels:
391391
mcp.profile: programming, research
392+
393+
# Container with volume mounts
394+
filesystem:
395+
image: mcp/filesystem
396+
volumes:
397+
- ${HOME}/projects:/workspace:ro
398+
- /tmp:/tmp
399+
labels:
400+
mcp.profile: programming
392401
```
393402

394403
## Development

cmd/list.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,12 @@ func printServerRow(w *tabwriter.Writer, name string, service Service, envVars m
242242
commandStr += fmt.Sprintf(" -e %s=%s", key, shellQuote(expandedValue))
243243
}
244244

245+
// Add volume mounts as -v flags
246+
for _, volume := range service.Volumes {
247+
expandedVolume := expandEnvVars(volume, envVars)
248+
commandStr += fmt.Sprintf(" -v %s", shellQuote(expandedVolume))
249+
}
250+
245251
// Add the image name
246252
commandStr += fmt.Sprintf(" %s", service.Image)
247253
} else {
@@ -284,6 +290,11 @@ func printServerRow(w *tabwriter.Writer, name string, service Service, envVars m
284290
commandStr += fmt.Sprintf(" -e %s", key)
285291
}
286292

293+
// Add volume mounts to the command
294+
for _, volume := range service.Volumes {
295+
commandStr += fmt.Sprintf(" -v %s", volume)
296+
}
297+
287298
// Add the image name
288299
commandStr += fmt.Sprintf(" %s", service.Image)
289300
} else {

cmd/set.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,12 @@ func convertToMCPConfig(servers map[string]Service, envVars map[string]string) M
218218
args = append(args, "-e", fmt.Sprintf("%s=%s", key, expandedValue))
219219
}
220220

221+
// Add volume mounts with expanded values
222+
for _, volume := range service.Volumes {
223+
expandedVolume := expandEnvVars(volume, envVars)
224+
args = append(args, "-v", expandedVolume)
225+
}
226+
221227
// Expand image name if it contains env vars
222228
expandedImage := expandEnvVars(service.Image, envVars)
223229
args = append(args, expandedImage)

cmd/types.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ type Service struct {
9191
Image string `yaml:"image"`
9292
Environment map[string]string `yaml:"environment"`
9393
Labels map[string]string `yaml:"labels"`
94+
Volumes []string `yaml:"volumes"`
9495
}
9596

9697
// MCPConfig represents the MCP JSON configuration format
@@ -151,8 +152,8 @@ type ToolStatus struct {
151152

152153
// ToolConfig represents a tool's configuration with metadata
153154
type ToolConfig struct {
154-
Config MCPConfig
155-
Path string
156-
Exists bool
157-
Error string
155+
Config MCPConfig
156+
Path string
157+
Exists bool
158+
Error string
158159
}

mcp-compose.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
services:
2-
32
# default mcp servers
43

54
time:
@@ -8,7 +7,6 @@ services:
87
fetch:
98
command: uvx mcp-server-fetch
109

11-
1210
# programming
1311

1412
github:
@@ -30,7 +28,6 @@ services:
3028
labels:
3129
mcp.profile: programming, database
3230

33-
3431
# Container based MCP servers
3532

3633
github-docker:
@@ -46,3 +43,12 @@ services:
4643
BRAVE_API_KEY: ${BRAVE_API_KEY}
4744
labels:
4845
mcp.profile: programming, research
46+
47+
# Example with volume mounts
48+
filesystem:
49+
image: mcp/filesystem
50+
volumes:
51+
- ${HOME}/projects:/workspace:ro
52+
- /tmp:/tmp
53+
labels:
54+
mcp.profile: programming

0 commit comments

Comments
 (0)