Build AI agents with Spring AI 2.0 - basic agent, memory, tools/MCP, agentic workflows, guardrails, and observability
86
85%
Does it follow best practices?
Impact
90%
2.43xAverage score across 3 eval scenarios
Passed
No known issues
A legal-tech startup is building a document analysis platform that allows law firms to submit contracts for automated review. The backend needs two components: (1) an MCP server that exposes document analysis capabilities (clause extraction, risk flagging, summary generation) to any MCP-compatible client, and (2) an orchestrating agent that accepts a contract analysis request, decomposes it into sub-tasks, assigns them to appropriate workers, and assembles a final report.
The orchestrating agent has been a black box — the team cannot tell what the agent was "thinking" when it chose which analysis tool to call and why. This makes it difficult to audit decisions on sensitive legal documents. The platform lead wants every tool invocation logged with the agent's stated reasoning before the tool executes, so the audit trail can be reviewed later.
Produce a self-contained Spring Boot application with both the MCP server and the orchestrating agent client:
DocumentAnalysisMcpServer.java — Spring component exposing at least three document analysis tools via MCP annotations: clause extraction, risk flagging, and document summarisation. Tool parameters should include the document text as a required parameter and at least one optional parameter per tool (e.g., focus area, severity threshold).ContractOrchestratorAgent.java — Service that takes a contract text string and produces a structured analysis report by orchestrating calls to the document tools. This orchestrator should decompose the contract analysis into sub-tasks and coordinate their execution using a structured multi-step approach. It must also be configured so that the agent's reasoning for each tool call is captured and written to a log file analysis-reasoning.log in the working directory.AgentConfig.java — Spring configuration class wiring together the ChatClient, tools, and reasoning captureAnalysisReport.java — Record or class representing the final assembled report (clause list, risk items, summary)pom.xml — Maven build descriptorapplication.properties — Application configurationThe analysis tools may return plausible hardcoded or simulated results — no real document parsing is required. The reasoning log entries must be written to analysis-reasoning.log and should include the tool name and the agent's stated reason for calling it.