Skip to content

LoggingMessageNotification.data is String, so the client fails on object data (e.g. from FastMCP servers) #1180

Open

Description

@pavelkokush

Bug description
The MCP spec allows any JSON value in notifications/message params.data (type unknown). The SDK declares LoggingMessageNotification.data as String. When a server sends an object, the client cannot parse the notification. It logs an ERROR and drops the log message. The tool call itself still works.

FastMCP sends data as an object for every ctx.info() / ctx.log(): {"msg": "...", "extra": null}. So any SDK client calling a FastMCP tool that logs will hit this.

ERROR i.m.spec.McpClientSession : Error handling notification: Cannot deserialize value of type `java.lang.String` from Object value (token `JsonToken.START_OBJECT`)
 (through reference chain: io.modelcontextprotocol.spec.McpSchema$LoggingMessageNotification["data"])

Environment

  • MCP Java SDK 2.0.1 (also 2.0.0)
  • Spring AI 2.0.0, Java 21
  • Server: FastMCP 3.3.1, Streamable HTTP

Steps to reproduce

  1. Run the FastMCP server below.
  2. Call the hello tool with McpSyncClient.

Expected behavior
The notification is parsed and passed to the logging consumers. data should accept any JSON value, as the spec says.

Minimal Complete Reproducible example
Server:

from fastmcp import FastMCP, Context

mcp = FastMCP("repro")

@mcp.tool
async def hello(ctx: Context) -> str:
    await ctx.info("working")
    return "ok"

mcp.run(transport="streamable-http", port=8000)

Client:

var client = McpClient.sync(
        HttpClientStreamableHttpTransport.builder("http://localhost:8000").endpoint("/mcp").build())
    .build();
client.callTool(McpSchema.CallToolRequest.builder("hello").build()); // returns "ok", but logs the ERROR above

Possible fix that does not break the API: keep String, but turn a non-string data into its JSON text when parsing.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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