From 135754aed5fefd05244e947e7b765ce3b8b4c847 Mon Sep 17 00:00:00 2001 From: William Martin Date: Thu, 3 Apr 2025 22:13:12 +0200 Subject: [PATCH] Add missing milestone to create_issue --- pkg/github/issues.go | 15 +++++++++++++++ pkg/github/issues_test.go | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/pkg/github/issues.go b/pkg/github/issues.go index e27215ce..0e337637 100644 --- a/pkg/github/issues.go +++ b/pkg/github/issues.go @@ -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") @@ -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) diff --git a/pkg/github/issues_test.go b/pkg/github/issues_test.go index d9fdeb54..f29e2b04 100644 --- a/pkg/github/issues_test.go +++ b/pkg/github/issues_test.go @@ -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 @@ -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 { @@ -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), ), @@ -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,