From d7924b37b86833b414811239ee3779e415feb8cc Mon Sep 17 00:00:00 2001 From: bensincs Date: Wed, 23 Jul 2025 18:47:19 +0400 Subject: [PATCH] Add issue type to mcp server --- pkg/github/issues.go | 21 +++++++++++++++++++++ pkg/github/issues_test.go | 4 ++++ 2 files changed, 25 insertions(+) diff --git a/pkg/github/issues.go b/pkg/github/issues.go index f718c37cb2..d378ec92fd 100644 --- a/pkg/github/issues.go +++ b/pkg/github/issues.go @@ -624,6 +624,9 @@ func CreateIssue(getClient GetClientFn, t translations.TranslationHelperFunc) (t mcp.WithString("body", mcp.Description("Issue body content"), ), + mcp.WithString("type", + mcp.Description("Issue type"), + ), mcp.WithArray("assignees", mcp.Description("Usernames to assign to this issue"), mcp.Items( @@ -687,6 +690,12 @@ func CreateIssue(getClient GetClientFn, t translations.TranslationHelperFunc) (t milestoneNum = &milestone } + // Get optional issue type + issueType, err := OptionalParam[string](request, "type") + if err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + // Create the issue request issueRequest := &github.IssueRequest{ Title: github.Ptr(title), @@ -694,6 +703,7 @@ func CreateIssue(getClient GetClientFn, t translations.TranslationHelperFunc) (t Assignees: &assignees, Labels: &labels, Milestone: milestoneNum, + Type: github.Ptr(issueType), } client, err := getClient(ctx) @@ -894,6 +904,9 @@ func UpdateIssue(getClient GetClientFn, t translations.TranslationHelperFunc) (t mcp.WithNumber("milestone", mcp.Description("New milestone number"), ), + mcp.WithString("type", + mcp.Description("New issue type"), + ), ), func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { owner, err := RequiredParam[string](request, "owner") @@ -963,6 +976,14 @@ func UpdateIssue(getClient GetClientFn, t translations.TranslationHelperFunc) (t milestoneNum := milestone issueRequest.Milestone = &milestoneNum } + // Get optional issue type + issueType, err := OptionalParam[string](request, "type") + if err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + if issueType != "" { + issueRequest.Type = github.Ptr(issueType) + } client, err := getClient(ctx) if err != nil { diff --git a/pkg/github/issues_test.go b/pkg/github/issues_test.go index 2bdb89b060..081bf26602 100644 --- a/pkg/github/issues_test.go +++ b/pkg/github/issues_test.go @@ -486,6 +486,7 @@ func Test_CreateIssue(t *testing.T) { assert.Contains(t, tool.InputSchema.Properties, "assignees") assert.Contains(t, tool.InputSchema.Properties, "labels") assert.Contains(t, tool.InputSchema.Properties, "milestone") + assert.Contains(t, tool.InputSchema.Properties, "type") assert.ElementsMatch(t, tool.InputSchema.Required, []string{"owner", "repo", "title"}) // Setup mock issue for success case @@ -498,6 +499,7 @@ func Test_CreateIssue(t *testing.T) { 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)}, + Type: &github.IssueType{Name: github.Ptr("bug")}, } tests := []struct { @@ -519,6 +521,7 @@ func Test_CreateIssue(t *testing.T) { "labels": []any{"bug", "help wanted"}, "assignees": []any{"user1", "user2"}, "milestone": float64(5), + "type": "bug", }).andThen( mockResponse(t, http.StatusCreated, mockIssue), ), @@ -532,6 +535,7 @@ func Test_CreateIssue(t *testing.T) { "assignees": []any{"user1", "user2"}, "labels": []any{"bug", "help wanted"}, "milestone": float64(5), + "type": "bug", }, expectError: false, expectedIssue: mockIssue,