MCPcopy Create free account
hub / github.com/lima-vm/lima / WriteFile

Method WriteFile

pkg/mcp/toolset/filesystem.go:81–112  ·  view source on GitHub ↗
(_ context.Context,
	_ *mcp.CallToolRequest, args msi.WriteFileParams,
)

Source from the content-addressed store, hash-verified

79}
80
81func (ts *ToolSet) WriteFile(_ context.Context,
82 _ *mcp.CallToolRequest, args msi.WriteFileParams,
83) (*mcp.CallToolResult, *msi.WriteFileResult, error) {
84 if ts.inst == nil {
85 return nil, nil, errors.New("instance not registered")
86 }
87 guestPath, err := ts.TranslateHostPath(args.Path)
88 if err != nil {
89 return nil, nil, err
90 }
91 dir := filepath.Dir(guestPath)
92 err = ts.sftp.MkdirAll(dir)
93 if err != nil {
94 return nil, nil, err
95 }
96 f, err := ts.sftp.Create(guestPath)
97 if err != nil {
98 return nil, nil, err
99 }
100 defer f.Close()
101 _, err = f.Write([]byte(args.Content))
102 if err != nil {
103 return nil, nil, err
104 }
105 res := &msi.WriteFileResult{}
106 return &mcp.CallToolResult{
107 // Gemini:
108 // A success message, e.g., `Successfully overwrote file: /path/to/your/file.txt`
109 // or `Successfully created and wrote to new file: /path/to/new/file.txt.`
110 StructuredContent: res,
111 }, res, nil
112}
113
114func (ts *ToolSet) Glob(_ context.Context,
115 _ *mcp.CallToolRequest, args msi.GlobParams,

Callers 15

writeGuestFilesFunction · 0.80
TestDiscoverDriversInDirFunction · 0.80
loadCacheFunction · 0.80
TestRedownloadRemoteFunction · 0.80
TestDownloadLocalFunction · 0.80
TestDownloadCompressedFunction · 0.80
FuzzDownloadFunction · 0.80
fetchFunction · 0.80
downloadHTTPFunction · 0.80
FuzzIsISO9660Function · 0.80
SaveEventStateMethod · 0.80

Calls 4

TranslateHostPathMethod · 0.95
CreateMethod · 0.65
CloseMethod · 0.45
WriteMethod · 0.45

Tested by 15

TestDiscoverDriversInDirFunction · 0.64
TestRedownloadRemoteFunction · 0.64
TestDownloadLocalFunction · 0.64
TestDownloadCompressedFunction · 0.64
FuzzDownloadFunction · 0.64
FuzzIsISO9660Function · 0.64
FuzzConvertToRawFunction · 0.64
writeNonISOFunction · 0.64