Skip to content

Commit 62aa7f7

Browse files
authored
Merge pull request #4331 from pragneshbagary/master
fix: handle write_file toolset issue (#4174)
2 parents e21b634 + a34f9b1 commit 62aa7f7

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

hack/bats/tests/mcp.bats

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,6 @@ tools_call() {
253253
}
254254

255255
@test 'write_file creates the directory if it does not yet exist' {
256-
skip "see https://github.com/lima-vm/lima/issues/4174"
257-
258256
limactl shell "$NAME" rm -rf /tmp/tmp
259257
tools_call write_file '{"path":"/tmp/tmp/tmp","content":"tmp"}'
260258
json=$output

pkg/mcp/toolset/filesystem.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"io"
1010
"os"
1111
"path"
12+
"path/filepath"
1213

1314
"github.com/modelcontextprotocol/go-sdk/mcp"
1415

@@ -87,6 +88,11 @@ func (ts *ToolSet) WriteFile(_ context.Context,
8788
if err != nil {
8889
return nil, nil, err
8990
}
91+
dir := filepath.Dir(guestPath)
92+
err = ts.sftp.MkdirAll(dir)
93+
if err != nil {
94+
return nil, nil, err
95+
}
9096
f, err := ts.sftp.Create(guestPath)
9197
if err != nil {
9298
return nil, nil, err

0 commit comments

Comments
 (0)