From 8b06d7154e59e8056d67e1b23f6bfa06a8e5b3fb Mon Sep 17 00:00:00 2001 From: Stanislav Krasnyi Date: Sat, 13 Dec 2025 08:37:15 +0000 Subject: [PATCH] Fix assignees parsing in Edit Issue (#109) # Fix assignees parsing in EditIssueFn ## Problem The `EditIssueFn` function in `operation/issue/issue.go` had a bug where assignees were not being properly parsed from the request arguments. The code was attempting to directly cast the assignees array to `[]string`, but the MCP framework passes arrays as `[]interface{}`. This caused the assignees to appear empty when editing issues through the Gitea-MCP endpoint. ## Solution The assignees parsing logic in the `EditIssueFn` function has been fixed to properly handle the `[]interface{}` type that comes from the MCP framework: 1. Check if the assignees argument exists in the request 2. Type-assert it to `[]interface{}` 3. Iterate through each element and convert it to string 4. Assign the properly parsed string slice to `opt.Assignees` ## Changes - Modified `operation/issue/issue.go` in the `EditIssueFn` function - The fix follows the same pattern used successfully in other parts of the codebase (pull/pull.go and label/label.go) ## Testing - The fix has been implemented and tested to ensure assignees are properly parsed and applied to issues - No existing functionality was broken - The solution maintains backward compatibility ## Impact This fix resolves the issue where assignees were not being set when using the Gitea-MCP endpoint `/repos/{owner}/{repo}/issues/{index} (PATCH)` to edit issues with assignees. Reviewed-on: https://gitea.com/gitea/gitea-mcp/pulls/109 Co-authored-by: Stanislav Krasnyi Co-committed-by: Stanislav Krasnyi --- operation/issue/issue.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/operation/issue/issue.go b/operation/issue/issue.go index fd40d62..ba62951 100644 --- a/operation/issue/issue.go +++ b/operation/issue/issue.go @@ -283,10 +283,17 @@ func EditIssueFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolRes if ok { opt.Body = ptr.To(body) } - assignees, ok := req.GetArguments()["assignees"].([]string) - if ok { - opt.Assignees = assignees + var assignees []string + if assigneesArg, exists := req.GetArguments()["assignees"]; exists { + if assigneesSlice, ok := assigneesArg.([]interface{}); ok { + for _, assignee := range assigneesSlice { + if assigneeStr, ok := assignee.(string); ok { + assignees = append(assignees, assigneeStr) + } + } + } } + opt.Assignees = assignees milestone, ok := req.GetArguments()["milestone"].(float64) if ok { opt.Milestone = ptr.To(int64(milestone))