AI for Java Architects – Part 10

Model Context Protocol (MCP) and Tool Integration: Connecting AI to Enterprise Systems

“An LLM without tools is knowledgeable. An LLM with tools becomes useful.”


Introduction

In the previous articles, we learned:

  • Part 1 — LLM Fundamentals
  • Part 2 — Embeddings and Vector Databases
  • Part 3 — RAG
  • Part 4 — Building RAG Applications
  • Part 5 — Prompt Engineering
  • Part 6 — Spring AI Deep Dive
  • Part 7 — AI Agents
  • Part 8 — Multi-Agent Systems
  • Part 9 — LangChain and LangGraph

By now, our AI applications can:

✅ Answer questions

✅ Search documents

✅ Use memory

✅ Execute workflows

✅ Coordinate multiple agents

But there is still a major limitation.

Suppose the user asks:

What is the status of order 10045?

The model doesn’t know.

The information exists in:

  • Oracle database
  • REST API
  • Kafka event
  • Redis cache
  • CRM system

How does the AI access these systems?

This is where:

Model Context Protocol (MCP)

enters the picture.


The Fundamental Problem

Every application exposes APIs differently.

Examples:

Jira REST API

MySQL

Oracle

SAP

Salesforce

Spring Boot APIs

Kafka

Redis

Every AI vendor would need custom integrations.

This creates:

  • Duplication
  • Vendor lock-in
  • Maintenance challenges

The Need for a Standard

Imagine if:

  • Every database had its own JDBC.
  • Every web service had a different HTTP.

Software engineering solved this with standards.

AI is beginning to solve this through:

MCP


What is MCP?

MCP stands for:

Model Context Protocol

It is a standard for exposing:

  • Tools
  • APIs
  • Data
  • Systems

to AI models.

Think of it as:

JDBC for AI.

Or:

REST for LLMs.


Traditional Integration

LLM
  ↓
Custom Code
  ↓
Database

MCP Integration

LLM
   ↓
MCP Client
   ↓
MCP Server
   ↓
Tools
   ↓
Systems

Java Analogy

Traditional JavaAI
JDBCMCP
DriverMCP Server
DataSourceTool Registry
SQL QueryTool Invocation

What Does an MCP Server Provide?

It exposes:

  • Tools
  • Resources
  • Functions

Example:

calculateDeadline()

findCustomer()

searchArchitecture()

getOrders()

Example: Holiday Service

Your existing service:

GET /holidays

MCP exposes:

calculateWorkingDay()

The AI can call it directly.


Why This Matters

Imagine asking:

Calculate the 5th working day after June 15 excluding holidays.

The model:

  1. Calls holiday service.
  2. Gets holiday list.
  3. Calculates date.
  4. Responds.

No hallucination.

Real data.


MCP Architecture

User
   ↓
LLM
   ↓
MCP Client
   ↓
MCP Server
   ↓
Enterprise Systems

Tools

Tools are actions.

Examples:

ToolPurpose
findOrderRetrieve orders
getCustomerCustomer lookup
calculateDateBusiness logic
searchDocumentRAG
createTicketJira

Resources

Resources are information.

Examples:

  • PDFs
  • Documentation
  • Databases
  • Files

Prompts

MCP can even expose:

  • Standard prompts
  • Templates
  • Workflows

Example Tool Definition

Conceptually:

Tool:
calculateDeadline

Input:
startDate
workingDays

Output:
deadlineDate

Example: Order Status Agent

User:

Where is order 1050?

Agent:

Thought:
Need order details.

Tool:
findOrder(1050)

Observation:
Delivered.

Answer:
Order delivered yesterday.

Database as a Tool

Traditional:

repository.findById(id);

AI:

Tool:
findCustomer()

The model decides when to use it.


REST APIs as Tools

Your existing APIs become AI capabilities.

Examples:

GET /orders

GET /customers

POST /tickets

Messaging Systems as Tools

Imagine:

Publish Event

Read Queue

Check Status

Agents can interact with:

  • SQS
  • SNS
  • Kafka
  • Solace

Enterprise Example

Your existing architecture:

Base Engine

Mediator

Choreo

Atomic

Each service could expose tools.

Example:

validateRequest()

calculateDeadline()

publishEvent()

The AI agent orchestrates them.


RAG as a Tool

Tool:

searchArchitecture()

Returns:

  • HLD
  • LLD
  • APIs

The model uses retrieved information.


Tool Calling Workflow

Question
    ↓
Reasoning
    ↓
Select Tool
    ↓
Execute
    ↓
Observe
    ↓
Respond

Multiple Tool Calls

User:

Find my tickets and summarize blockers.

Agent:

  1. Query Jira.
  2. Retrieve tickets.
  3. Analyze.
  4. Summarize.

Example Enterprise Workflow

Question
   ↓
Customer API
   ↓
Order API
   ↓
Payment API
   ↓
Summary

Human Approval

Not every tool should execute automatically.

Example:

Delete Account?

Agent:

Approval required.


Permissions

Tools can have:

  • Read-only access.
  • Write access.
  • Admin access.

Security

Never allow:

DROP DATABASE

without controls.


MCP and Spring Boot

Spring services already expose:

  • REST APIs
  • Business services
  • Integration points

These can become:

  • Tools
  • Resources
  • Agent capabilities

Example Architecture

Spring Boot
     ↓
Business Service
     ↓
MCP Tool
     ↓
AI Agent

Why Architects Should Care

You already have:

  • APIs
  • Services
  • Databases
  • Business logic

MCP allows AI to use them.


Example: Deadline Calculation

Current:

User
 ↓
UI
 ↓
API
 ↓
Service

Future:

User
 ↓
Agent
 ↓
Deadline Tool
 ↓
Service

Multi-Agent Example

Supervisor:

Process customer issue.

Agents:

  • Customer Agent.
  • Order Agent.
  • Payment Agent.

Each uses tools.


AWS Example

Tools:

  • Lambda
  • DynamoDB
  • Bedrock
  • S3

Production Example

Incident Agent

Tools:

  • CloudWatch
  • Grafana
  • Logs API

Question:

Why did production fail?

Agent:

  • Retrieves logs.
  • Analyzes metrics.
  • Suggests causes.

Observability

Track:

  • Tool calls.
  • Latency.
  • Failures.
  • Costs.

Error Handling

Tool unavailable:

Retry.

Fallback.

Escalate.

Future Enterprise Architecture

Today:

Application
    ↓
API

Tomorrow:

Application
    ↓
Tool
    ↓
Agent

Java Analogy

JavaMCP
JDBC DriverMCP Server
Service InterfaceTool
RepositoryResource
REST APITool Endpoint
DTOTool Response

Interview Questions

What is MCP?

A protocol for connecting AI models to tools and resources.


Why is MCP important?

It standardizes AI integrations.


What is a tool?

An executable capability.


What is a resource?

Information exposed to AI.


Why are permissions important?

Security and governance.


Hands-On Exercise

Build:

Holiday Tool

Expose:

calculateDeadline()

Agent:

Calculate the next working day.


Enterprise Project

Architecture Copilot

Tools:

  • searchArchitecture
  • findAPI
  • getJira
  • analyzeCosts

The agent becomes an architecture consultant.


Key Takeaways

✔ Models need tools.

✔ MCP standardizes integrations.

✔ APIs become tools.

✔ Databases become resources.

✔ Business services become capabilities.

✔ Security is critical.

✔ AI agents will increasingly consume enterprise systems through standardized interfaces.


What’s Next?

Part 11 — Building Production AI Systems on AWS

Topics:

  • Bedrock.
  • OpenSearch.
  • S3.
  • Lambda.
  • EKS.
  • Observability.
  • Cost optimization.
  • Security.
  • Enterprise deployment.

Because building a demo is easy.

Building production AI systems is engineering.


“The future of enterprise software may not be APIs talking to applications, but agents talking to tools.”

Leave a Reply

Your email address will not be published. Required fields are marked *