@@ -163,9 +163,63 @@ func NewServer() *MCPServer {
163
163
mcp .WithMIMEType ("text/plain" ),
164
164
), handleRootHelpResource )
165
165
166
+ // Static help resources for each command
167
+ mcpServer .AddResource (mcp .NewResource (
168
+ "func://create/docs" ,
169
+ "Create Command Help" ,
170
+ mcp .WithResourceDescription ("--help output of the 'create' command" ),
171
+ mcp .WithMIMEType ("text/plain" ),
172
+ ), func (ctx context.Context , request mcp.ReadResourceRequest ) ([]mcp.ResourceContents , error ) {
173
+ return runHelpCommand ("create" , "func://create/docs" )
174
+ })
175
+
176
+ mcpServer .AddResource (mcp .NewResource (
177
+ "func://build/docs" ,
178
+ "Build Command Help" ,
179
+ mcp .WithResourceDescription ("--help output of the 'build' command" ),
180
+ mcp .WithMIMEType ("text/plain" ),
181
+ ), func (ctx context.Context , request mcp.ReadResourceRequest ) ([]mcp.ResourceContents , error ) {
182
+ return runHelpCommand ("build" , "func://build/docs" )
183
+ })
184
+
185
+ mcpServer .AddResource (mcp .NewResource (
186
+ "func://deploy/docs" ,
187
+ "Deploy Command Help" ,
188
+ mcp .WithResourceDescription ("--help output of the 'deploy' command" ),
189
+ mcp .WithMIMEType ("text/plain" ),
190
+ ), func (ctx context.Context , request mcp.ReadResourceRequest ) ([]mcp.ResourceContents , error ) {
191
+ return runHelpCommand ("deploy" , "func://deploy/docs" )
192
+ })
193
+
194
+ mcpServer .AddResource (mcp .NewResource (
195
+ "func://list/docs" ,
196
+ "List Command Help" ,
197
+ mcp .WithResourceDescription ("--help output of the 'list' command" ),
198
+ mcp .WithMIMEType ("text/plain" ),
199
+ ), func (ctx context.Context , request mcp.ReadResourceRequest ) ([]mcp.ResourceContents , error ) {
200
+ return runHelpCommand ("list" , "func://list/docs" )
201
+ })
202
+
203
+ mcpServer .AddResource (mcp .NewResource (
204
+ "func://delete/docs" ,
205
+ "Delete Command Help" ,
206
+ mcp .WithResourceDescription ("--help output of the 'delete' command" ),
207
+ mcp .WithMIMEType ("text/plain" ),
208
+ ), func (ctx context.Context , request mcp.ReadResourceRequest ) ([]mcp.ResourceContents , error ) {
209
+ return runHelpCommand ("delete" , "func://delete/docs" )
210
+ })
211
+
166
212
mcpServer .AddPrompt (mcp .NewPrompt ("help" ,
167
213
mcp .WithPromptDescription ("help prompt for the root command" ),
168
- ), handleHelpPrompt )
214
+ ), handleRootHelpPrompt )
215
+
216
+ mcpServer .AddPrompt (mcp .NewPrompt ("cmd_help" ,
217
+ mcp .WithPromptDescription ("help prompt for a specific command" ),
218
+ mcp .WithArgument ("cmd" ,
219
+ mcp .ArgumentDescription ("The command for which help is requested" ),
220
+ mcp .RequiredArgument (),
221
+ ),
222
+ ), handleCmdHelpPrompt )
169
223
170
224
return & MCPServer {
171
225
server : mcpServer ,
@@ -191,7 +245,45 @@ func handleRootHelpResource(ctx context.Context, request mcp.ReadResourceRequest
191
245
}, nil
192
246
}
193
247
194
- func handleHelpPrompt (ctx context.Context , request mcp.GetPromptRequest ) (* mcp.GetPromptResult , error ) {
248
+ func runHelpCommand (cmd string , uri string ) ([]mcp.ResourceContents , error ) {
249
+ content , err := exec .Command ("func" , cmd , "--help" ).Output ()
250
+ if err != nil {
251
+ return nil , err
252
+ }
253
+ return []mcp.ResourceContents {
254
+ mcp.TextResourceContents {
255
+ URI : uri ,
256
+ MIMEType : "text/plain" ,
257
+ Text : string (content ),
258
+ },
259
+ }, nil
260
+ }
261
+
262
+ func handleCmdHelpPrompt (ctx context.Context , request mcp.GetPromptRequest ) (* mcp.GetPromptResult , error ) {
263
+ cmd := request .Params .Arguments ["cmd" ]
264
+ if cmd == "" {
265
+ return nil , fmt .Errorf ("cmd is required" )
266
+ }
267
+
268
+ return mcp .NewGetPromptResult (
269
+ "Cmd Help Prompt" ,
270
+ []mcp.PromptMessage {
271
+ mcp .NewPromptMessage (
272
+ mcp .RoleUser ,
273
+ mcp .NewTextContent ("What can I do with this func command? Please provide help for the command: " + cmd ),
274
+ ),
275
+ mcp .NewPromptMessage (
276
+ mcp .RoleAssistant ,
277
+ mcp .NewEmbeddedResource (mcp.TextResourceContents {
278
+ URI : fmt .Sprintf ("func://%s/docs" , cmd ),
279
+ MIMEType : "text/plain" ,
280
+ }),
281
+ ),
282
+ },
283
+ ), nil
284
+ }
285
+
286
+ func handleRootHelpPrompt (ctx context.Context , request mcp.GetPromptRequest ) (* mcp.GetPromptResult , error ) {
195
287
return mcp .NewGetPromptResult (
196
288
"Help Prompt" ,
197
289
[]mcp.PromptMessage {
0 commit comments