Skip to content

(fix): Update fallbackRequestHandler type to match _requestHandlers leaves type #784

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

fredericbarthelet
Copy link
Contributor

@fredericbarthelet fredericbarthelet commented Jul 18, 2025

This PR only updates type definition

fallbackRequestHandler current type is not matching the type of what it is a fallback for, i.e. the type of each request handler on the Server.

The following code snippet is the only location where fallbackRequestHandler is used

const handler =
this._requestHandlers.get(request.method) ?? this.fallbackRequestHandler;

Motivation and Context

fallbackRequestHandler current type lacks the request id, the jsonrpc version (while being actually forwarded) and the extra param altogether. Updating the type avoid having the rely on type casting where fallback must be defined. The new type is exacly the one defined for _requestHandlers leaves:

private _requestHandlers: Map<
string,
(
request: JSONRPCRequest,
extra: RequestHandlerExtra<SendRequestT, SendNotificationT>,
) => Promise<SendResultT>
> = new Map();

How Has This Been Tested?

Locally on my project

Breaking Changes

Non breaking, JSONRPCRequest is actually narrower than Request

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

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

Additional context

@fredericbarthelet fredericbarthelet requested a review from a team as a code owner July 18, 2025 19:56
@fredericbarthelet fredericbarthelet requested a review from ihrpr July 18, 2025 19:56
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