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

Method RunCommand

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

RunCommand executes a command in an environment via MCP

(envID, command, explanation string)

Source from the content-addressed store, hash-verified

173
174// RunCommand executes a command in an environment via MCP
175func (s *MCPServerProcess) RunCommand(envID, command, explanation string) (string, error) {
176 ctx := context.Background()
177
178 request := mcp.CallToolRequest{}
179 request.Params.Name = "environment_run_cmd"
180 request.Params.Arguments = map[string]any{
181 "environment_source": s.repoDir,
182 "environment_id": envID,
183 "command": command,
184 "explanation": explanation,
185 }
186
187 result, err := s.client.CallTool(ctx, request)
188 if err != nil {
189 return "", err
190 }
191
192 if len(result.Content) > 0 {
193 if textContent, ok := result.Content[0].(mcp.TextContent); ok {
194 return textContent.Text, nil
195 }
196 }
197
198 return "", nil
199}
200
201// createMCPServerForRepositoryTest creates an MCP server process for repository contention testing
202func createMCPServerForRepositoryTest(t *testing.T, i int, repoDir, configDir string, singleTenant bool) *MCPServerProcess {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected