Building a Tool Engine with Spring AI — How We Gave Jarvis the Ability to Act in the World
From knowing to doing — Phase 4 of the Jarvis AI Platform The Problem with Knowledge-Only AI After Phase 3, Jarvis could remember you across sessions and search your documents. But it still had a fundamental limitation. You: "What is the weather in Kathmandu right now?" Jarvis: "I don't have access to real-time weather data." You: "What is 2847 × 391?" Jarvis: "The answer is approximately 1.1 million." ← WRONG An AI that only knows things from training data is useful. An AI that can do things is transformative. That is what Phase 4 built. What Is a Tool Engine? A tool engine gives the AI model the ability to call real functions during a conversation. The flow looks like this: User: "What is the weather in Kathmandu?" ↓ AI Model ↓ "I should call WeatherTool" ↓ WeatherTool.getWeather("Kathmandu") ↓ "22°C, Clear sky, Humidity: 45%" ↓ AI Model ↓ "The weather in Kathmandu is 22°C and clear." The key insight: the AI decides when to call a tool and with what input . We don't hardcode "if user asks about weather, call WeatherTool." The model figures that out from the tool descriptions we provide. The Architecture Decision The most important architectural decision in Phase 4 was the package structure. ai . jarvis . tools / ├── JarvisTool . java ← marker interface ( root ) ├── ToolRegistry . java ← manages all tools ( root ) ├── builtin / ← built - in tools │ ├── DateTimeTool . java │ ├── CalculatorTool . java │ ├── WeatherTool . java │ └── WebSearchTool . java └── mcp / ← MCP protocol └── McpServerConfig . java Why not put tools inside ai/ ? The ai/ package handles HOW Jarvis talks to AI models. Tools define WHAT Jarvis can do. These are fundamentally different responsibilities. Mixing them would mean every new tool requires changes to AI infrastructure code. Keeping them, separate means adding a new tool requires exactly one file. The JarvisTool Pattern Every tool in Jarvis implements one interface. /** * Marker interface for all Jarvis tools. * Spring auto-discovers all @C