From a34f9b10573c6e4194573a68975223d544f29aab Mon Sep 17 00:00:00 2001 From: pragneshbagary Date: Wed, 12 Nov 2025 12:43:34 +0530 Subject: [PATCH] mcp: create parent directories in write_file Signed-off-by: pragneshbagary --- hack/bats/tests/mcp.bats | 2 -- pkg/mcp/toolset/filesystem.go | 6 ++++++ 2 files changed, 6 insertions(+), 2 deletions(-) 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