Skip to content

CAMEL-23476: camel-jbang-mcp: strip null fields from MCP JSON responses#23169

Merged
oscerd merged 1 commit into
apache:mainfrom
oscerd:fix/CAMEL-23476
May 13, 2026
Merged

CAMEL-23476: camel-jbang-mcp: strip null fields from MCP JSON responses#23169
oscerd merged 1 commit into
apache:mainfrom
oscerd:fix/CAMEL-23476

Conversation

@oscerd
Copy link
Copy Markdown
Contributor

@oscerd oscerd commented May 12, 2026

Summary

Configures the Quarkus Jackson ObjectMapper for the camel-jbang-mcp module
with quarkus.jackson.serialization-inclusion=non-null so the @Tool result
records serialized via JsonTextContentEncoder no longer emit fields with
null values.

This reduces LLM context-window pressure for every caller of the
camel-jbang-mcp server. The module exposes 31 tools, 6 resources and 3 prompts,
so per-call token bloat from useless \"field\": null entries adds up quickly.

Closes CAMEL-23476.

Why this works

io.quarkiverse.mcp.server.runtime.JsonTextContentEncoder (the default content
encoder used for arbitrary objects returned from @Tool methods) injects the
default Quarkus ObjectMapper and calls writeValueAsString(...) on it.
Quarkus' built-in io.quarkus.jackson.runtime.ConfigurationCustomizer
(priority Integer.MAX_VALUE) reads JacksonBuildTimeConfig.serializationInclusion()
and invokes setSerializationInclusion(...) on that ObjectMapper, so the
single property line is enough to strip nulls from every result the MCP server
emits.

The framework already ships an McpObjectMapperCustomizer that adds a
@JsonInclude(NON_NULL) mixin to MCP envelope types (ToolResponse,
PromptResponse, etc.), but not to application-level result records like
ComponentDetailResult or OptionInfo — which is the bug filed in the JIRA.

Changes

  • application.properties: add quarkus.jackson.serialization-inclusion=non-null
  • McpJsonSerializationTest: new test verifying
    • the property is set in application.properties
    • ComponentInfo, OptionInfo and ComponentDetailResult instances with
      null fields produce JSON that omits those fields

Test plan

  • mvn -pl dsl/camel-jbang/camel-jbang-mcp test — 231 tests pass (227 existing + 4 new)
  • mvn clean install -DskipTests from the repo root — full reactor build green

Claude Code on behalf of Andrea Cosentino

Configures the Quarkus Jackson ObjectMapper with serialization-inclusion=non-null
so the @tool result records serialized via JsonTextContentEncoder no longer emit
fields with null values, reducing LLM context-window pressure for every caller of
the camel-jbang-mcp server.

Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
@oscerd oscerd requested review from Croway and gnodet May 12, 2026 21:05
@github-actions
Copy link
Copy Markdown
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@github-actions github-actions Bot added the dsl label May 12, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • dsl/camel-jbang/camel-jbang-mcp

⚠️ Some tests are disabled on GitHub Actions (@DisabledIfSystemProperty(named = "ci.env.name")) and require manual verification:

  • dsl/camel-jbang/camel-jbang-mcp: 1 test(s) disabled on GitHub Actions

⚙️ View full build and test results

@oscerd oscerd merged commit 7d7ee40 into apache:main May 13, 2026
6 checks passed
@oscerd oscerd deleted the fix/CAMEL-23476 branch May 13, 2026 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants