Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 18, 2025

Closes: Part of #1428

Migrates the issues toolset from mark3labs/mcp-go to modelcontextprotocol/go-sdk.

Changes

Tools migrated (8):

  • IssueRead - Read issue details, comments, sub-issues, or labels
  • ListIssueTypes - List available issue types for an organization
  • AddIssueComment - Add comments to issues
  • SubIssueWrite - Add, remove, or reprioritize sub-issues
  • SearchIssues - Search issues with GitHub search syntax
  • IssueWrite - Create or update issues
  • ListIssues - List and filter repository issues
  • AssignCopilotToIssue - Assign Copilot to issues

Prompts migrated (1):

  • AssignCodingAgentPrompt - Multi-issue Copilot assignment workflow

Key schema changes:

  • Tool definitions: Builder pattern (mcp.NewTool()) → struct format with jsonschema.Schema
  • Handler signatures: (ctx, request) (*CallToolResult, error)(ctx, *request, args) (*CallToolResult, any, error)
  • Parameter extraction: From request object → args map[string]any
  • Result constructors: mcp.NewToolResult*()utils.NewToolResult*()
  • Prompt handler: Generic type parameter removed, Arguments now map[string]string

Before/After:

// Before (mark3labs/mcp-go)
func ListIssueTypes(...) (mcp.Tool, server.ToolHandlerFunc) {
    return mcp.NewTool("list_issue_types",
        mcp.WithString("owner", mcp.Required(), ...),
    ),
    func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
        owner, err := RequiredParam[string](request, "owner")
        return mcp.NewToolResultText(result), nil
    }
}

// After (modelcontextprotocol/go-sdk)
func ListIssueTypes(...) (mcp.Tool, mcp.ToolHandlerFor[map[string]any, any]) {
    return mcp.Tool{
        Name: "list_issue_types",
        InputSchema: &jsonschema.Schema{
            Properties: map[string]*jsonschema.Schema{
                "owner": {Type: "string", ...},
            },
            Required: []string{"owner"},
        },
    },
    func(ctx context.Context, _ *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) {
        owner, err := RequiredParam[string](args, "owner")
        return utils.NewToolResultText(result), nil, nil
    }
}

Files modified:

  • pkg/github/issues.go - Tool implementations
  • pkg/github/issues_test.go - Test assertions updated for new signatures
  • pkg/github/search_utils.go - Search helper migrated
  • pkg/github/__toolsnaps__/*.snap - Schema snapshots regenerated
Original prompt

Migrate the issues toolset to modelcontextprotocol/go-sdk.

This will be merged into the parent PR #1428, so reference that PR in the description to track the migration

Custom agent used: go-sdk-tool-migrator
Agent specializing in migrating MCP tools from mark3labs/mcp-go to modelcontextprotocol/go-sdk


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 7 commits November 18, 2025 13:55
…functions)

Co-authored-by: omgitsads <4619+omgitsads@users.noreply.github.com>
Co-authored-by: omgitsads <4619+omgitsads@users.noreply.github.com>
Co-authored-by: omgitsads <4619+omgitsads@users.noreply.github.com>
Co-authored-by: omgitsads <4619+omgitsads@users.noreply.github.com>
…ngAgentPrompt

Co-authored-by: omgitsads <4619+omgitsads@users.noreply.github.com>
Co-authored-by: omgitsads <4619+omgitsads@users.noreply.github.com>
Co-authored-by: omgitsads <4619+omgitsads@users.noreply.github.com>
Copilot AI changed the title [WIP] Migrate issues toolset to modelcontextprotocol/go-sdk Migrate issues toolset to modelcontextprotocol/go-sdk Nov 18, 2025
Copilot AI requested a review from omgitsads November 18, 2025 14:40
Copilot finished work on behalf of omgitsads November 18, 2025 14:40
@omgitsads omgitsads marked this pull request as ready for review November 19, 2025 16:47
@omgitsads omgitsads requested a review from a team as a code owner November 19, 2025 16:47
Copilot AI review requested due to automatic review settings November 19, 2025 16:47
Copilot finished reviewing on behalf of omgitsads November 19, 2025 16:51
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR migrates the issues toolset from mark3labs/mcp-go to modelcontextprotocol/go-sdk, completing part of the broader migration effort (#1428).

Key changes:

  • Updated 8 tools with new schema definitions and handler signatures (3-value returns)
  • Migrated 1 prompt (AssignCodingAgentPrompt) to new struct format
  • Changed handler parameter extraction from request object to args map[string]any
  • Updated all error handling to use utils.NewToolResult*() constructors
  • Regenerated tool snapshots reflecting schema structure changes

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
pkg/github/issues.go Migrated 8 issue tools to new SDK with schema structs and 3-value handler returns
pkg/github/issues_test.go Updated test assertions to cast InputSchema to *jsonschema.Schema and added third nil return value to handler calls
pkg/github/search_utils.go Migrated search helper function to accept args map[string]any instead of request object
pkg/github/workflow_prompts.go Converted 2 prompts from builder pattern to struct format with new message content wrapping
pkg/github/tools.go Re-enabled issues toolset registration (uncommented lines)
pkg/github/minimal_types.go Moved parseISOTimestamp function to issues.go (only used there)
pkg/github/toolsnaps/*.snap Regenerated snapshots with new JSON schema structure (type/required/properties ordering)

err := client.Query(ctx, &query, variables)
if err != nil {
return nil, err
return nil, nil, err
Copy link

Copilot AI Nov 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect error handling in GraphQL query. When client.Query() fails, the function returns nil, nil, err which will return a Go error to the handler caller. This is inconsistent with the SDK pattern where API errors should be returned as tool result errors.

This should be:

if err := client.Query(ctx, &query, variables); err != nil {
    return utils.NewToolResultErrorFromErr("failed to query suggested actors", err), nil, nil
}

This error is within the pagination loop, so the error context should clarify which page failed if relevant.

Suggested change
return nil, nil, err
pageInfo := ""
if variables["endCursor"] != nil {
pageInfo = fmt.Sprintf(" (endCursor: %v)", variables["endCursor"])
}
return utils.NewToolResultErrorFromErr(
fmt.Sprintf("failed to query suggested actors%s", pageInfo),
err,
), nil, nil

Copilot uses AI. Check for mistakes.
nil,
); err != nil {
return nil, fmt.Errorf("failed to replace actors for assignable: %w", err)
return nil, nil, fmt.Errorf("failed to replace actors for assignable: %w", err)
Copy link

Copilot AI Nov 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect error handling in GraphQL mutation. When client.Mutate() fails, the function returns nil, nil, err which will return a Go error to the handler caller. This is inconsistent with the SDK pattern where API errors should be returned as tool result errors.

This should be:

if err := client.Mutate(...); err != nil {
    return utils.NewToolResultErrorFromErr("failed to assign copilot to issue", err), nil, nil
}
Suggested change
return nil, nil, fmt.Errorf("failed to replace actors for assignable: %w", err)
return utils.NewToolResultErrorFromErr("failed to assign copilot to issue", err), nil, nil

Copilot uses AI. Check for mistakes.
client, err := getGQLClient(ctx)
if err != nil {
return nil, fmt.Errorf("failed to get GitHub client: %w", err)
return nil, nil, fmt.Errorf("failed to get GitHub client: %w", err)
Copy link

Copilot AI Nov 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect error handling when getting GitHub client. The function returns nil, nil, fmt.Errorf(...) which will return a Go error to the handler caller. This is inconsistent with the SDK migration pattern where all errors should be returned as tool result errors.

This should be:

if err != nil {
    return utils.NewToolResultErrorFromErr("failed to get GitHub client", err), nil, nil
}

This same pattern appears at line 1571 and should be fixed there as well.

Suggested change
return nil, nil, fmt.Errorf("failed to get GitHub client: %w", err)
return utils.NewToolResultErrorFromErr("failed to get GitHub client", err), nil, nil

Copilot uses AI. Check for mistakes.
paginationParams, err := pagination.ToGraphQLParams()
if err != nil {
return nil, err
return nil, nil, err
Copy link

Copilot AI Nov 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect error handling in pagination parameter conversion. When ToGraphQLParams() fails, the function returns nil, nil, err which will return a Go error to the handler caller. This is inconsistent with the SDK pattern where validation/client errors should be returned as tool result errors.

This should be:

if err != nil {
    return utils.NewToolResultErrorFromErr("failed to convert pagination parameters", err), nil, nil
}

The same pattern is used correctly throughout the rest of the function for other client errors.

Suggested change
return nil, nil, err
return utils.NewToolResultErrorFromErr("failed to convert pagination parameters", err), nil, nil

Copilot uses AI. Check for mistakes.
out, err := json.Marshal(response)
if err != nil {
return nil, fmt.Errorf("failed to marshal issues: %w", err)
return nil, nil, fmt.Errorf("failed to marshal issues: %w", err)
Copy link

Copilot AI Nov 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect error handling in query execution. When client.Query() fails, the function returns nil, nil, err which will return a Go error to the handler caller. This is inconsistent with the SDK pattern where API errors should be returned as tool result errors.

This should be:

if err := client.Query(ctx, issueQuery, vars); err != nil {
    return utils.NewToolResultErrorFromErr("failed to list issues", err), nil, nil
}

Compare with line 1450 where query errors are correctly wrapped as tool result errors using utils.NewToolResultError(err.Error()).

Suggested change
return nil, nil, fmt.Errorf("failed to marshal issues: %w", err)
return utils.NewToolResultErrorFromErr("failed to marshal issues", err), nil, nil

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

@SamMorrowDrums SamMorrowDrums left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still generally looking great. Didn't check the lint fail, but the tool and prompt refactoring looks correct.

"description": "Repository owner",
"type": "string"
"type": "string",
"description": "Repository owner"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these toolsnap ordering changes deterministic? As long as this is a one-off churn it's all good.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will take a look and confirm!

@omgitsads omgitsads merged commit 726c683 into omgitsads/go-sdk Nov 20, 2025
20 of 21 checks passed
@omgitsads omgitsads deleted the copilot/migrate-issues-toolset branch November 20, 2025 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants