Skip to content

Conversation

@yoliyu
Copy link
Member

@yoliyu yoliyu commented Jan 12, 2026

Added .objectMapper() configuration to the MCP server to ignore unknown properties, ensuring compatibility with newer versions

.objectMapper(new ObjectMapper().configure(com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false))

Summary by Sourcery

Bug Fixes:

  • Prevent MCP server from failing on incoming messages that contain unknown JSON properties in the transport payload.

@yoliyu yoliyu linked an issue Jan 12, 2026 that may be closed by this pull request
@sourcery-ai
Copy link

sourcery-ai bot commented Jan 12, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Configures the MCP server's HTTP servlet transport ObjectMapper to ignore unknown JSON properties, improving forward compatibility with newer message formats.

Sequence diagram for MCP server JSON deserialization with unknown properties

sequenceDiagram
    actor Client
    participant McpServer
    participant HttpServletStreamableServerTransportProvider as TransportProvider
    participant JacksonObjectMapper as ObjectMapper

    Client->>McpServer: HTTP SSE JSON message
    McpServer->>TransportProvider: handleIncomingMessage(jsonPayload)
    TransportProvider->>ObjectMapper: readValue(jsonPayload, MessageClass)
    ObjectMapper-->>TransportProvider: MessageInstance (unknown properties ignored)
    TransportProvider-->>McpServer: processed MessageInstance
    McpServer-->>Client: SSE response / acknowledgement
Loading

Class diagram for MCP server transport ObjectMapper configuration

classDiagram
    class McpServerConfig {
        +HttpServletStreamableServerTransportProvider servletSseServerTransportProvider()
    }

    class HttpServletStreamableServerTransportProvider {
        -boolean disallowDelete
        -String mcpEndpoint
        -ObjectMapper objectMapper
        +static builder() HttpServletStreamableServerTransportProviderBuilder
    }

    class HttpServletStreamableServerTransportProviderBuilder {
        -boolean disallowDelete
        -String mcpEndpoint
        -ObjectMapper objectMapper
        +disallowDelete(disallowDelete boolean) HttpServletStreamableServerTransportProviderBuilder
        +mcpEndpoint(mcpEndpoint String) HttpServletStreamableServerTransportProviderBuilder
        +objectMapper(objectMapper ObjectMapper) HttpServletStreamableServerTransportProviderBuilder
        +build() HttpServletStreamableServerTransportProvider
    }

    class ObjectMapper {
        +configure(feature DeserializationFeature, state boolean) ObjectMapper
    }

    class DeserializationFeature {
        <<enum>>
        FAIL_ON_UNKNOWN_PROPERTIES
    }

    McpServerConfig --> HttpServletStreamableServerTransportProviderBuilder : uses builder()
    HttpServletStreamableServerTransportProviderBuilder --> HttpServletStreamableServerTransportProvider : builds
    HttpServletStreamableServerTransportProvider --> ObjectMapper : uses
    ObjectMapper --> DeserializationFeature : configures

    McpServerConfig ..> ObjectMapper : creates with
    McpServerConfig ..> DeserializationFeature : sets FAIL_ON_UNKNOWN_PROPERTIES = false
Loading

File-Level Changes

Change Details Files
Configure the MCP HTTP servlet transport ObjectMapper to ignore unknown JSON properties during deserialization.
  • Replaces the default ObjectMapper instance used by HttpServletStreamableServerTransportProvider with one configured to set DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES to false for JSON deserialization.
  • Ensures the MCP server's SSE message endpoint can handle payloads containing additional fields not yet defined in the server-side model.
matchbox-server/src/main/java/ca/uhn/fhir/jpa/starter/mcp/McpServerConfig.java

Assessment against linked issues

Issue Objective Addressed Explanation
#455 Modify the MCP server's JSON deserialization so that unknown fields (such as the "form" field in capabilities.elicitation) do not cause initialization to fail, ensuring compatibility with the VS Code (Copilot) client.

Possibly linked issues

  • #MCP server fails to initialize due to Unrecognized field "form": PR configures Jackson to ignore unknown properties, directly resolving the initialization failure on unrecognized "form" field.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@yoliyu yoliyu requested review from oliveregger and qligier January 12, 2026 12:46
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • Consider reusing a centrally configured ObjectMapper bean instead of instantiating a new one here so that all MCP server transports share consistent serialization/deserialization settings.
  • The configuration currently only relaxes deserialization; if the intention is broader compatibility with evolving payloads, verify whether other DeserializationFeature or MapperFeature flags (e.g., for enums or unknown types) should also be aligned here or in a shared config.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider reusing a centrally configured `ObjectMapper` bean instead of instantiating a new one here so that all MCP server transports share consistent serialization/deserialization settings.
- The configuration currently only relaxes deserialization; if the intention is broader compatibility with evolving payloads, verify whether other `DeserializationFeature` or `MapperFeature` flags (e.g., for enums or unknown types) should also be aligned here or in a shared config.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

.disallowDelete(false)
.mcpEndpoint(SSE_MESSAGE_ENDPOINT)
.objectMapper(new ObjectMapper())
.objectMapper(new ObjectMapper().configure(com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.objectMapper(new ObjectMapper().configure(com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false))
.objectMapper(new ObjectMapper().configure(FAIL_ON_UNKNOWN_PROPERTIES, false))

Please use imports to make the code more readable.

Copy link
Member

@oliveregger oliveregger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx, can you update docs/changelog.md with the PR that the issue #455 will be closed with this?

@yoliyu yoliyu merged commit eb3f074 into main Jan 13, 2026
9 checks passed
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.

MCP server fails to initialize due to Unrecognized field "form"

4 participants