|
| 1 | +package github |
| 2 | + |
| 3 | +import ( |
| 4 | +"context" |
| 5 | +"fmt" |
| 6 | + |
| 7 | +"github.com/github/github-mcp-server/pkg/translations" |
| 8 | +"github.com/mark3labs/mcp-go/mcp" |
| 9 | +"github.com/mark3labs/mcp-go/server" |
| 10 | +) |
| 11 | + |
| 12 | +// IssueToFixWorkflowPrompt provides a guided workflow for creating an issue and then generating a PR to fix it |
| 13 | +funcIssueToFixWorkflowPrompt(t translations.TranslationHelperFunc) (tool mcp.Prompt,handler server.PromptHandlerFunc) { |
| 14 | +returnmcp.NewPrompt("IssueToFixWorkflow", |
| 15 | +mcp.WithPromptDescription(t("PROMPT_ISSUE_TO_FIX_WORKFLOW_DESCRIPTION","Create an issue for a problem and then generate a pull request to fix it")), |
| 16 | +mcp.WithArgument("owner",mcp.ArgumentDescription("Repository owner"),mcp.RequiredArgument()), |
| 17 | +mcp.WithArgument("repo",mcp.ArgumentDescription("Repository name"),mcp.RequiredArgument()), |
| 18 | +mcp.WithArgument("title",mcp.ArgumentDescription("Issue title"),mcp.RequiredArgument()), |
| 19 | +mcp.WithArgument("description",mcp.ArgumentDescription("Issue description"),mcp.RequiredArgument()), |
| 20 | +mcp.WithArgument("labels",mcp.ArgumentDescription("Comma-separated list of labels to apply (optional)")), |
| 21 | +mcp.WithArgument("assignees",mcp.ArgumentDescription("Comma-separated list of assignees (optional)")), |
| 22 | +),func(_ context.Context,request mcp.GetPromptRequest) (*mcp.GetPromptResult,error) { |
| 23 | +owner:=request.Params.Arguments["owner"] |
| 24 | +repo:=request.Params.Arguments["repo"] |
| 25 | +title:=request.Params.Arguments["title"] |
| 26 | +description:=request.Params.Arguments["description"] |
| 27 | + |
| 28 | +labels:="" |
| 29 | +ifl,exists:=request.Params.Arguments["labels"];exists { |
| 30 | +labels=fmt.Sprintf("%v",l) |
| 31 | +} |
| 32 | + |
| 33 | +assignees:="" |
| 34 | +ifa,exists:=request.Params.Arguments["assignees"];exists { |
| 35 | +assignees=fmt.Sprintf("%v",a) |
| 36 | +} |
| 37 | + |
| 38 | +messages:= []mcp.PromptMessage{ |
| 39 | +{ |
| 40 | +Role:"system", |
| 41 | +Content:mcp.NewTextContent("You are a development workflow assistant helping to create GitHub issues and generate corresponding pull requests to fix them. You should: 1) Create a well-structured issue with clear problem description, 2) Assign it to Copilot coding agent to generate a solution, and 3) Monitor the PR creation process."), |
| 42 | +}, |
| 43 | +{ |
| 44 | +Role:"user", |
| 45 | +Content:mcp.NewTextContent(fmt.Sprintf("I need to create an issue titled '%s' in %s/%s and then have a PR generated to fix it. The issue description is: %s%s%s", |
| 46 | +title,owner,repo,description, |
| 47 | +func()string { |
| 48 | +iflabels!="" { |
| 49 | +returnfmt.Sprintf("\n\nLabels to apply: %s",labels) |
| 50 | +} |
| 51 | +return"" |
| 52 | +}(), |
| 53 | +func()string { |
| 54 | +ifassignees!="" { |
| 55 | +returnfmt.Sprintf("\nAssignees: %s",assignees) |
| 56 | +} |
| 57 | +return"" |
| 58 | +}())), |
| 59 | +}, |
| 60 | +{ |
| 61 | +Role:"assistant", |
| 62 | +Content:mcp.NewTextContent(fmt.Sprintf("I'll help you create the issue '%s' in %s/%s and then coordinate with Copilot to generate a fix. Let me start by creating the issue with the provided details.",title,owner,repo)), |
| 63 | +}, |
| 64 | +{ |
| 65 | +Role:"user", |
| 66 | +Content:mcp.NewTextContent("Perfect! Please:\n1. Create the issue with the title, description, labels, and assignees\n2. Once created, assign it to Copilot coding agent to generate a solution\n3. Monitor the process and let me know when the PR is ready for review"), |
| 67 | +}, |
| 68 | +{ |
| 69 | +Role:"assistant", |
| 70 | +Content:mcp.NewTextContent("Excellent plan! Here's what I'll do:\n\n1. ✅ Create the issue with all specified details\n2. 🤖 Assign to Copilot coding agent for automated fix\n3. 📋 Monitor progress and notify when PR is created\n4. 🔍 Provide PR details for your review\n\nLet me start by creating the issue."), |
| 71 | +}, |
| 72 | +} |
| 73 | +return&mcp.GetPromptResult{ |
| 74 | +Messages:messages, |
| 75 | +},nil |
| 76 | +} |
| 77 | +} |