feat: grant filesystem access for WASM modules in MCPAgent

Enhance the MCPAgent's WASM module initialization by granting access to the host filesystem. This is necessary for DNS lookups and other operations that may depend on filesystem access. Added comments to highlight the security implications of this change and the need for potential restrictions in the future.
This commit is contained in:
Deluan 2025-04-19 14:46:54 -04:00
parent 6b89f7ab63
commit fb0714562d

View File

@ -343,7 +343,11 @@ func (a *MCPAgent) startWasmModule(ctx context.Context) (hostStdinWriter io.Writ
WithStdin(wasmStdinReader).
WithStdout(wasmStdoutWriter).
WithStderr(os.Stderr).
WithArgs(McpServerPath)
WithArgs(McpServerPath).
// Grant access to the host filesystem. Needed for DNS lookup (/etc/resolv.conf)
// and potentially other operations depending on the module.
// SECURITY: This grants broad access; consider more restricted FS if needed.
WithFS(os.DirFS("/"))
log.Debug(ctx, "Compiling WASM module (using cache if enabled)...")
// Compile module using the shared runtime (which uses the configured cache)