Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions pkg/github/issues.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,9 @@ func createIssue(client *github.Client, t translations.TranslationHelperFunc) (t
},
),
),
mcp.WithNumber("milestone",
mcp.Description("Milestone number"),
),
),
func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
owner, err := requiredParam[string](request, "owner")
Expand Down Expand Up @@ -294,12 +297,24 @@ func createIssue(client *github.Client, t translations.TranslationHelperFunc) (t
return mcp.NewToolResultError(err.Error()), nil
}

// Get optional milestone
milestone, err := optionalIntParam(request, "milestone")
if err != nil {
return mcp.NewToolResultError(err.Error()), nil
}

var milestoneNum *int
if milestone != 0 {
milestoneNum = &milestone
}

// Create the issue request
issueRequest := &github.IssueRequest{
Title: github.Ptr(title),
Body: github.Ptr(body),
Assignees: &assignees,
Labels: &labels,
Milestone: milestoneNum,
}

issue, resp, err := client.Issues.Create(ctx, owner, repo, issueRequest)
Expand Down
4 changes: 4 additions & 0 deletions pkg/github/issues_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ func Test_CreateIssue(t *testing.T) {
assert.Contains(t, tool.InputSchema.Properties, "body")
assert.Contains(t, tool.InputSchema.Properties, "assignees")
assert.Contains(t, tool.InputSchema.Properties, "labels")
assert.Contains(t, tool.InputSchema.Properties, "milestone")
assert.ElementsMatch(t, tool.InputSchema.Required, []string{"owner", "repo", "title"})

// Setup mock issue for success case
Expand All @@ -403,6 +404,7 @@ func Test_CreateIssue(t *testing.T) {
HTMLURL: github.Ptr("https://github.com/owner/repo/issues/123"),
Assignees: []*github.User{{Login: github.Ptr("user1")}, {Login: github.Ptr("user2")}},
Labels: []*github.Label{{Name: github.Ptr("bug")}, {Name: github.Ptr("help wanted")}},
Milestone: &github.Milestone{Number: github.Ptr(5)},
}

tests := []struct {
Expand All @@ -423,6 +425,7 @@ func Test_CreateIssue(t *testing.T) {
"body": "This is a test issue",
"labels": []any{"bug", "help wanted"},
"assignees": []any{"user1", "user2"},
"milestone": float64(5),
}).andThen(
mockResponse(t, http.StatusCreated, mockIssue),
),
Expand All @@ -435,6 +438,7 @@ func Test_CreateIssue(t *testing.T) {
"body": "This is a test issue",
"assignees": []string{"user1", "user2"},
"labels": []string{"bug", "help wanted"},
"milestone": float64(5),
},
expectError: false,
expectedIssue: mockIssue,
Expand Down