Skip to content

CAMEL-24369: camel-mcp-server jackson-annotations alignment + camel-openai deferred MCP client init - #25404

Merged
davsclaus merged 4 commits into
apache:mainfrom
Croway:CAMEL-24369-ai-tool-mcp-server-fixes
Aug 7, 2026
Merged

CAMEL-24369: camel-mcp-server jackson-annotations alignment + camel-openai deferred MCP client init#25404
davsclaus merged 4 commits into
apache:mainfrom
Croway:CAMEL-24369-ai-tool-mcp-server-fixes

Conversation

@Croway

@Croway Croway commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

JIRA: CAMEL-24369

Two fixes found by running the same ai-tool + mcp-server application on Camel Main, Spring Boot and Quarkus (companion PRs in apache/camel-spring-boot and apache/camel-quarkus):

camel-mcp-server: jackson-annotations alignment

An application importing only camel-bom fails at MCP engine startup with NoClassDefFoundError: com/fasterxml/jackson/annotation/JsonSerializeAs: the MCP Java SDK (mcp-core, still latest 2.0.0) declares jackson-annotations:2.20, which nearest-wins resolution picks over the 2.22 required by jackson-databind:2.22.1. A direct dependency on the aligned jackson-annotations makes consumers resolve a consistent version with or without the jackson-bom.

camel-openai: defer initialization of MCP servers unreachable at endpoint startup

openai:chat-completion?mcpServer.x.url=<own /mcp> (an application consuming its own MCP endpoint — the pattern shown in the mcp-server docs) initializes its MCP client eagerly on route warm-up. On Quarkus the HTTP server only accepts connections after the application has started, so the route — and the whole application — failed to start; on Spring Boot the client started with 0 tools; on Camel Main it worked. Now an MCP server that is unreachable during doStart is recorded with a WARN and initialized lazily on first use, reusing the existing reconnect path and per-server locks. Invalid configuration (e.g. missing transportType) still fails fast. This aligns behavior across runtimes and matches the in-process registration model of annotated tools (quarkiverse @Tool, Spring AI @McpTool), which cannot hit this ordering problem.

Includes a new unit test (OpenAIEndpointMcpDeferredInitTest, 4 scenarios), the openai-mcp.adoc error-table update, and a fix for the stale ai-tool "See Also" section (langchain4j-agent and spring-ai-chat discover ai-tool routes today, not "in a future release").

Verified end-to-end: 27/27 MCP conformance scenario checks on all three runtimes with local Ollama.


Claude Code on behalf of Croway (Federico Mariani)

🤖 Generated with Claude Code

Croway and others added 2 commits August 7, 2026 10:42
…-databind for camel-bom users

The MCP Java SDK (mcp-core) declares jackson-annotations 2.20, which nearest-wins
resolution picks over the 2.22 required by jackson-databind 2.22.1 when an
application imports only camel-bom, failing at MCP engine startup with
NoClassDefFoundError: com/fasterxml/jackson/annotation/JsonSerializeAs.
Declare the aligned jackson-annotations directly so consumers resolve a
consistent version with or without the jackson-bom.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
…hable at endpoint startup

An application consuming its own MCP endpoint (or one of a service starting
concurrently) failed route startup on runtimes where the HTTP server only
accepts connections after the application has started (e.g. Quarkus). An MCP
server that is unreachable during doStart is now recorded with a WARN and its
initialization is deferred and retried on first use, reusing the existing
reconnect path and per-server locks. Invalid configuration still fails fast.
This aligns the behavior across Camel Main, Spring Boot and Quarkus and
matches the in-process registration model of annotated tools, which cannot
hit this ordering problem.

Also update the stale ai-tool See Also section: langchain4j-agent and
spring-ai-chat discover ai-tool routes today, not in a future release.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Aug 7, 2026

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.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>

@davsclaus davsclaus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Clean, well-structured PR that addresses a real cross-runtime compatibility issue.

Highlights:

  • Smart reuse of the existing doReconnectMcpServer path for deferred init — no duplicated logic
  • Fast-fail preserved: transportType validation stays before the try-catch, so invalid config still fails the route at startup
  • Thread safety is sound: ConcurrentHashMap.newKeySet() for pendingMcpServers, tryLock() to avoid blocking on concurrent getMcpToolState() calls, and mcpStopped double-check inside the lock prevents zombie initialization after doStop()
  • Tests cover the key scenarios (startup resilience, lazy init, eager init, stopped endpoint safety)
  • jackson-annotations alignment is correct and well-commented
  • Doc updates are accurate (future-tense → present-tense in See Also, error table reflects new behavior)

Minor observation (non-blocking): when the server is still unreachable, each getMcpToolState() call triggers doReconnectMcpServer, which logs at LOG.error on failure. For the deferred-init use case this is expected transient behavior — could consider a follow-up to suppress the ERROR log during deferred retries.

This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.

@davsclaus

Copy link
Copy Markdown
Contributor

There are uncommitted changes
HEAD detached at pull/25404/merge
Changes not staged for commit:
(use "git add ..." to update what will be committed)
(use "git restore ..." to discard changes in working directory)
modified: catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/ai-tool-component.adoc
modified: catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/openai-mcp.adoc

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
@davsclaus
davsclaus merged commit aa8c9d3 into apache:main Aug 7, 2026
6 checks passed
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • catalog/camel-catalog
  • components/camel-ai/camel-ai-tool
  • components/camel-ai/camel-mcp-server
  • components/camel-ai/camel-openai

