@@ -113,9 +113,53 @@ func NewServer() *MCPServer {
113113 mcp .WithMIMEType ("text/plain" ),
114114 ), handleRootHelpResource )
115115
116+ // Static help resources for each command
117+ mcpServer .AddResource (mcp .NewResource (
118+ "func://create/docs" ,
119+ "Create Command Help" ,
120+ mcp .WithResourceDescription ("--help output of the 'create' command" ),
121+ mcp .WithMIMEType ("text/plain" ),
122+ ), handleCreateHelpResource )
123+
124+ mcpServer .AddResource (mcp .NewResource (
125+ "func://build/docs" ,
126+ "Build Command Help" ,
127+ mcp .WithResourceDescription ("--help output of the 'build' command" ),
128+ mcp .WithMIMEType ("text/plain" ),
129+ ), handleBuildHelpResource )
130+
131+ mcpServer .AddResource (mcp .NewResource (
132+ "func://deploy/docs" ,
133+ "Deploy Command Help" ,
134+ mcp .WithResourceDescription ("--help output of the 'deploy' command" ),
135+ mcp .WithMIMEType ("text/plain" ),
136+ ), handleDeployHelpResource )
137+
138+ mcpServer .AddResource (mcp .NewResource (
139+ "func://list/docs" ,
140+ "List Command Help" ,
141+ mcp .WithResourceDescription ("--help output of the 'list' command" ),
142+ mcp .WithMIMEType ("text/plain" ),
143+ ), handleListHelpResource )
144+
145+ mcpServer .AddResource (mcp .NewResource (
146+ "func://delete/docs" ,
147+ "Delete Command Help" ,
148+ mcp .WithResourceDescription ("--help output of the 'delete' command" ),
149+ mcp .WithMIMEType ("text/plain" ),
150+ ), handleDeleteHelpResource )
151+
116152 mcpServer .AddPrompt (mcp .NewPrompt ("help" ,
117153 mcp .WithPromptDescription ("help prompt for the root command" ),
118- ), handleHelpPrompt )
154+ ), handleRootHelpPrompt )
155+
156+ mcpServer .AddPrompt (mcp .NewPrompt ("cmd_help" ,
157+ mcp .WithPromptDescription ("help prompt for a specific command" ),
158+ mcp .WithArgument ("cmd" ,
159+ mcp .ArgumentDescription ("The command for which help is requested" ),
160+ mcp .RequiredArgument (),
161+ ),
162+ ), handleCmdHelpPrompt )
119163
120164 return & MCPServer {
121165 server : mcpServer ,
@@ -141,7 +185,65 @@ func handleRootHelpResource(ctx context.Context, request mcp.ReadResourceRequest
141185 }, nil
142186}
143187
144- func handleHelpPrompt (ctx context.Context , request mcp.GetPromptRequest ) (* mcp.GetPromptResult , error ) {
188+ func handleCreateHelpResource (ctx context.Context , request mcp.ReadResourceRequest ) ([]mcp.ResourceContents , error ) {
189+ return runHelpCommand ("create" , "func://create/docs" )
190+ }
191+
192+ func handleBuildHelpResource (ctx context.Context , request mcp.ReadResourceRequest ) ([]mcp.ResourceContents , error ) {
193+ return runHelpCommand ("build" , "func://build/docs" )
194+ }
195+
196+ func handleDeployHelpResource (ctx context.Context , request mcp.ReadResourceRequest ) ([]mcp.ResourceContents , error ) {
197+ return runHelpCommand ("deploy" , "func://deploy/docs" )
198+ }
199+
200+ func handleListHelpResource (ctx context.Context , request mcp.ReadResourceRequest ) ([]mcp.ResourceContents , error ) {
201+ return runHelpCommand ("list" , "func://list/docs" )
202+ }
203+
204+ func handleDeleteHelpResource (ctx context.Context , request mcp.ReadResourceRequest ) ([]mcp.ResourceContents , error ) {
205+ return runHelpCommand ("delete" , "func://delete/docs" )
206+ }
207+
208+ func runHelpCommand (cmd string , uri string ) ([]mcp.ResourceContents , error ) {
209+ content , err := exec .Command ("func" , cmd , "--help" ).Output ()
210+ if err != nil {
211+ return nil , err
212+ }
213+ return []mcp.ResourceContents {
214+ mcp.TextResourceContents {
215+ URI : uri ,
216+ MIMEType : "text/plain" ,
217+ Text : string (content ),
218+ },
219+ }, nil
220+ }
221+
222+ func handleCmdHelpPrompt (ctx context.Context , request mcp.GetPromptRequest ) (* mcp.GetPromptResult , error ) {
223+ cmd := request .Params .Arguments ["cmd" ]
224+ if cmd == "" {
225+ return nil , fmt .Errorf ("cmd is required" )
226+ }
227+
228+ return mcp .NewGetPromptResult (
229+ "Cmd Help Prompt" ,
230+ []mcp.PromptMessage {
231+ mcp .NewPromptMessage (
232+ mcp .RoleUser ,
233+ mcp .NewTextContent ("What can I do with this func command? Please provide help for the command: " + cmd ),
234+ ),
235+ mcp .NewPromptMessage (
236+ mcp .RoleAssistant ,
237+ mcp .NewEmbeddedResource (mcp.TextResourceContents {
238+ URI : fmt .Sprintf ("func://%s/docs" , cmd ),
239+ MIMEType : "text/plain" ,
240+ }),
241+ ),
242+ },
243+ ), nil
244+ }
245+
246+ func handleRootHelpPrompt (ctx context.Context , request mcp.GetPromptRequest ) (* mcp.GetPromptResult , error ) {
145247 return mcp .NewGetPromptResult (
146248 "Help Prompt" ,
147249 []mcp.PromptMessage {
0 commit comments