FileRead reads a file from an environment via MCP
(envID, targetFile string)
| 127 | |
| 128 | // FileRead reads a file from an environment via MCP |
| 129 | func (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 |
| 157 | func (s *MCPServerProcess) FileWrite(envID, targetFile, contents, explanation string) error { |
no outgoing calls
no test coverage detected