Skip to content

Migrate code-scanning toolset to modelcontextprotocol/go-sdk - #1430

Merged
omgitsads merged 5 commits into
omgitsads/go-sdkfrom
copilot/migrate-code-scanning-toolset
Nov 19, 2025
Merged

Migrate code-scanning toolset to modelcontextprotocol/go-sdk#1430
omgitsads merged 5 commits into
omgitsads/go-sdkfrom
copilot/migrate-code-scanning-toolset

Conversation

CopilotAI commented Nov 18, 2025

Copy link
Copy Markdown
Contributor

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>
CopilotAI changed the title [WIP] Migrate code-scanning toolset to modelcontextprotocol/go-sdkMigrate code-scanning toolset to modelcontextprotocol/go-sdkNov 18, 2025
CopilotAI requested a review from omgitsadsNovember 18, 2025 11:26
@LuluBeatson
LuluBeatson self-requested a review November 18, 2025 13:33
@LuluBeatson

Copy link
Copy Markdown
Contributor
imageimage

@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 ownerNovember 18, 2025 15:14
CopilotAI review requested due to automatic review settings November 18, 2025 15:14
@LuluBeatson

Copy link
Copy Markdown
Contributor

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

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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
FileDescription
pkg/github/code_scanning.goMigrated tool implementations from mark3labs/mcp-go to modelcontextprotocol/go-sdk with new schemas and handlers
pkg/github/code_scanning_test.goUpdated tests to cast InputSchema to *jsonschema.Schema and use new handler signature
pkg/github/tools.goRe-enabled codeSecurity toolset and added nolint directives to DefaultToolsetGroup and InitDynamicToolset
pkg/github/toolsnaps/*.snapCosmetic updates to field ordering in tool schema snapshots
internal/ghmcp/server.goRemoved unused stdioServerLogPrefix constant

Comment threadpkg/github/tools.go
}
}

//nolint:unused

CopilotAINov 18, 2025

Copy link

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.
Comment threadpkg/github/tools.go

// 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

CopilotAINov 18, 2025

Copy link

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

CopilotAINov 18, 2025

Copy link

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:

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

Instead of:

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

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

CopilotAINov 18, 2025

Copy link

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:

returnghErrors.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

CopilotAINov 18, 2025

Copy link

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:

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

Instead of returning nil as the third value.

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

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

CopilotAINov 18, 2025

Copy link

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:

returnghErrors.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-sdkNov 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 freeto 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.

4 participants

@LuluBeatson@omgitsads