@@ -72,6 +72,25 @@ func NewServer() *MCPServer {
72
72
handleListTool ,
73
73
)
74
74
75
+ mcpServer .AddTool (
76
+ mcp .NewTool ("build" ,
77
+ mcp .WithDescription ("Builds the function image in the current directory" ),
78
+ mcp .WithString ("cwd" ,
79
+ mcp .Required (),
80
+ mcp .Description ("Current working directory of the MCP client" ),
81
+ ),
82
+ mcp .WithString ("builder" ,
83
+ mcp .Required (),
84
+ mcp .Description ("Builder to be used to build the function image" ),
85
+ ),
86
+ mcp .WithString ("registry" ,
87
+ mcp .Required (),
88
+ mcp .Description ("Name of the registry to be used to push the function image" ),
89
+ ),
90
+ ),
91
+ handleBuildTool ,
92
+ )
93
+
75
94
return & MCPServer {
76
95
server : mcpServer ,
77
96
}
@@ -154,3 +173,30 @@ func handleListTool(
154
173
body := []byte (fmt .Sprintf (`{"result": "%s"}` , out ))
155
174
return mcp .NewToolResultText (string (body )), nil
156
175
}
176
+
177
+ func handleBuildTool (
178
+ ctx context.Context ,
179
+ request mcp.CallToolRequest ,
180
+ ) (* mcp.CallToolResult , error ) {
181
+ cwd , err := request .RequireString ("cwd" )
182
+ if err != nil {
183
+ return mcp .NewToolResultError (err .Error ()), nil
184
+ }
185
+ builder , err := request .RequireString ("builder" )
186
+ if err != nil {
187
+ return mcp .NewToolResultError (err .Error ()), nil
188
+ }
189
+ registry , err := request .RequireString ("registry" )
190
+ if err != nil {
191
+ return mcp .NewToolResultError (err .Error ()), nil
192
+ }
193
+
194
+ cmd := exec .Command ("func" , "build" , "--builder" , builder , "--registry" , registry )
195
+ cmd .Dir = cwd
196
+ out , err := cmd .Output ()
197
+ if err != nil {
198
+ return mcp .NewToolResultError (err .Error ()), nil
199
+ }
200
+ body := []byte (fmt .Sprintf (`{"result": "%s"}` , out ))
201
+ return mcp .NewToolResultText (string (body )), nil
202
+ }
0 commit comments