Skip to content

Conversation

gching
Copy link

@gching gching commented Oct 19, 2025

  • Updates registerTool signature to provide the accurate type for the ToolCallback

Motivation and Context

  • Currently, even though no inputSchma is provided, given the generic, it will assume the ToolCallback function will always be cb(params, extra) even though it should be cb(extra)
  • In these cases, params will be typed as the Record<string, any> even though it should be typed RequestHandlerExtra and extra would be typed as RequestHandlerExtra but actually be undefined
  • After the change, we have a properly typed ToolCallback where if inputSchema is undefined, the callback will be cb(extra) and if inputSchema is defined, it will be cb(params, extra)

How Has This Been Tested?

  • Local type check

Breaking Changes

  • Probably not, just removing typecasts + @ts-ignore

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

@gching gching changed the title Update registerTool function signature for proper type drilling Update registerTool function signature for proper typed ToolCalback Oct 19, 2025
@gching gching marked this pull request as ready for review October 19, 2025 10:17
@gching gching requested a review from a team as a code owner October 19, 2025 10:17
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.

1 participant