Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 12, 2026

Summary

Removes the deprecated NewServerToolFromHandler function after all consumers migrated to NewServerToolWithRawContextHandler.

Why

The deprecated function created closures at registration time, causing performance issues in per-request server scenarios. With github-mcp-server-remote now migrated, the old API can be removed.

What changed

  • Removed NewServerToolFromHandler function from pkg/inventory/server_tool.go
  • Updated test helpers (mockTool, mockToolWithDefault) to use NewServerToolWithRawContextHandler
  • Simplified test code by removing unnecessary closure wrapping

Before:

NewServerToolFromHandler(tool, toolset, func(_ any) mcp.ToolHandler {
    return func(ctx context.Context, req *mcp.CallToolRequest) (*mcp.CallToolResult, error) {
        // handler implementation
    }
})

After:

NewServerToolWithRawContextHandler(tool, toolset, 
    func(ctx context.Context, req *mcp.CallToolRequest) (*mcp.CallToolResult, error) {
        // handler implementation
    })

MCP impact

  • No tool or API changes

This is an internal API change only. The removed function was already deprecated and not exported to external consumers.

Security / limits

  • No security or limits impact

Tool renaming

  • I am not renaming tools as part of this PR

Lint & tests

  • Linted locally with ./script/lint
  • Tested locally with ./script/test

Docs

  • Not needed

Internal API change with no user-facing impact.

Original prompt

The NewServerToolFromHandler function in pkg/inventory/server_tool.go is deprecated in favor of NewServerToolWithRawContextHandler.

The deprecation comment says:

// Deprecated: This creates closures at registration time. For better performance in
// per-request server scenarios, use NewServerToolWithRawContextHandler instead.

Since all known consumers (github-mcp-server-remote) have migrated to the new API, this deprecated function can now be removed.

Tasks:

  1. Remove the NewServerToolFromHandler function from pkg/inventory/server_tool.go
  2. Remove any tests specifically for NewServerToolFromHandler if they exist
  3. Update any documentation that references the old function

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

- Removed NewServerToolFromHandler function from pkg/inventory/server_tool.go
- Updated test helper functions (mockTool and mockToolWithDefault) to use NewServerToolWithRawContextHandler
- All tests pass successfully

Co-authored-by: SamMorrowDrums <4811358+SamMorrowDrums@users.noreply.github.com>
Copilot AI changed the title [WIP] Remove deprecated NewServerToolFromHandler function Remove deprecated NewServerToolFromHandler function Jan 12, 2026
Copilot AI requested a review from SamMorrowDrums January 12, 2026 20:26
@SamMorrowDrums SamMorrowDrums marked this pull request as ready for review January 12, 2026 21:59
@SamMorrowDrums SamMorrowDrums requested a review from a team as a code owner January 12, 2026 21:59
Copilot AI review requested due to automatic review settings January 12, 2026 21:59
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 removes the deprecated NewServerToolFromHandler function after all consumers have migrated to the more performant NewServerToolWithRawContextHandler API. The old API created closures at registration time, causing performance issues in per-request server scenarios.

Changes:

  • Removed the deprecated NewServerToolFromHandler function from pkg/inventory/server_tool.go
  • Updated test helper functions (mockTool and mockToolWithDefault) to use the new API
  • Simplified test code by removing unnecessary closure wrapping around handlers

Reviewed changes

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

File Description
pkg/inventory/server_tool.go Removed deprecated NewServerToolFromHandler function (lines 166-175)
pkg/inventory/registry_test.go Updated mockToolWithDefault and mockTool helper functions to use NewServerToolWithRawContextHandler instead of the deprecated function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants