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

Method renderGitHubTOML

pkg/workflow/mcp_renderer_github.go:109–207  ·  view source on GitHub ↗

renderGitHubTOML generates GitHub MCP configuration in TOML format (for Codex engine)

(yaml *strings.Builder, githubTool map[string]any, workflowData *WorkflowData)

Source from the content-addressed store, hash-verified

107
108// renderGitHubTOML generates GitHub MCP configuration in TOML format (for Codex engine)
109func (r *MCPConfigRendererUnified) renderGitHubTOML(yaml *strings.Builder, githubTool map[string]any, workflowData *WorkflowData) {
110 githubType := getGitHubType(githubTool)
111 readOnly := getGitHubReadOnly()
112 lockdown := getGitHubLockdown(githubTool)
113 toolsets := getGitHubToolsets(githubTool)
114
115 mcpRendererLog.Printf("Rendering GitHub MCP TOML: type=%s, read_only=%t, lockdown=%t, toolsets=%s", githubType, readOnly, lockdown, toolsets)
116
117 yaml.WriteString(" \n")
118 yaml.WriteString(" [mcp_servers.github]\n")
119
120 // Add user_agent field defaulting to workflow identifier
121 userAgent := "github-agentic-workflow"
122 if workflowData != nil {
123 // Check if user_agent is configured in engine config first
124 if workflowData.EngineConfig != nil && workflowData.EngineConfig.UserAgent != "" {
125 userAgent = workflowData.EngineConfig.UserAgent
126 } else if workflowData.Name != "" {
127 // Fall back to sanitizing the workflow name as an artifact/user-agent identifier
128 userAgent = SanitizeArtifactIdentifier(workflowData.Name)
129 }
130 }
131 yaml.WriteString(" user_agent = \"" + userAgent + "\"\n")
132
133 // Use tools.startup-timeout if specified, otherwise default to DefaultMCPStartupTimeout
134 // For GitHub Actions expressions, fall back to default (TOML format doesn't support expressions)
135 startupTimeout := int(constants.DefaultMCPStartupTimeout / time.Second)
136 if workflowData != nil && workflowData.ToolsStartupTimeout != "" {
137 if n := templatableIntValue(&workflowData.ToolsStartupTimeout); n > 0 {
138 startupTimeout = n
139 }
140 }
141 fmt.Fprintf(yaml, " startup_timeout_sec = %d\n", startupTimeout)
142
143 // Use tools.timeout if specified, otherwise default to DefaultToolTimeout
144 // For GitHub Actions expressions, fall back to default (TOML format doesn't support expressions)
145 toolTimeout := int(constants.DefaultToolTimeout / time.Second)
146 if workflowData != nil && workflowData.ToolsTimeout != "" {
147 if n := templatableIntValue(&workflowData.ToolsTimeout); n > 0 {
148 toolTimeout = n
149 }
150 }
151 fmt.Fprintf(yaml, " tool_timeout_sec = %d\n", toolTimeout)
152
153 // Check if remote mode is enabled
154 if githubType == GitHubMCPModeRemote {
155 mcpRendererLog.Printf("GitHub MCP TOML remote mode: readonly_endpoint=%t", readOnly)
156 // Remote mode - use hosted GitHub MCP server with streamable HTTP
157 // Use readonly endpoint if read-only mode is enabled
158 if readOnly {
159 yaml.WriteString(" url = \"https://api.githubcopilot.com/mcp-readonly/\"\n")
160 } else {
161 yaml.WriteString(" url = \"https://api.githubcopilot.com/mcp/\"\n")
162 }
163
164 // Use bearer_token_env_var for authentication
165 yaml.WriteString(" bearer_token_env_var = \"GH_AW_GITHUB_TOKEN\"\n")
166 } else {

Callers 1

RenderGitHubMCPMethod · 0.95

Calls 12

SortedKeysFunction · 0.92
getGitHubTypeFunction · 0.85
getGitHubReadOnlyFunction · 0.85
getGitHubLockdownFunction · 0.85
getGitHubToolsetsFunction · 0.85
templatableIntValueFunction · 0.85
getGitHubCustomArgsFunction · 0.85
buildGitHubMCPEnvVarsFunction · 0.85
PrintfMethod · 0.45

Tested by

no test coverage detected