🔬 Scalpel shadow comparison — Scalpel: 15 tested, 28 compile-only — current: 14 all tested

Maveniverse Scalpel detected 43 affected modules (current approach: 14).

⚠️ Modules only in Scalpel (29)
  • apache-camel
  • camel-allcomponents
  • camel-catalog
  • camel-catalog-console
  • camel-catalog-lucene
  • camel-catalog-maven
  • camel-catalog-suggest
  • camel-componentdsl
  • camel-csimple-maven-plugin
  • camel-endpointdsl
  • camel-endpointdsl-support
  • camel-itest
  • camel-jbang-core
  • camel-jbang-it
  • camel-jbang-main
  • camel-jbang-plugin-edit
  • camel-jbang-plugin-generate
  • camel-jbang-plugin-kubernetes
  • camel-jbang-plugin-test
  • camel-kamelet-main
  • camel-launcher
  • camel-report-maven-plugin
  • camel-route-parser
  • camel-yaml-dsl
  • camel-yaml-dsl-deserializers
  • camel-yaml-dsl-maven-plugin
  • coverage
  • docs
  • dummy-component

Skip-tests mode would test 15 modules (4 direct + 11 downstream), skip tests for 28 (generated code, meta-modules)

Modules Scalpel would test (15)
  • camel-ai-tool
  • camel-catalog
  • camel-jbang-mcp
  • camel-jbang-plugin-mcp
  • camel-jbang-plugin-route-parser
  • camel-jbang-plugin-tui
  • camel-jbang-plugin-validate
  • camel-langchain4j-agent
  • camel-launcher-container
  • camel-mcp-server
  • camel-mcp-server-api
  • camel-openai
  • camel-spring-ai-chat
  • camel-yaml-dsl-validator
  • camel-yaml-dsl-validator-maven-plugin
Modules with tests skipped (28)
  • apache-camel
  • camel-allcomponents
  • camel-catalog-console
  • camel-catalog-lucene
  • camel-catalog-maven
  • camel-catalog-suggest
  • camel-componentdsl
  • camel-csimple-maven-plugin
  • camel-endpointdsl
  • camel-endpointdsl-support
  • camel-itest
  • camel-jbang-core
  • camel-jbang-it
  • camel-jbang-main
  • camel-jbang-plugin-edit
  • camel-jbang-plugin-generate
  • camel-jbang-plugin-kubernetes
  • camel-jbang-plugin-test
  • camel-kamelet-main
  • camel-launcher
  • camel-report-maven-plugin
  • camel-route-parser
  • camel-yaml-dsl
  • camel-yaml-dsl-deserializers
  • camel-yaml-dsl-maven-plugin
  • coverage
  • docs
  • dummy-component

ℹ️ Shadow mode — Scalpel observes but does not affect test execution. Learn more

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

  • components/camel-ai/camel-mcp-server: 1 test(s) disabled on GitHub Actions
  • components/camel-ai/camel-openai: 7 test(s) disabled on GitHub Actions
All tested modules (43 modules)
  • Camel :: AI :: LangChain4j :: Agent
  • Camel :: AI :: MCP Server
  • Camel :: AI :: MCP Server API
  • Camel :: AI :: OpenAI
  • Camel :: AI :: Tool
  • Camel :: All Components Sync point
  • Camel :: Assembly
  • Camel :: Catalog :: CSimple Maven Plugin (deprecated)
  • Camel :: Catalog :: Camel Catalog
  • Camel :: Catalog :: Camel Report Maven Plugin
  • Camel :: Catalog :: Camel Route Parser
  • Camel :: Catalog :: Console
  • Camel :: Catalog :: Dummy Component
  • Camel :: Catalog :: Lucene (deprecated)
  • Camel :: Catalog :: Maven
  • Camel :: Catalog :: Suggest
  • Camel :: Component DSL
  • Camel :: Coverage
  • Camel :: Docs
  • Camel :: Endpoint DSL
  • Camel :: Endpoint DSL :: Support
  • Camel :: Integration Tests
  • Camel :: JBang :: Core
  • Camel :: JBang :: Integration tests
  • Camel :: JBang :: MCP
  • Camel :: JBang :: Main
  • Camel :: JBang :: Plugin :: Edit
  • Camel :: JBang :: Plugin :: Generate
  • Camel :: JBang :: Plugin :: Kubernetes
  • Camel :: JBang :: Plugin :: MCP
  • Camel :: JBang :: Plugin :: Route Parser
  • Camel :: JBang :: Plugin :: TUI
  • Camel :: JBang :: Plugin :: Testing
  • Camel :: JBang :: Plugin :: Validate
  • Camel :: Kamelet Main
  • Camel :: Launcher
  • Camel :: Launcher :: Container
  • Camel :: Spring AI :: Chat
  • Camel :: YAML DSL
  • Camel :: YAML DSL :: Deserializers
  • Camel :: YAML DSL :: Maven Plugins
  • Camel :: YAML DSL :: Validator
  • Camel :: YAML DSL :: Validator Maven Plugin

⚙️ View full build and test results

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants