Skip to content

Non initialized McpServerSession hangs and timesout instead of providing helpful error message #275

@marianogonzalez

Description

@marianogonzalez

This issue is closely related to #274 and could be considered as a follow up to that, but I decided to split it for convenience and readability.

Calling McpServerSession#handle(JSonRPCMessage) on an instance that hasn't yet received the notifications/initialized notification results in a Mono that never completes until a Timeout is raised.

This happens because the io.modelcontextprotocol.spec.McpServerSession#exchangeSink will never emit any value until such notification is received, and thus the this.exchangeSink.asMono().flatMap(exchange -> handler.handle(exchange, request.params())); in McpServerSession#225 will never complete.

Putting the considerations of #274 aside, it is fair for a non intiailized session to not handle messages, but it should do it by quickly returning a Mono.error instead of hanging and returning an unspecified timeout.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions