MCPcopy Create free account
hub / github.com/github/gh-aw / TestCodexEngineRenderMCPConfig

Function TestCodexEngineRenderMCPConfig

pkg/workflow/codex_engine_test.go:219–339  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

217}
218
219func TestCodexEngineRenderMCPConfig(t *testing.T) {
220 engine := NewCodexEngine()
221
222 tests := []struct {
223 name string
224 tools map[string]any
225 mcpTools []string
226 expected []string
227 }{
228 {
229 name: "github tool with user_agent",
230 tools: map[string]any{
231 "github": map[string]any{},
232 },
233 mcpTools: []string{"github"},
234 expected: []string{
235 `cat > "${RUNNER_TEMP}/gh-aw/mcp-config/config.toml" << GH_AW_MCP_CONFIG_NORM_EOF`,
236 "[history]",
237 "persistence = \"none\"",
238 "",
239 "[shell_environment_policy]",
240 "inherit = \"core\"",
241 "include_only = [\"^CODEX_API_KEY$\", \"^GITHUB_PERSONAL_ACCESS_TOKEN$\", \"^HOME$\", \"^OPENAI_API_KEY$\", \"^PATH$\"]",
242 "",
243 "[mcp_servers.github]",
244 "user_agent = \"test-workflow\"",
245 "startup_timeout_sec = 120",
246 "tool_timeout_sec = 60",
247 fmt.Sprintf("container = \"ghcr.io/github/github-mcp-server:%s\"", constants.DefaultGitHubMCPServerVersion),
248 "env = { \"GITHUB_HOST\" = \"$GITHUB_SERVER_URL\", \"GITHUB_PERSONAL_ACCESS_TOKEN\" = \"$GH_AW_GITHUB_TOKEN\", \"GITHUB_READ_ONLY\" = \"1\", \"GITHUB_TOOLSETS\" = \"context,repos,issues,pull_requests\" }",
249 "env_vars = [\"GITHUB_HOST\", \"GITHUB_PERSONAL_ACCESS_TOKEN\", \"GITHUB_READ_ONLY\", \"GITHUB_TOOLSETS\"]",
250 "GH_AW_MCP_CONFIG_NORM_EOF",
251 "",
252 "# Generate JSON config for MCP gateway",
253 "GH_AW_NODE=$(which node 2>/dev/null || command -v node 2>/dev/null || echo node)",
254 "cat << GH_AW_MCP_CONFIG_NORM_EOF | \"$GH_AW_NODE\" \"${RUNNER_TEMP}/gh-aw/actions/start_mcp_gateway.cjs\"",
255 "{",
256 "\"mcpServers\": {",
257 "\"github\": {",
258 fmt.Sprintf("\"container\": \"ghcr.io/github/github-mcp-server:%s\",", constants.DefaultGitHubMCPServerVersion),
259 "\"env\": {",
260 "\"GITHUB_HOST\": \"$GITHUB_SERVER_URL\",",
261 "\"GITHUB_PERSONAL_ACCESS_TOKEN\": \"$GITHUB_MCP_SERVER_TOKEN\",",
262 "\"GITHUB_READ_ONLY\": \"1\",",
263 "\"GITHUB_TOOLSETS\": \"context,repos,issues,pull_requests\"",
264 "},",
265 "\"guard-policies\": {",
266 "\"allow-only\": {",
267 "\"min-integrity\": \"$GITHUB_MCP_GUARD_MIN_INTEGRITY\",",
268 "\"repos\": \"$GITHUB_MCP_GUARD_REPOS\"",
269 "}",
270 "}",
271 "}",
272 "},",
273 "\"gateway\": {",
274 "\"port\": $MCP_GATEWAY_PORT,",
275 "\"domain\": \"${MCP_GATEWAY_DOMAIN}\",",
276 "\"apiKey\": \"${MCP_GATEWAY_API_KEY}\",",

Callers

nothing calls this directly

Calls 6

RenderMCPConfigMethod · 0.95
NewCodexEngineFunction · 0.85
RunMethod · 0.45
StringMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected