MCPcopy Create free account
hub / github.com/astercloud/aster / Read

Method Read

pkg/sandbox/cloud/volcengine.go:226–246  ·  view source on GitHub ↗

Read 读取文件

(ctx context.Context, path string)

Source from the content-addressed store, hash-verified

224
225// Read 读取文件
226func (vfs *VolcengineFS) Read(ctx context.Context, path string) (string, error) {
227 absPath := vfs.absPath(path)
228
229 result, err := vfs.mcpClient.CallTool(ctx, "computer_read_file", map[string]any{
230 "session_id": vfs.sessionID,
231 "path": absPath,
232 })
233 if err != nil {
234 return "", fmt.Errorf("read file: %w", err)
235 }
236
237 var fileContent struct {
238 Content string `json:"content"`
239 Size int64 `json:"size"`
240 }
241 if err := json.Unmarshal(result, &fileContent); err != nil {
242 return "", fmt.Errorf("parse file content: %w", err)
243 }
244
245 return fileContent.Content, nil
246}
247
248// Write 写入文件
249func (vfs *VolcengineFS) Write(ctx context.Context, path string, content string) error {

Callers

nothing calls this directly

Calls 2

absPathMethod · 0.95
CallToolMethod · 0.45

Tested by

no test coverage detected