diff --git a/hack/bats/tests/mcp.bats b/hack/bats/tests/mcp.bats index 733d736877b..85e91600251 100644 --- a/hack/bats/tests/mcp.bats +++ b/hack/bats/tests/mcp.bats @@ -253,8 +253,6 @@ tools_call() { } @test 'write_file creates the directory if it does not yet exist' { - skip "see https://github.com/lima-vm/lima/issues/4174" - limactl shell "$NAME" rm -rf /tmp/tmp tools_call write_file '{"path":"/tmp/tmp/tmp","content":"tmp"}' json=$output diff --git a/pkg/mcp/toolset/filesystem.go b/pkg/mcp/toolset/filesystem.go index e60032b24aa..1df4b088b58 100644 --- a/pkg/mcp/toolset/filesystem.go +++ b/pkg/mcp/toolset/filesystem.go @@ -9,6 +9,7 @@ import ( "io" "os" "path" + "path/filepath" "github.com/modelcontextprotocol/go-sdk/mcp" @@ -87,6 +88,11 @@ func (ts *ToolSet) WriteFile(_ context.Context, if err != nil { return nil, nil, err } + dir := filepath.Dir(guestPath) + err = ts.sftp.MkdirAll(dir) + if err != nil { + return nil, nil, err + } f, err := ts.sftp.Create(guestPath) if err != nil { return nil, nil, err