Class McpToolResolutionException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
dev.langchain4j.exception.LangChain4jException
dev.langchain4j.agentic.agent.AgentUnavailableException
dev.langchain4j.agentic.mcp.McpToolResolutionException
- All Implemented Interfaces:
Serializable
Thrown when the MCP tool wrapped by an MCP client agent cannot be resolved, because the MCP client cannot be
created or the tools of the MCP server cannot be listed. The tool is resolved lazily, the first time it is needed,
which is normally the first invocation of the agent, so this exception reaches the caller of that invocation and
the error handler of the agentic system, where it can be recognized to skip an agent whose MCP server is
unavailable, by this type or by its supertype
AgentUnavailableException, common to every integration. A
resolution that does not complete within the resolution timeout of the agent, when one is set, is interrupted and
reported with this exception too, with a TimeoutException as cause. As long as a resolution that timed
out has not reacted to its interruption, the tool cannot be resolved again: the invocations arriving in the
meantime fail at once, with a message saying that the previous resolution is still running. Concurrent first
invocations wait on the same resolution and all fail when it fails, each with its own exception sharing that
cause, but a failed resolution is not cached: the next invocation retries it. A retry from the error handler
happens at once, so it should be bounded by the handler itself. A tool that is not found on the server, or a
missing tool name when the server exposes several tools, is a configuration error instead, reported with an
AgenticSystemConfigurationException.- Since:
- 1.24.0
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionMcpToolResolutionException(String agentName, String toolName, Throwable cause) -
Method Summary
Methods inherited from class AgentUnavailableException
agentNameMethods inherited from class Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
McpToolResolutionException
-
-
Method Details
-
toolName
- Returns:
- the name of the tool configured for the agent, or
nullwhen the agent binds the single tool of its MCP server - Since:
- 1.24.0
-