Skip to content

Notifications cause trouble #19

@robinevers93

Description

@robinevers93

When running the server, the following happens:

[virtual-71] DEBUG sttp.tapir.server.netty.sync.NettySyncServerOptions$ -- Request: POST /mcp, handled by: POST /mcp, took: 12ms; response: 200
[virtual-72] DEBUG chimp.McpHandler -- Request: {
  "method" : "notifications/initialized",
  "jsonrpc" : "2.0"
}
[virtual-72] DEBUG chimp.McpHandler -- Protocol error (id=null, code=-32600): Invalid request type

I believe we can resolve this by adding

      case Right(notification: JSONRPCMessage.Notification) => notification.unit

on line 137 in chimp.McpHandler.

I wrote a test case that can be added to McpHandlerSpec as well which passes after this change and fails before.

  it should "accept notifications" in:
    // Given
    val req: JSONRPCMessage = Notification(method = "notifications/initialized")
    val json = req.asJson
    // When
    val respJson = handler.handleJsonRpc(json)
    val resp = respJson.as[JSONRPCMessage].getOrElse(fail("Failed to decode response"))
    // Then
    resp match
      case Notification(_, methodName, _) => methodName shouldBe "notifications/initialized"
      case _                              => fail("Expected Notification")

I'd be happy to open a PR, but I don't think I have permissions to do so.

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