Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 18, 2025

Closes:

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

Changes

Function signatures

  • Return type: (mcp.Tool, server.ToolHandlerFunc)(mcp.Tool, mcp.ToolHandlerFor[map[string]any, any])
  • Handler signature: func(ctx, request)func(ctx, *request, args map[string]any) with 3 return values

Schema definitions

  • Converted from DSL (mcp.NewTool()) to struct initialization (mcp.Tool{})
  • Built InputSchema using jsonschema.Schema with explicit properties
  • Default values use json.RawMessage (e.g., Default: json.RawMessage(\"open"`)`)

Result helpers

  • mcp.NewToolResult*()utils.NewToolResult*()

Tests

  • Handler invocations updated to pass args map[string]any
  • Removed direct schema property assertions (no longer exposed)
  • Maintained toolsnap validation

Before/After

Before (mark3labs/mcp-go):

func GetDependabotAlert(...) (tool mcp.Tool, handler server.ToolHandlerFunc) {
    return mcp.NewTool(
        "get_dependabot_alert",
        mcp.WithString("owner", mcp.Required(), ...),
        ...
    ), func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
        owner, _ := RequiredParam[string](request, "owner")
        ...
        return mcp.NewToolResultText(string(r)), nil
    }
}

After (modelcontextprotocol/go-sdk):

func GetDependabotAlert(...) (mcp.Tool, mcp.ToolHandlerFor[map[string]any, any]) {
    tool := mcp.Tool{
        Name: "get_dependabot_alert",
        InputSchema: &jsonschema.Schema{
            Properties: map[string]*jsonschema.Schema{
                "owner": {Type: "string", ...},
                ...
            },
        },
    }
    handler := mcp.ToolHandlerFor[map[string]any, any](
        func(ctx context.Context, _ *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) {
            owner, _ := RequiredParam[string](args, "owner")
            ...
            return utils.NewToolResultText(string(r)), nil, nil
        })
    return tool, handler
}

Toolsnaps updated with cosmetic field reordering only—schemas remain functionally identical.

Original prompt

Migrate the dependabot toolset to modelcontextprotocol/go-sdk

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.

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

image

@LuluBeatson LuluBeatson marked this pull request as ready for review November 19, 2025 15:28
@LuluBeatson LuluBeatson requested a review from a team as a code owner November 19, 2025 15:28
Copilot AI review requested due to automatic review settings November 19, 2025 15:28
Copilot finished reviewing on behalf of LuluBeatson November 19, 2025 15:31
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 dependabot toolset from mark3labs/mcp-go to modelcontextprotocol/go-sdk, completing the migration of another toolset to the new SDK. The migration updates function signatures, schema definitions, and error handling patterns to align with the new SDK's API.

  • Migrated two dependabot tools (get_dependabot_alert and list_dependabot_alerts) to use the new SDK
  • Updated schema definitions from DSL-based to struct-based initialization with jsonschema.Schema
  • Modified handler signatures to return three values (*mcp.CallToolResult, any, error) instead of two
  • Re-enabled the dependabot toolset in the default toolset group

Reviewed Changes

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

Show a summary per file
File Description
pkg/github/dependabot.go Migrated tool implementations to new SDK with updated function signatures, schema definitions, and result helpers
pkg/github/dependabot_test.go Updated tests to match new handler signatures and removed direct schema assertions in favor of toolsnap validation
pkg/github/tools.go Uncommented dependabot toolset registration to re-enable it in the default toolset group
pkg/github/toolsnaps/get_dependabot_alert.snap Cosmetic reordering of JSON fields (no functional changes)
pkg/github/toolsnaps/list_dependabot_alerts.snap Cosmetic reordering of JSON fields (no functional changes)

body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("failed to marshal alert: %w", err)
return utils.NewToolResultErrorFromErr("failed to read response body", err), 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.

