From ec8398f47bf33c2117fc429de26b7a7b58d90f4b Mon Sep 17 00:00:00 2001 From: Andrew Georgiou Date: Wed, 9 Apr 2025 13:20:10 +0000 Subject: [PATCH 1/2] Fix handling nil values for optional string array parameters, nil values should be equivalent to an empty string, currently we return an error but Claude passes nil for optional values. --- pkg/github/issues_test.go | 1 + pkg/github/server.go | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/github/issues_test.go b/pkg/github/issues_test.go index 04a2ae19..7e48a443 100644 --- a/pkg/github/issues_test.go +++ b/pkg/github/issues_test.go @@ -471,6 +471,7 @@ func Test_CreateIssue(t *testing.T) { "owner": "owner", "repo": "repo", "title": "Minimal Issue", + "assignees": nil, // Expect no failure with nil optional value. }, expectError: false, expectedIssue: &github.Issue{ diff --git a/pkg/github/server.go b/pkg/github/server.go index 84c15f50..9b77a5e2 100644 --- a/pkg/github/server.go +++ b/pkg/github/server.go @@ -232,12 +232,14 @@ func OptionalIntParamWithDefault(r mcp.CallToolRequest, p string, d int) (int, e // 1. Checks if the parameter is present in the request, if not, it returns its zero-value // 2. If it is present, iterates the elements and checks each is a string func OptionalStringArrayParam(r mcp.CallToolRequest, p string) ([]string, error) { - // Check if the parameter is present in the request + // Check if the parameter is present in the request if _, ok := r.Params.Arguments[p]; !ok { return []string{}, nil } - switch v := r.Params.Arguments[p].(type) { + switch v := r.Params.Arguments[p].(type) { + case nil: + return []string{}, nil case []string: return v, nil case []any: From d8b2273e5bbca08e33c3441440de4adc9ceb371f Mon Sep 17 00:00:00 2001 From: Andrew Georgiou Date: Wed, 9 Apr 2025 13:24:23 +0000 Subject: [PATCH 2/2] lint fixes --- pkg/github/issues_test.go | 8 ++++---- pkg/github/server.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/github/issues_test.go b/pkg/github/issues_test.go index 7e48a443..e8b16e02 100644 --- a/pkg/github/issues_test.go +++ b/pkg/github/issues_test.go @@ -468,10 +468,10 @@ func Test_CreateIssue(t *testing.T) { ), ), requestArgs: map[string]interface{}{ - "owner": "owner", - "repo": "repo", - "title": "Minimal Issue", - "assignees": nil, // Expect no failure with nil optional value. + "owner": "owner", + "repo": "repo", + "title": "Minimal Issue", + "assignees": nil, // Expect no failure with nil optional value. }, expectError: false, expectedIssue: &github.Issue{ diff --git a/pkg/github/server.go b/pkg/github/server.go index 9b77a5e2..80457a54 100644 --- a/pkg/github/server.go +++ b/pkg/github/server.go @@ -232,12 +232,12 @@ func OptionalIntParamWithDefault(r mcp.CallToolRequest, p string, d int) (int, e // 1. Checks if the parameter is present in the request, if not, it returns its zero-value // 2. If it is present, iterates the elements and checks each is a string func OptionalStringArrayParam(r mcp.CallToolRequest, p string) ([]string, error) { - // Check if the parameter is present in the request + // Check if the parameter is present in the request if _, ok := r.Params.Arguments[p]; !ok { return []string{}, nil } - switch v := r.Params.Arguments[p].(type) { + switch v := r.Params.Arguments[p].(type) { case nil: return []string{}, nil case []string: