-
Notifications
You must be signed in to change notification settings - Fork 131
Description
I have these components
- A2A client Agent
- A2A Server Agent (protected by OIDC scheme with Keycloak as the authorization server)
- AI Service
- MCP Server (protected by OIDC scheme with Keycloak as the authorization server)
The flow is
A2A client Agent (JSON+RPC transport) >> A2A Server Agent >> AI Service >> MCP Server
In terms of endpoints
A2A Server Agent listening on http://localhost:11001
MCP Server listening on https://wanaku-backend.poc/mcp
The A2A client Agent call to http://localhost:11001 gets authenticated successfully by the A2A Server Agent. The question is how i can propagate the same access token from the authenticated session along when the AI Service makes a call to the MCP server.
Essentially, i would like to understands what options there are to get the same access token from the RPC call being pass along to the MCP and get it injected via the Authorization header
Running a test results in this error. As the MCP call from the AI service does not gets authenticated hence the 401 error
jakarta.enterprise.inject.CreationException: Error creating synthetic bean [U9ADr3gmC8Sgw7Tk6HeTkK8tptU]: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: Unexpected status code: 401
at dev.langchain4j.mcp.client.McpClient_U9ADr3gmC8Sgw7Tk6HeTkK8tptU_Synthetic_Bean.create(Unknown Source)
at dev.langchain4j.mcp.client.McpClient_U9ADr3gmC8Sgw7Tk6HeTkK8tptU_Synthetic_Bean.create(Unknown Source)
... 25 more
Caused by: java.util.concurrent.ExecutionException: java.lang.RuntimeException: Unexpected status code: 401
at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:396)
at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2096)
at dev.langchain4j.mcp.client.DefaultMcpClient.initialize(DefaultMcpClient.java:166)
... 32 more
Caused by: java.lang.RuntimeException: Unexpected status code: 401
at io.quarkiverse.langchain4j.mcp.runtime.http.QuarkusStreamableHttpMcpTransport.lambda$execute$8(QuarkusStreamableHttpMcpTransport.java:259)
at io.vertx.core.impl.future.FutureImpl$4.onSuccess(FutureImpl.java:176)