Skip to content

Commit f90251f

Browse files
committed
Adding dynamic state queries for list_issues
1 parent 011b56f commit f90251f

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

pkg/github/issues.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,6 @@ func ListIssues(getGQLClient GetGQLClientFn, t translations.TranslationHelperFun
834834
mcp.Description("Repository name"),
835835
),
836836
mcp.WithString("state",
837-
mcp.Required(),
838837
mcp.Description("Filter by state"),
839838
mcp.Enum("OPEN", "CLOSED"),
840839
),
@@ -870,11 +869,19 @@ func ListIssues(getGQLClient GetGQLClientFn, t translations.TranslationHelperFun
870869
}
871870

872871
// Set optional parameters if provided
873-
state, err := RequiredParam[string](request, "state")
872+
state, err := OptionalParam[string](request, "state")
874873
if err != nil {
875874
return mcp.NewToolResultError(err.Error()), nil
876875
}
877876

877+
//If the state has a value, cast into an array of strings
878+
var states []githubv4.IssueState
879+
if state != "" {
880+
states = append(states, githubv4.IssueState(state))
881+
} else {
882+
states = []githubv4.IssueState{githubv4.IssueStateOpen, githubv4.IssueStateClosed}
883+
}
884+
878885
// Get labels
879886
labels, err := OptionalStringArrayParam(request, "labels")
880887
if err != nil {
@@ -951,7 +958,7 @@ func ListIssues(getGQLClient GetGQLClientFn, t translations.TranslationHelperFun
951958
vars := map[string]interface{}{
952959
"owner": githubv4.String(owner),
953960
"repo": githubv4.String(repo),
954-
"states": []githubv4.IssueState{githubv4.IssueState(state)},
961+
"states": states,
955962
"orderBy": githubv4.IssueOrderField(orderBy),
956963
"direction": githubv4.OrderDirection(direction),
957964
"first": githubv4.Int(*paginationParams.First),

0 commit comments

Comments
 (0)