MCPcopy
hub / github.com/dagger/container-use / FileRead

Method FileRead

cmd/container-use/stdio_test.go:129–154  ·  view source on GitHub ↗

FileRead reads a file from an environment via MCP

(envID, targetFile string)

Source from the content-addressed store, hash-verified

127
128// FileRead reads a file from an environment via MCP
129func (s *MCPServerProcess) FileRead(envID, targetFile string) (string, error) {
130 ctx := context.Background()
131
132 request := mcp.CallToolRequest{}
133 request.Params.Name = "environment_file_read"
134 request.Params.Arguments = map[string]any{
135 "environment_source": s.repoDir,
136 "environment_id": envID,
137 "target_file": targetFile,
138 "should_read_entire_file": true,
139 "explanation": "Reading file for verification",
140 }
141
142 result, err := s.client.CallTool(ctx, request)
143 if err != nil {
144 return "", err
145 }
146
147 if len(result.Content) > 0 {
148 if textContent, ok := result.Content[0].(mcp.TextContent); ok {
149 return textContent.Text, nil
150 }
151 }
152
153 return "", nil
154}
155
156// FileWrite writes a file to an environment via MCP
157func (s *MCPServerProcess) FileWrite(envID, targetFile, contents, explanation string) error {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected