Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 18, 2025

Closes: Part of #1428

Migrates GetCodeScanningAlert and ListCodeScanningAlerts tools from mark3labs/mcp-go to modelcontextprotocol/go-sdk.

Changes

  • Tool constructors: Return type updated to (mcp.Tool, mcp.ToolHandlerFor[map[string]any, any])
  • Handler signatures: Now func(context.Context, *mcp.CallToolRequest, map[string]any) (*mcp.CallToolResult, any, error)
  • Schema definitions: Converted from DSL to explicit jsonschema.Schema structs
  • Parameter extraction: Uses args map passed to handler instead of extracting from request
  • Result helpers: Changed to utils.NewToolResult* functions
  • Tests: Updated to cast InputSchema to *jsonschema.Schema and pass args map to handlers

Schema changes in toolsnaps are cosmetic (field ordering only) - all fields, types, enums, defaults, and descriptions remain logically equivalent.

Original prompt

Migrate the code-scanning 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


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: omgitsads <4619+omgitsads@users.noreply.github.com>
Copilot AI changed the title [WIP] Migrate code-scanning toolset to modelcontextprotocol/go-sdk Migrate code-scanning toolset to modelcontextprotocol/go-sdk Nov 18, 2025
Copilot AI requested a review from omgitsads November 18, 2025 11:26
Copilot finished work on behalf of omgitsads November 18, 2025 11:26
@LuluBeatson LuluBeatson self-requested a review November 18, 2025 13:33
@LuluBeatson
Copy link
Contributor

image image

@LuluBeatson LuluBeatson marked this pull request as ready for review November 18, 2025 15:14
@LuluBeatson LuluBeatson requested a review from a team as a code owner November 18, 2025 15:14
Copilot AI review requested due to automatic review settings November 18, 2025 15:14
@LuluBeatson
Copy link
Contributor

Ignore lint errors due to unused parameters and types. These will naturally be fixed when all tools are re-enabled.

Copilot finished reviewing on behalf of LuluBeatson November 18, 2025 15:19
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 code-scanning toolset (GetCodeScanningAlert and ListCodeScanningAlerts tools) from mark3labs/mcp-go to modelcontextprotocol/go-sdk. This is part of a larger migration effort tracked in PR #1428.

Key Changes:

  • Updated tool constructors to return (mcp.Tool, mcp.ToolHandlerFor[map[string]any, any])
  • Converted handler signatures to accept 3 parameters and return 3 values
  • Replaced DSL-based schemas with explicit jsonschema.Schema structs
  • Changed parameter extraction to use args map instead of request object
  • Re-enabled the codeSecurity toolset in tools.go

Reviewed Changes

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

Show a summary per file
File Description
pkg/github/code_scanning.go Migrated tool implementations from mark3labs/mcp-go to modelcontextprotocol/go-sdk with new schemas and handlers
pkg/github/code_scanning_test.go Updated tests to cast InputSchema to *jsonschema.Schema and use new handler signature
pkg/github/tools.go Re-enabled codeSecurity toolset and added nolint directives to DefaultToolsetGroup and InitDynamicToolset
pkg/github/toolsnaps/*.snap Cosmetic updates to field ordering in tool schema snapshots
internal/ghmcp/server.go Removed unused stdioServerLogPrefix constant

}
}

//nolint:unused
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

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

The //nolint:unused directive is being added to DefaultToolsetGroup and InitDynamicToolset functions, but these functions appear to be actively used in the codebase. In internal/ghmcp/server.go, DefaultToolsetGroup is called on line 135 and InitDynamicToolset is called on line 154. These directives should only be added if the functions are truly unused, which doesn't appear to be the case here. Consider removing these directives unless they're being added in preparation for future deprecation.

Suggested change
//nolint:unused

Copilot uses AI. Check for mistakes.

// InitDynamicToolset creates a dynamic toolset that can be used to enable other toolsets, and so requires the server and toolset group as arguments
//
//nolint:unused
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

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

The //nolint:unused directive is being added to InitDynamicToolset, but this function is actively used in internal/ghmcp/server.go on line 154. These directives should only be added if the function is truly unused. Consider removing this directive unless it's being added in preparation for future deprecation.

Suggested change
//nolint:unused

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

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

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

Inconsistent error handling: When getClient(ctx) fails, the error should be returned as the third return value to match the pattern used in other migrated tools like GetMe in context_tools.go. The return statement should be:

return utils.NewToolResultErrorFromErr("failed to get GitHub client", err), nil, err

Instead of:

return utils.NewToolResultErrorFromErr("failed to get GitHub client", err), nil, nil
Suggested change
return utils.NewToolResultErrorFromErr("failed to get GitHub client", err), nil, nil
return utils.NewToolResultErrorFromErr("failed to get GitHub client", err), nil, err

Copilot uses AI. Check for mistakes.
resp,
err,
), nil
), nil, nil
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

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

Inconsistent error handling: When GitHub API calls fail, the error should be returned as the third return value to match the pattern used in other migrated tools. The return statement should be:

return ghErrors.NewGitHubAPIErrorResponse(ctx,
    "failed to get alert",
    resp,
    err,
), nil, err

Instead of returning nil as the third value.

Suggested change
), nil, nil
), nil, err

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

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

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

Inconsistent error handling: When getClient(ctx) fails, the error should be returned as the third return value to match the pattern used in other migrated tools. The return statement should be:

return utils.NewToolResultErrorFromErr("failed to get GitHub client", err), nil, err

Instead of returning nil as the third value.

Suggested change
return utils.NewToolResultErrorFromErr("failed to get GitHub client", err), nil, nil
return utils.NewToolResultErrorFromErr("failed to get GitHub client", err), nil, err

Copilot uses AI. Check for mistakes.
resp,
err,
), nil
), nil, nil
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

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

Inconsistent error handling: When GitHub API calls fail, the error should be returned as the third return value to match the pattern used in other migrated tools. The return statement should be:

return ghErrors.NewGitHubAPIErrorResponse(ctx,
    "failed to list alerts",
    resp,
    err,
), nil, err

Instead of returning nil as the third value.

Suggested change
), nil, nil
), nil, err

Copilot uses AI. Check for mistakes.
@omgitsads omgitsads merged commit a405519 into omgitsads/go-sdk Nov 19, 2025
19 of 20 checks passed
@omgitsads omgitsads deleted the copilot/migrate-code-scanning-toolset branch November 19, 2025 10:44
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