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

Function registerCompileTool

pkg/cli/mcp_tools_readonly.go:90–264  ·  view source on GitHub ↗

registerCompileTool registers the compile tool with the MCP server. manifestCacheFile is the path to a temp JSON file containing pre-cached gh-aw-manifests collected at server startup; it is passed to each compile subprocess via --prior-manifest-file so the compiler uses tamper-proof manifests for s

(server *mcp.Server, execCmd execCmdFunc, manifestCacheFile string)

Source from the content-addressed store, hash-verified

88// enforcement. An empty string disables this feature.
89// Returns an error if schema generation fails, which causes the server to stop registering tools.
90func registerCompileTool(server *mcp.Server, execCmd execCmdFunc, manifestCacheFile string) error {
91 // Generate schema with elicitation defaults
92 compileSchema, err := GenerateSchema[compileArgs]()
93 if err != nil {
94 mcpLog.Printf("Failed to generate compile tool schema: %v", err)
95 return err
96 }
97 // Add elicitation default: strict defaults to true (most common case)
98 if err := AddSchemaDefault(compileSchema, "strict", true); err != nil {
99 mcpLog.Printf("Failed to add default for strict: %v", err)
100 }
101
102 mcp.AddTool(server, &mcp.Tool{
103 Name: "compile",
104 Annotations: &mcp.ToolAnnotations{
105 IdempotentHint: true,
106 DestructiveHint: boolPtr(false),
107 OpenWorldHint: boolPtr(false),
108 },
109 Description: `Compile Markdown workflows to GitHub Actions YAML with optional static analysis tools.
110
111⚠️ IMPORTANT: Any change to .github/workflows/*.md files MUST be compiled using this tool.
112This tool generates .lock.yml files from .md workflow files. The .lock.yml files are what GitHub Actions
113actually executes, so failing to compile after modifying a .md file means your changes won't take effect.
114
115Workflows use strict mode validation by default (unless frontmatter sets strict: false).
116Strict mode enforces: action pinning to SHAs, explicit network config, safe-outputs for write operations,
117and refuses write permissions and deprecated fields. Use the strict parameter to override frontmatter settings.
118
119Returns JSON array with validation results for each workflow:
120- workflow: Name of the workflow file
121- valid: Boolean indicating if compilation was successful
122- errors: Array of error objects with type, message, and optional line number
123- warnings: Array of warning objects
124- compiled_file: Path to the generated .lock.yml file`,
125 InputSchema: compileSchema,
126 Icons: []mcp.Icon{
127 {Source: "📋"},
128 },
129 }, func(ctx context.Context, req *mcp.CallToolRequest, args compileArgs) (*mcp.CallToolResult, any, error) {
130 // Check for cancellation before starting
131 select {
132 case <-ctx.Done():
133 return nil, nil, newMCPError(jsonrpc.CodeInternalError, "request cancelled", ctx.Err().Error())
134 default:
135 }
136
137 // dockerUnavailableWarning is set when Docker is not accessible but the compile
138 // should still proceed without the static-analysis tools. After the compile
139 // attempt, the warning is appended to workflow results in the JSON output so
140 // the caller knows linting was skipped, while preserving each workflow's
141 // valid/invalid status.
142 var dockerUnavailableWarning string
143
144 // Check if any static analysis tools are requested that require Docker images
145 if args.Zizmor || args.Poutine || args.Actionlint || args.RunnerGuard {
146 // Check if Docker images are available; if not, start downloading and return retry message
147 if err := CheckAndPrepareDockerImages(ctx, args.Zizmor, args.Poutine, args.Actionlint, args.RunnerGuard); err != nil {

Calls 10

AddSchemaDefaultFunction · 0.85
newMCPErrorFunction · 0.85
buildDockerErrorResultsFunction · 0.85
runMCPExecOutputFunction · 0.85
DoneMethod · 0.80
boolPtrFunction · 0.70
PrintfMethod · 0.45
ErrorMethod · 0.45