Inconsistent error handling pattern. When returning an error result using utils.NewToolResultErrorFromErr, the third return value should be nil, not err. The error is already embedded in the result.

The correct pattern (consistent with code_scanning.go line 77) is:

return utils.NewToolResultErrorFromErr("failed to read response body", err), nil, nil
Suggested change
return utils.NewToolResultErrorFromErr("failed to read response body", err), nil, err
return utils.NewToolResultErrorFromErr("failed to read response body", err), nil, nil

Copilot uses AI. Check for mistakes.
return mcp.NewToolResultText(string(r)), nil
r, err := json.Marshal(alert)
if err != nil {
return utils.NewToolResultErrorFromErr("failed to marshal alert", err), 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.

Inconsistent error handling pattern. When returning an error result using utils.NewToolResultErrorFromErr, the third return value should be nil, not err. The error is already embedded in the result.

The correct pattern (consistent with code_scanning.go line 84) is:

return utils.NewToolResultErrorFromErr("failed to marshal alert", err), nil, nil
Suggested change
return utils.NewToolResultErrorFromErr("failed to marshal alert", err), nil, err
return utils.NewToolResultErrorFromErr("failed to marshal alert", err), nil, nil

Copilot uses AI. Check for mistakes.
}
client, err := getClient(ctx)
if err != nil {
return utils.NewToolResultErrorFromErr("failed to get GitHub client", err), 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.

Inconsistent error handling pattern. When returning an error result using utils.NewToolResultErrorFromErr, the third return value should be nil, not err. The error is already embedded in the result.

The correct pattern (consistent with code_scanning.go line 161) is:

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

Copilot uses AI. Check for mistakes.
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("failed to marshal alerts: %w", err)
return utils.NewToolResultErrorFromErr("failed to read response body", err), 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.

Inconsistent error handling pattern. When returning an error result using utils.NewToolResultErrorFromErr, the third return value should be nil, not err. The error is already embedded in the result.

The correct pattern (consistent with code_scanning.go line 176) is:

return utils.NewToolResultErrorFromErr("failed to read response body", err), nil, nil
Suggested change
return utils.NewToolResultErrorFromErr("failed to read response body", err), nil, err
return utils.NewToolResultErrorFromErr("failed to read response body", err), nil, nil

Copilot uses AI. Check for mistakes.
return mcp.NewToolResultText(string(r)), nil
r, err := json.Marshal(alerts)
if err != nil {
return utils.NewToolResultErrorFromErr("failed to marshal alerts", err), 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.

Inconsistent error handling pattern. When returning an error result using utils.NewToolResultErrorFromErr, the third return value should be nil, not err. The error is already embedded in the result.

The correct pattern (consistent with code_scanning.go line 183) is:

return utils.NewToolResultErrorFromErr("failed to marshal alerts", err), nil, nil
Suggested change
return utils.NewToolResultErrorFromErr("failed to marshal alerts", err), nil, err
return utils.NewToolResultErrorFromErr("failed to marshal alerts", err), nil, nil

Copilot uses AI. Check for mistakes.
}
client, err := getClient(ctx)
if err != nil {
return utils.NewToolResultErrorFromErr("failed to get GitHub client", err), 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.

Inconsistent error handling pattern. When returning an error result using utils.NewToolResultErrorFromErr, the third return value should be nil, not err. The error is already embedded in the result.

The correct pattern (consistent with code_scanning.go line 61, 77, 84) is:

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

Not:

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

Copilot uses AI. Check for mistakes.
@omgitsads omgitsads force-pushed the copilot/migrate-dependabot-toolset branch from 4c3d834 to 183d17a Compare November 19, 2025 16:39
@omgitsads omgitsads merged commit 1b769a5 into omgitsads/go-sdk Nov 20, 2025
13 of 14 checks passed
@omgitsads omgitsads deleted the copilot/migrate-dependabot-toolset branch November 20, 2025 10:18
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.

4 participants