RenderCustomMCPToolConfigHandler is a function type that engines must provide to render their specific MCP config FormatStepWithCommandAndEnv formats a GitHub Actions step with command and environment variables. This shared function extracts the common pattern used by Copilot and Codex engines. Par
(stepLines []string, command string, env map[string]string)
| 279 | // Returns: |
| 280 | // - []string: Complete step lines including run command and env section |
| 281 | func FormatStepWithCommandAndEnv(stepLines []string, command string, env map[string]string) []string { |
| 282 | engineHelpersLog.Printf("Formatting step with command and %d environment variables", len(env)) |
| 283 | // Add the run section |
| 284 | stepLines = append(stepLines, " run: |") |
| 285 | |
| 286 | // Split command into lines and indent them properly |
| 287 | commandLines := strings.SplitSeq(command, "\n") |
| 288 | for line := range commandLines { |
| 289 | // Don't add indentation to empty lines |
| 290 | if line == "" { |
| 291 | stepLines = append(stepLines, "") |
| 292 | } else { |
| 293 | stepLines = append(stepLines, " "+line) |
| 294 | } |
| 295 | } |
| 296 | |
| 297 | // Add environment variables |
| 298 | if len(env) > 0 { |
| 299 | stepLines = append(stepLines, " env:") |
| 300 | for _, key := range sliceutil.SortedKeys(env) { |
| 301 | value := env[key] |
| 302 | stepLines = appendEnvVarLine(stepLines, key, value) |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | return stepLines |
| 307 | } |
| 308 | |
| 309 | // appendEnvVarLine appends a YAML env var entry to lines. |
| 310 | // If the value contains embedded newlines (e.g. from a multi-line YAML block scalar |