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

Function registerUpdateTool

pkg/cli/mcp_tools_management.go:104–166  ·  view source on GitHub ↗

registerUpdateTool registers the update tool with the MCP server.

(server *mcp.Server, execCmd execCmdFunc)

Source from the content-addressed store, hash-verified

102
103// registerUpdateTool registers the update tool with the MCP server.
104func registerUpdateTool(server *mcp.Server, execCmd execCmdFunc) {
105 mcp.AddTool(server, &mcp.Tool{
106 Name: "update",
107 Annotations: &mcp.ToolAnnotations{
108 OpenWorldHint: new(true),
109 },
110 Description: `Update workflows from their source repositories and check for gh-aw updates.
111
112The command:
1131. Checks if a newer version of gh-aw is available
1142. Updates workflows using the 'source' field in the workflow frontmatter
1153. Compiles each workflow immediately after update
116
117For workflow updates, it fetches the latest version based on the current ref:
118- If the ref is a tag, it updates to the latest release (use major flag for major version updates)
119- If the ref is a branch, it fetches the latest commit from that branch
120- Otherwise, it fetches the latest commit from the default branch
121
122Returns formatted text output showing:
123- Extension update status
124- Updated workflows with their new versions
125- Compilation status for each updated workflow`,
126 Icons: []mcp.Icon{
127 {Source: "🔄"},
128 },
129 }, func(ctx context.Context, req *mcp.CallToolRequest, args updateArgs) (*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 mcpToolsManagementLog.Printf("update tool invoked: workflows=%d, major=%v, force=%v", len(args.Workflows), args.Major, args.Force)
138
139 // Build command arguments
140 cmdArgs := []string{"update"}
141
142 // Add workflow IDs if specified
143 cmdArgs = append(cmdArgs, args.Workflows...)
144
145 // Add optional flags
146 if args.Major {
147 cmdArgs = append(cmdArgs, "--major")
148 }
149 if args.Force {
150 cmdArgs = append(cmdArgs, "--force")
151 }
152
153 // Execute the CLI command
154 output, err := runMCPExecCombinedOutput(ctx, execCmd, cmdArgs...)
155
156 if err != nil {
157 return nil, nil, newMCPError(jsonrpc.CodeInternalError, "failed to update workflows", map[string]any{"error": err.Error(), "output": string(output)})
158 }
159
160 return &mcp.CallToolResult{
161 Content: []mcp.Content{

Callers 1

createMCPServerFunction · 0.85

Calls 5

newMCPErrorFunction · 0.85
runMCPExecCombinedOutputFunction · 0.85
DoneMethod · 0.80
ErrorMethod · 0.45
PrintfMethod · 0.45

Tested by

no test coverage detected