Skip to content

About

No description, website, or topics provided.

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

 
 

Latest commit

 

History

654 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

LangChain4j CDI Logo

License Maven Build Status Discord

LangChain4j CDI Integration

Enterprise CDI extension for LangChain4j — inject AI services directly into your Jakarta EE and MicroProfile applications.

Documentation

Full documentation is available at langchain4j.github.io/langchain4j-cdi.

Features

  • AI Service Injection — declare AI services as CDI beans using @RegisterAIService
  • Agentic Topologies — 11 per-topology annotations (@RegisterSimpleAgent, @RegisterSequenceAgent, @RegisterLoopAgent, etc.) for multi-agent workflows
  • MCP Server — expose CDI beans as a Model Context Protocol server
  • Configuration via Properties — configure LLM components through MicroProfile Config or a custom SPI
  • Fault Tolerance — resilience with @Retry, @Timeout, @CircuitBreaker, @Fallback
  • Telemetry — OpenTelemetry-based observability for AI operations
  • Expression Language — resolve ${...} (MicroProfile Config) and #{...} (Jakarta EL) expressions in annotations
  • Guardrails — input and output validation for AI service interactions

The MCP server is dual-era: on the same /mcp endpoint it speaks both the legacy MCP 2025-03-26 protocol (session handshake) and the stateless MCP 2026-07-28 revision, so existing and modern clients connect side by side. See langchain4j-cdi-mcp/README.md for the full guide, including protocol diagrams and conformance results.

Supported Runtimes

Runtime Extension Type
Quarkus Build-compatible
Helidon Both
WildFly Portable
Payara Portable
GlassFish Portable
Liberty Portable

Quick Start

1. Add the dependency:

<!-- For portable extension (WildFly, Payara, GlassFish, Liberty) -->
<dependency>
    <groupId>dev.langchain4j.cdi</groupId>
    <artifactId>langchain4j-cdi-portable-ext</artifactId>
    <version>${langchain4j-cdi.version}</version>
</dependency>

<!-- For build-compatible extension (Quarkus, Helidon) -->
<dependency>
    <groupId>dev.langchain4j.cdi</groupId>
    <artifactId>langchain4j-cdi-build-compatible-ext</artifactId>
    <version>${langchain4j-cdi.version}</version>
</dependency>

2. Define an AI service:

@RegisterAIService
public interface AssistantService {

    @SystemMessage("You are a helpful assistant.")
    String chat(String userMessage);
}

3. Inject and use:

@Path("/assistant")
public class AssistantResource {

    @Inject
    AssistantService assistant;

    @GET
    @Path("/chat")
    public String chat(@QueryParam("message") String message) {
        return assistant.chat(message);
    }
}

See the documentation for configuration, agents, tools, RAG, guardrails, and more.

Examples

Example applications are in the examples/ directory, based on a car rental booking scenario. The Quarkus example is recommended for the fastest development experience.

Contributing

See CONTRIBUTING.md for contribution guidelines.

License

Apache License 2.0 — see LICENSE file.

About

No description, website, or topics provided.

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages