Skip to content

Conversation

@JAORMX
Copy link
Collaborator

@JAORMX JAORMX commented Mar 26, 2025

This commit adds the ability to mount directories from the host into containers
via both vt run and vt registry run commands. This feature enhances the
flexibility of MCP servers by allowing them to access files from the host system.

Volume Mount Format:

  • Basic format: -v host-path:container-path
  • Read-only mount: -v host-path:container-path:ro

The implementation supports three types of mounts:

  1. Single path: When only one path is provided, it's used as both the source and
    target (e.g., -v /path/to/dir)
  2. Different paths: When two paths are provided, the first is the host path and
    the second is the container path (e.g., -v /host/path:/container/path)
  3. Resource URIs: For future extensibility, the source can be a URI that
    identifies a resource (e.g., -v volume://name:/container/path)

Security Features:

  • Command injection detection: Paths are validated to prevent command injection
  • Null byte detection: Paths containing null bytes are rejected
  • Path normalization: All paths are normalized using filepath.Clean

Implementation Details:

  • Added MountDeclaration type to represent mount declarations
  • Updated Profile struct to use MountDeclaration for Read and Write mounts
  • Added volume flag to both vt run and registry run commands
  • Implemented processVolumeMounts function to parse and validate volume mounts
  • Updated container client to handle MountDeclaration objects

The feature has been thoroughly tested with both read-write and read-only mounts,
and all code quality checks have been passed.

Signed-off-by: Juan Antonio Osorio [email protected]

This commit adds the ability to mount directories from the host into containers
via both `vt run` and `vt registry run` commands. This feature enhances the
flexibility of MCP servers by allowing them to access files from the host system.

Volume Mount Format:
- Basic format: `-v host-path:container-path`
- Read-only mount: `-v host-path:container-path:ro`

The implementation supports three types of mounts:
1. Single path: When only one path is provided, it's used as both the source and
   target (e.g., `-v /path/to/dir`)
2. Different paths: When two paths are provided, the first is the host path and
   the second is the container path (e.g., `-v /host/path:/container/path`)
3. Resource URIs: For future extensibility, the source can be a URI that
   identifies a resource (e.g., `-v volume://name:/container/path`)

Security Features:
- Command injection detection: Paths are validated to prevent command injection
- Null byte detection: Paths containing null bytes are rejected
- Path normalization: All paths are normalized using filepath.Clean

Implementation Details:
- Added MountDeclaration type to represent mount declarations
- Updated Profile struct to use MountDeclaration for Read and Write mounts
- Added volume flag to both vt run and registry run commands
- Implemented processVolumeMounts function to parse and validate volume mounts
- Updated container client to handle MountDeclaration objects

The feature has been thoroughly tested with both read-write and read-only mounts,
and all code quality checks have been passed.

Signed-off-by: Juan Antonio Osorio <[email protected]>
@JAORMX JAORMX requested review from ChrisJBurns and dmjb March 26, 2025 10:40
@JAORMX JAORMX merged commit 2f8b497 into main Mar 26, 2025
@dmjb dmjb deleted the volume-mounts branch March 26, 2025 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants