From fb0714562d56942ca26f9d4108c616f15d8c8025 Mon Sep 17 00:00:00 2001 From: Deluan Date: Sat, 19 Apr 2025 14:46:54 -0400 Subject: [PATCH] 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. --- core/agents/mcp/mcp_agent.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/agents/mcp/mcp_agent.go b/core/agents/mcp/mcp_agent.go index 9634a8bb7..5f039d966 100644 --- a/core/agents/mcp/mcp_agent.go +++ b/core/agents/mcp/mcp_agent.go @@ -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)