Definition
- MCP (Model Context Protocol) is an open protocol (by Anthropic) that standardizes how AI assistants discover and use external tools and data sources.
- MCP Client is the AI application (IDE assistant, chatbot, agent) that needs to call tools or read data.
- MCP Server is a lightweight program that exposes capabilities (tools, resources, prompts) over the MCP protocol.
- Tool is a function the AI can call with parameters and get a result: query account balance, search documents, calculate EMI.
- Resource is read-only data the AI can access: a database schema, a configuration file, a document.
- JSON-RPC is the message format MCP uses for communication between client and server.
Think of the National Bank of India connecting its systems. Before MCP, if the bank wanted its AI assistant to check account balances, it needed custom code for the account system. If it wanted the assistant to search loan policies, it needed different custom code for the document system. MCP is like a universal adapter. The bank builds one MCP server for accounts and one for documents. Any AI assistant that speaks MCP can use both servers without any custom wiring. It is like USB-C: one connector, many devices.
Understanding the Concepts
What problem does MCP solve?
Without MCP, every AI application builds its own integration for each tool. If you have 5 AI assistants and 10 tools, you need 50 custom integrations. With MCP, each tool is exposed as an MCP server. Each AI assistant is an MCP client. You build 10 servers and 5 clients: 15 implementations instead of 50.
package com.bank.ai;
public class MCPProblemDemo {
public static void main(String[] args) {
System.out.println("Without MCP (N x M integrations):");
System.out.println(" AI Assistant 1 -> custom code -> Account API");
System.out.println(" AI Assistant 1 -> custom code -> Document Search");
System.out.println(" AI Assistant 1 -> custom code -> EMI Calculator");
System.out.println(" AI Assistant 2 -> custom code -> Account API (duplicate!)");
System.out.println(" AI Assistant 2 -> custom code -> Document Search (duplicate!)");
System.out.println(" Total: 5 assistants x 10 tools = 50 integrations");
System.out.println();
System.out.println("With MCP (N + M implementations):");
System.out.println(" Account API -> 1 MCP Server");
System.out.println(" Document Search -> 1 MCP Server");
System.out.println(" EMI Calculator -> 1 MCP Server");
System.out.println(" AI Assistant 1 -> MCP Client (uses all servers)");
System.out.println(" AI Assistant 2 -> MCP Client (uses all servers)");
System.out.println(" Total: 10 servers + 5 clients = 15 implementations");
}
}
Without MCP (N x M integrations):
AI Assistant 1 -> custom code -> Account API
AI Assistant 1 -> custom code -> Document Search
AI Assistant 1 -> custom code -> EMI Calculator
AI Assistant 2 -> custom code -> Account API (duplicate!)
AI Assistant 2 -> custom code -> Document Search (duplicate!)
Total: 5 assistants x 10 tools = 50 integrations
With MCP (N + M implementations):
Account API -> 1 MCP Server
Document Search -> 1 MCP Server
EMI Calculator -> 1 MCP Server
AI Assistant 1 -> MCP Client (uses all servers)
AI Assistant 2 -> MCP Client (uses all servers)
Total: 10 servers + 5 clients = 15 implementations
What are the core concepts in MCP?
| Concept | Description | Banking example |
|---|---|---|
| Tool | A function the AI can call with parameters | check_balance(account_id) |
| Resource | Read-only data the AI can access | Loan policy PDF, database schema |
| Prompt | A reusable prompt template | "Summarize this account statement" |
| Server | Exposes tools, resources, prompts | Account service MCP server |
| Client | Discovers and uses servers | IDE assistant, chatbot |
| Transport | Communication channel | stdio (local), HTTP/SSE (remote) |
package com.bank.ai;
public class MCPConceptsDemo {
public static void main(String[] args) {
System.out.println("MCP Server: banking-account-service");
System.out.println();
System.out.println("Tools:");
System.out.println(" check_balance(account_id: string) -> {balance: BigDecimal}");
System.out.println(" get_transactions(account_id: string, days: int) -> [Transaction]");
System.out.println(" calculate_emi(principal: BigDecimal, rate: double, years: int) -> {emi: BigDecimal}");
System.out.println();
System.out.println("Resources:");
System.out.println(" banking://policies/home-loan-2025 (loan policy document)");
System.out.println(" banking://schemas/account-table (database schema)");
System.out.println();
System.out.println("Prompts:");
System.out.println(" summarize-statement: 'Summarize the following account statement...'");
System.out.println(" explain-transaction: 'Explain this transaction in simple terms...'");
}
}
MCP Server: banking-account-service
Tools:
check_balance(account_id: string) -> {balance: BigDecimal}
get_transactions(account_id: string, days: int) -> [Transaction]
calculate_emi(principal: BigDecimal, rate: double, years: int) -> {emi: BigDecimal}
Resources:
banking://policies/home-loan-2025 (loan policy document)
banking://schemas/account-table (database schema)
Prompts:
summarize-statement: 'Summarize the following account statement...'
explain-transaction: 'Explain this transaction in simple terms...'
How does the MCP communication flow work?
MCP uses JSON-RPC 2.0 messages. The client discovers available tools by calling tools/list, then invokes a tool with tools/call.
package com.bank.ai;
public class MCPFlowDemo {
public static void main(String[] args) {
System.out.println("MCP Communication Flow:");
System.out.println();
System.out.println("1. Client -> Server: initialize");
System.out.println(" {jsonrpc: '2.0', method: 'initialize', params: {capabilities: {}}}");
System.out.println();
System.out.println("2. Client -> Server: tools/list");
System.out.println(" Server responds with available tools and their schemas");
System.out.println();
System.out.println("3. AI decides to call check_balance");
System.out.println(" Client -> Server: tools/call");
System.out.println(" {method: 'tools/call', params: {");
System.out.println(" name: 'check_balance',");
System.out.println(" arguments: {account_id: 'SAV2001'}");
System.out.println(" }}");
System.out.println();
System.out.println("4. Server executes and responds:");
System.out.println(" {result: {content: [{type: 'text', text: 'Balance: 75000.00 INR'}]}}");
System.out.println();
System.out.println("5. Client feeds result back to the LLM");
System.out.println(" LLM: 'Rajesh, your account SAV2001 balance is 75,000 INR.'");
}
}
MCP Communication Flow:
1. Client -> Server: initialize
{jsonrpc: '2.0', method: 'initialize', params: {capabilities: {}}}
2. Client -> Server: tools/list
Server responds with available tools and their schemas
3. AI decides to call check_balance
Client -> Server: tools/call
{method: 'tools/call', params: {
name: 'check_balance',
arguments: {account_id: 'SAV2001'}
}}
4. Server executes and responds:
{result: {content: [{type: 'text', text: 'Balance: 75000.00 INR'}]}}
5. Client feeds result back to the LLM
LLM: 'Rajesh, your account SAV2001 balance is 75,000 INR.'
How is MCP similar to JDBC?
MCP does for AI tools what JDBC does for databases. JDBC provides a standard interface so Java code works with any database driver. MCP provides a standard interface so AI clients work with any tool server.
| Aspect | JDBC | MCP | |--------|------|-----| | Problem solved | Java app -> any database | AI client -> any tool | | Standard | JDBC Driver Interface | MCP Protocol Spec | | Provider | Database vendor writes a driver | Tool builder writes an MCP server | | Consumer | Java app uses JDBC API | AI app uses MCP client | | Discovery | DriverManager.getConnection | MCP initialize + tools/list | | Execution | statement.executeQuery(sql) | tools/call(name, arguments) |
package com.bank.ai;
public class MCPvsJDBCDemo {
public static void main(String[] args) {
System.out.println("JDBC analogy:");
System.out.println(" Java App -> JDBC -> PostgreSQL Driver -> Database");
System.out.println(" Java App -> JDBC -> MySQL Driver -> Database");
System.out.println(" Same Java code, different databases.");
System.out.println();
System.out.println("MCP analogy:");
System.out.println(" AI Client -> MCP -> Account Server -> Account API");
System.out.println(" AI Client -> MCP -> Document Server -> Vector DB");
System.out.println(" Same AI client, different tools.");
}
}
JDBC analogy:
Java App -> JDBC -> PostgreSQL Driver -> Database
Java App -> JDBC -> MySQL Driver -> Database
Same Java code, different databases.
MCP analogy:
AI Client -> MCP -> Account Server -> Account API
AI Client -> MCP -> Document Server -> Vector DB
Same AI client, different tools.
What are the transport options?
MCP supports two transport mechanisms:
- stdio (standard I/O): The server runs as a child process. Communication happens over stdin/stdout. Used for local tools.
- HTTP with SSE (Server-Sent Events): The server runs as a web service. Used for remote tools and shared servers.
package com.bank.ai;
public class MCPTransportDemo {
public static void main(String[] args) {
System.out.println("Transport: stdio (local)");
System.out.println(" Client spawns server process");
System.out.println(" JSON-RPC over stdin/stdout");
System.out.println(" Use for: local file access, local DB queries");
System.out.println();
System.out.println("Transport: HTTP + SSE (remote)");
System.out.println(" Server runs as a web service");
System.out.println(" Client connects over HTTP");
System.out.println(" Use for: shared servers, cloud-hosted tools");
System.out.println(" Banking example: account service on internal network");
}
}
Transport: stdio (local)
Client spawns server process
JSON-RPC over stdin/stdout
Use for: local file access, local DB queries
Transport: HTTP + SSE (remote)
Server runs as a web service
Client connects over HTTP
Use for: shared servers, cloud-hosted tools
Banking example: account service on internal network
What are common mistakes with MCP?
Mistake 1: Exposing too many tools
Wrong: an MCP server with 50 tools. The LLM struggles to choose the right one.
Correct: group related tools into focused MCP servers. One server for accounts, one for loans, one for documents.
Mistake 2: No input validation in tool handlers
Wrong: the tool handler trusts the AI's input without validation. The AI might pass an invalid account ID or a negative amount.
Correct: validate all inputs in the tool handler, return clear error messages, and never trust AI-generated parameters blindly.
What should a senior engineer know?
- Spring AI MCP support. Spring AI provides an MCP server framework for Java. You annotate methods as tools with @Tool, and the framework handles JSON-RPC communication, schema generation, and transport.
- Security and authorization. MCP servers in banking must authenticate the client and authorize each tool call. Use OAuth2 tokens or mTLS. Do not expose sensitive tools without authentication.
- Tool schema design. Well-designed tool schemas with clear descriptions, parameter names, and examples help the LLM choose the right tool and provide correct parameters. Think of the schema as the tool's documentation for the AI.
- Sampling. MCP supports a "sampling" capability where the server can ask the client's LLM to generate text. This enables server-side AI workflows without the server needing its own LLM.
- Composability. A single AI client can connect to multiple MCP servers simultaneously. The bank's assistant connects to the account server, the loan server, and the document server. The LLM sees all tools from all servers and chooses the right one.
What are common interview follow-up questions?
- What is the difference between MCP tools and OpenAI function calling?
- How do you secure an MCP server for banking use?
- What is the role of tool descriptions in MCP?
- How do you test an MCP server?
- What happens if the MCP server is slow or unavailable?
Visual Overview
MCP Architecture ================== AI Client (IDE, Chatbot) MCP Servers ──────────────────────── ─────────── │ ┌──────────────────┐ │ tools/list ──> │ Account Server │ │ tools/call ──> │ check_balance │ │ <── │ get_transactions │ │ └──────────────────┘ │ ┌──────────────────┐ │ tools/list ──> │ Loan Server │ │ tools/call ──> │ calculate_emi │ │ <── │ check_eligibility│ │ └──────────────────┘ │ ┌──────────────────┐ │ resources/read ──> │ Document Server │ │ <── │ policy search │ │ │ schema lookup │ └───────────────────── └──────────────────┘ Protocol: JSON-RPC 2.0 over stdio or HTTP+SSE MCP vs Custom Integrations =========================== Without MCP: With MCP: N clients x M tools N clients + M servers = N*M integrations = N+M implementations 5 clients, 10 tools: 5 clients, 10 tools: 50 custom integrations 15 implementations
Key Takeaway
MCP standardizes how AI applications talk to external tools and data. Instead of building custom integration code for every AI-tool combination, you build MCP servers for your tools and MCP clients for your AI applications. Any client works with any server. This is the same principle that made JDBC successful: one standard interface, many implementations.
For the National Bank of India, MCP means building one account service server, one loan server, and one document server. The customer support chatbot, the developer assistant, and the compliance analysis tool all connect to these servers through MCP. Adding a new AI application does not require touching any tool code. Adding a new tool does not require touching any AI application code.
The protocol is simple: JSON-RPC messages over stdio (local) or HTTP (remote). The client discovers available tools by calling tools/list, then invokes tools with tools/call. The server validates inputs, executes the function, and returns the result. The AI client feeds the result back to the LLM, which uses it to generate the final response.
Security is critical in banking MCP servers. Every server must authenticate the client, authorize each tool call, validate all inputs, and log every invocation for compliance. Do not expose banking tools without authentication and rate limiting.
One sentence to remember: MCP is the USB-C of AI tools: one standard protocol that lets any AI client use any tool server without custom integration.
---