Class McpAgent
java.lang.Object
dev.langchain4j.agentic.mcp.McpAgent
Provides type-safe factory methods to create MCP client agent builders.
An MCP client agent wraps a single MCP tool as a non-AI agent, allowing it to be composed with other agents in sequences, loops, supervisors, and other workflow patterns.
UntypedAgent agent = McpAgentBuilder
.mcpBuilder(mcpClient)
.toolName("my_tool")
.inputKeys("arg1", "arg2")
.outputKey("result")
.build();
-
Method Summary
Modifier and TypeMethodDescriptionstatic McpClientBuilder<UntypedAgent> Creates a builder for an untyped MCP client agent.static <T> McpClientBuilder<T> Creates a builder for a typed MCP client agent implementing the given agent service interface.
-
Method Details
-
builder
Creates a builder for an untyped MCP client agent.- Parameters:
mcpClient- the MCP client instance used to discover and execute the tool- Returns:
- a new McpClientBuilder instance
-
builder
Creates a builder for a typed MCP client agent implementing the given agent service interface.- Parameters:
mcpClient- the MCP client instance used to discover and execute the toolagentServiceClass- the class of the agent service interface- Returns:
- a new McpClientBuilder instance
-