Further iteration of the tool typing#391
Open
domarmstrong wants to merge 3 commits intotypesafetool_bugsnagfrom
Open
Further iteration of the tool typing#391domarmstrong wants to merge 3 commits intotypesafetool_bugsnagfrom
domarmstrong wants to merge 3 commits intotypesafetool_bugsnagfrom
Conversation
domarmstrong
commented
Mar 25, 2026
| }, | ||
| (client: BugsnagClient) => async (params, _extra) => { | ||
| const project = await client.getInputProject(params.projectId); | ||
| async ({ client, args }) => { |
Contributor
Author
There was a problem hiding this comment.
I stuck with the name args as that is in the mcp types and most other clients are using 'args'
domarmstrong
commented
Mar 25, 2026
|
|
||
| // Fetches full details for a single error including aggregated stats, the latest event, pivots, and a dashboard URL. | ||
| export const getError = new TypesafeTool( | ||
| export default BugsnagClient.createTool( |
Contributor
Author
There was a problem hiding this comment.
could still use named exports, but consistently using default makes the imports a bit more straightforward.
domarmstrong
commented
Mar 25, 2026
| readOnly: false, | ||
| idempotent: false, | ||
| }, | ||
| (client: BugsnagClient, getInput: GetInputFunction) => |
Contributor
Author
There was a problem hiding this comment.
With the current implementation, you have to also manually type any additional arguments to the handler factory. With this change you don't need any explicit typing or extra function nesting.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Goal
Make the api a bit nicer for defining type safe tools and resources.
With this change, the client classes have factory function that allow you to
Client.createTool(...)Client.createResource(...)`.Design
Make Client an abstract class and add factory functions to the base class. This allows us to use type inference without any explicit typing.
One thing required to be able to use this though is you need to use dynamic imports in the clients register functions. If you tried to do a static import of the tool files at the top of the client file the client class would not have been created yet and be undefined.
Changeset
Refactoring
Testing