atiaomar1978-hub opened a new pull request, #25037:
URL: https://github.com/apache/camel/pull/25037

   ## Summary
   
   Fixes [CAMEL-23948](https://issues.apache.org/jira/browse/CAMEL-23948): 
`AgentConfiguration.withMcpToolProviderFilter(...)` was honored for MCP clients 
configured on the agent (via `AbstractAgent.configureBuilder`), but ignored for 
endpoint-level MCP clients built in 
`LangChain4jAgentProducer.createComposedToolProvider` (`mcpClients` URI option 
and `mcpServer.<name>.*` inline definitions).
   
   This change applies the same filter semantics regardless of where MCP 
clients are configured.
   
   ## Root cause
   
   `LangChain4jAgentProducer` assembled endpoint-level `McpToolProvider` 
instances without calling `McpToolProvider.Builder.filter(...)`, while 
`AbstractAgent` already applied the filter for agent-level MCP clients.
   
   ## Fix
   
   - **`LangChain4jAgentProducer`**: resolve and apply `mcpToolProviderFilter` 
when composing endpoint-level MCP tool providers.
   - **`AbstractAgent`**: add `getMcpToolProviderFilter()` so registry 
`AbstractAgent` beans can supply the filter when MCP clients are configured on 
the endpoint.
   
   Filter resolution order:
   1. Endpoint `agentConfiguration.getMcpToolProviderFilter()`
   2. Registry `AbstractAgent` bean configuration (when endpoint agent is an 
`AbstractAgent`)
   
   ## Files changed
   
   | File | Change |
   |------|--------|
   | `LangChain4jAgentProducer.java` | Apply filter to endpoint-level 
`McpToolProvider` |
   | `AbstractAgent.java` | Expose `getMcpToolProviderFilter()` |
   | `LangChain4jAgentMcpToolProviderFilterTest.java` | Regression tests (4 
cases) |
   | `StubMcpClient.java` | Minimal in-memory MCP client test helper |
   | `langchain4j-agent-mcp.adoc` | Document endpoint-level filter behavior |
   
   ## Test plan
   
   - [x] `LangChain4jAgentMcpToolProviderFilterTest` — 4/4 pass
     - Reject all endpoint MCP tools when filter returns `false`
     - Selective filter exposes only matching tools
     - No filter exposes all endpoint MCP tools
     - Filter from registry `AbstractAgent` applies to endpoint MCP clients
   - [x] Code formatted (`formatter:format impsort:sort`)
   
   Build command used locally (JDK 21):
   
   ```powershell
   $env:JAVA_HOME = 'C:\Program Files\Eclipse Adoptium\jdk-21.0.11.10-hotspot'
   .\mvnw.cmd test -pl 
components/camel-ai/camel-langchain4j-agent,components/camel-ai/camel-langchain4j-agent-api
 -am "-Dtest=LangChain4jAgentMcpToolProviderFilterTest" "-DfailIfNoTests=false"
   ```
   
   Related: CAMEL-23928, CAMEL-23929
   
   _AI-generated PR description on behalf of 
[atiaomar1978-hub](https://github.com/atiaomar1978-hub)_
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to