MCP Explained for Developers: What It Is and When You Need It

Every few months, our industry invents a new acronym and convinces us it’s the future. Some stick (REST, Kubernetes), some fade (RIP, NFT). MCP — the Model Context Protocol — is looking very much like the former. If you’re an AI engineer in India building agents, or prepping for interviews where “have you worked with MCP?” now shows up, this article is for you.

We’ll do this in three acts: the problem, the solution, and how your life changes after it.

Act 1: The Problem — Your AI Model Is Brilliant but Completely Disconnected

Here’s a scenario every Indian developer will recognize. Your boss says:

“Build a chatbot where employees can check their leave balance, raise IT tickets, and see the cafeteria menu.”

The uncomfortable truth: the AI model is the easy part. It already knows English, it can reason, it can write code. The hard part is this:

The model has no idea your company exists.

It doesn’t know your HR system, your Jira, your cafeteria API. It has zero access. So as the engineer, you have to teach it. And “teaching” means writing custom code that:

  1. Exposes each system as a function the model can call
  2. Describes that function to the model in its preferred JSON format
  3. Translates the model’s messy output into your API’s format
  4. Handles errors, auth, and timeouts

Now multiply by three systems. Now multiply again, because your colleague in the next team is building a different chatbot that needs the same three systems — and she has to write the same glue code all over again, because her agent speaks a slightly different dialect.

This is the M×N explosion:

M AI applications × N tools = M×N custom integrations. Every pair is bespoke plumbing.

Nobody builds anything reusable. Everyone becomes a full-time glue-code writer. Add one more tool, and every agent that might want it needs to be touched. Add one more agent, and every tool needs re-plumbing for it. The system scales terribly, and the worst part? Your API keys and credentials end up floating dangerously close to prompt text, where a prompt-injection attack can reach them.

That is the problem MCP was built to kill.

Act 2: The Solution — MCP Is the USB-C Moment for AI

Remember life before USB-C? Every phone had its own charger. Every hotel room was a scavenger hunt for the right cable. Then USB-C arrived: one port, one cable, everything works. The phone maker doesn’t care which charger you use; the charger maker doesn’t care which phone you own.

MCP does the same thing for AI tools.

  • Your leave system gets wrapped once, in a standard way, as an MCP server.
  • Now Claude Desktop can use it. Cursor can use it. Your own Streamlit app can use it. Your teammate’s chatbot can use it. Write once, plug into any AI app.

The M×N explosion collapses into M + N: each tool builds one server, each AI app speaks one protocol.

MCP is simply a standard way for AI applications to discover and use tools and data. No magic, no new model — just a shared plug shape.

The three moving parts (60 seconds)

  • Host — the AI app the user talks to: Claude Desktop, Cursor, VS Code, or your Streamlit app.
  • Client — a messenger inside the host. One client = one connection = one server.
  • Server — a small program exposing capabilities: tools (actions the model can take), prompts (workflows the user triggers), and resources (context the app injects). Keep servers narrow: one server, one job.

A handy analogy: the host is your office receptionist, the clients are the intercom lines, the servers are the departments. The receptionist doesn’t need to know how accounts works internally — they just pick up the right intercom and ask.

The golden mental model: who decides?

PrimitiveWho triggers itThink of it as
ToolThe LLMA verb — do something
PromptThe userA saved workflow — run this process
ResourceThe host appA noun — here’s some context

Honest note: today’s ecosystem is heavily tool-centric; prompts and especially resources have patchy client support. Design for where things are heading, but build tools first.

Act 3: A Real Example — Build Your First MCP Server in 10 Minutes

Let’s build that HR leave assistant. Install FastMCP:

bash

pip install fastmcp

leave_server.py:

Python

from fastmcp import FastMCP

# In production this talks to your real HR API (Keka, greytHR, Zoho People...).
# Here we fake it with a dict — the point is the MCP layer, not the backend.
mcp = FastMCP("hr-leave-assistant")

LEAVE_DB = {
    "priya": {"casual": 8, "sick": 5, "earned": 12},
    "arjun": {"casual": 2, "sick": 1, "earned": 4},
}

@mcp.tool()
def check_leave_balance(employee_name: str) -> str:
    """Check the remaining leave balance for an employee.

    Args:
        employee_name: The employee's first name, lowercase.
    """
    balances = LEAVE_DB.get(employee_name.lower())
    if not balances:
        return f"No record found for '{employee_name}'."
    return f"{employee_name.title()} has: " + ", ".join(
        f"{k}={v}" for k, v in balances.items()
    )

@mcp.tool()
def apply_leave(employee_name: str, leave_type: str, days: int) -> str:
    """Apply for leave. Returns approval status.

    Args:
        employee_name: The employee's first name, lowercase.
        leave_type: One of 'casual', 'sick', or 'earned'.
        days: Number of days of leave requested.
    """
    name = employee_name.lower()
    if name not in LEAVE_DB:
        return f"Unknown employee '{employee_name}'."
    if LEAVE_DB[name].get(leave_type, 0) >= days:
        LEAVE_DB[name][leave_type] -= days
        return f"Approved! {days} day(s) of {leave_type} leave for {name}."
    return f"Insufficient {leave_type} leave balance."

@mcp.prompt()
def leave_application_email(employee_name: str, leave_type: str, days: int) -> str:
    """Generate a professional leave application email."""
    return (f"Write a polite, concise leave application email from {employee_name} "
            f"requesting {days} day(s) of {leave_type} leave. "
            f"Mention willingness to hand over pending work before leaving.")

if __name__ == "__main__":
    mcp.run()  # serves over stdio by default

That’s it — one MCP server, two tools, one prompt. Notice what’s not there: no HTTP routes, no hand-written JSON schemas, no auth boilerplate. FastMCP derives tool schemas from your type hints and docstrings.

Now the Client — Your Own Streamlit App, No Claude Desktop Needed

Seeing the plumbing yourself is the best way to understand MCP, so let’s skip the desktop apps and write our own client:

bash

pip install mcp streamlit openai

app.py:

Python

import asyncio
import json

import streamlit as st
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client
from openai import OpenAI

SERVER_SCRIPT = "leave_server.py"
MODEL = "gpt-4o-mini"
client = OpenAI()  # reads OPENAI_API_KEY from env

st.set_page_config(page_title="HR Leave Assistant", page_icon="🏖️")
st.title("🏖️ HR Leave Assistant — powered by MCP")

if "messages" not in st.session_state:
    st.session_state.messages = []

for msg in st.session_state.messages:
    with st.chat_message(msg["role"]):
        st.markdown(msg["content"])

async def chat_turn(user_text: str) -> str:
    # 1. Spawn the MCP server as a local child process (stdio transport)
    params = StdioServerParameters(command="python", args=[SERVER_SCRIPT])
    async with stdio_client(params) as (read, write):
        async with ClientSession(read, write) as session:
            await session.initialize()  # capability handshake

            # 2. Discover what tools the server exposes
            tools_result = await session.list_tools()
            openai_tools = [
                {
                    "type": "function",
                    "function": {
                        "name": t.name,
                        "description": t.description or "",
                        "parameters": t.inputSchema,
                    },
                }
                for t in tools_result.tools
            ]

            # 3. Agentic loop: model replies -> maybe calls tools -> repeat
            messages = st.session_state.messages + [
                {"role": "user", "content": user_text}
            ]

            for _ in range(5):  # safety cap on tool-call rounds
                response = client.chat.completions.create(
                    model=MODEL, messages=messages, tools=openai_tools,
                )
                choice = response.choices[0]

                if choice.finish_reason != "tool_calls":
                    return choice.message.content  # final answer, done

                messages.append(choice.message)

                # 4. Execute each requested tool on the MCP server
                for call in choice.message.tool_calls:
                    args = json.loads(call.function.arguments)
                    result = await session.call_tool(call.function.name, args)

                    with st.status(f"🔧 {call.function.name}({args})"):
                        st.write(result.content[0].text)

                    messages.append({
                        "role": "tool",
                        "tool_call_id": call.id,
                        "content": result.content[0].text,
                    })

            return "Too many tool calls — try a simpler request."

if user_text := st.chat_input("e.g. How much casual leave does Priya have?"):
    st.session_state.messages.append({"role": "user", "content": user_text})
    with st.chat_message("user"):
        st.markdown(user_text)
    with st.chat_message("assistant"):
        answer = asyncio.run(chat_turn(user_text))
        st.markdown(answer)
    st.session_state.messages.append({"role": "assistant", "content": answer})

Run it:

bash

streamlit run app.py

Type “Check Priya’s leave balance and apply for 2 days of casual leave.” and watch the st.status block light up with live tool calls. That loop — handshake, discover, call, respond — is MCP. Everything else in the ecosystem is this pattern scaled up.

Note: the stdio connection reopens per message here for simplicity. In production, keep one session alive instead.

Life After MCP: How Your Job Actually Changes

Before MCP, your calendar looked like this:

  • ~70% writing and maintaining glue code — API adapters, tool-description JSON, argument validation
  • Every new AI app = re-plumbing the same tools
  • Every new tool = touching every agent that might want it
  • Credentials drifting dangerously close to prompt text

After MCP:

  • Tools become products. You wrap a system once, and it plugs into any AI app — including ones you never anticipated.
  • Your focus shifts from plumbing to design. What should this tool do? What should it refuse to do? What does a good output look like? That’s the interesting engineering now.
  • Non-engineers self-serve. Analysts and PMs wire tools into Claude Desktop or Cursor themselves — the standard protocol means no code on their side.
  • Security gets cleaner by construction. Credentials live inside the server; the model never sees your keys. Even a prompt-injection attack can’t steal what was never in context. Hosts approve destructive tool calls — human-in-the-loop is the default, not an afterthought.
  • A shared ecosystem appears. Check the official MCP registry (registry.modelcontextprotocol.io) — like an app store for servers — before building anything for Postgres, GitHub, Slack, or Drive. There’s a good chance it already exists.

The honest headline: MCP doesn’t make your AI smarter. It makes your tooling boring — in the best possible way. Reusable, standardized, pluggable.

MCP vs Function Calling: When Do You Actually Need It?

The question interviewers care about most. Be direct with yourself:

Plain function calling is enough when: you have 2–5 tools in one codebase, everything sits behind one API you control, and you’re prototyping.

MCP starts paying off when: tools must be reusable across multiple agents, you’re connecting many external systems, a team shares tooling, or non-engineers need to wire tools without code.

Rule of thumb: switch around 5+ tools, or 2+ consuming applications. Below that it’s ceremony; above that it pays for itself in weeks.

stdio vs HTTP: Where Does Your Server Live?

  • stdio — host spawns your server as a local child process; stdin/stdout. For local tools. Simple, no networking, no auth.
  • Streamable HTTP — remote web service. The production choice: OAuth 2.0 support, concurrent clients, independent deployment.

stdio for your laptop, HTTP for your company. Production servers are best built as thin, mostly stateless interfaces over internal systems — an AI-facing layer over your data, not a new app tier.

MCP in Interviews: Questions to Be Ready For

MCP questions now show up in India alongside RAG and agents. Rehearse:

  1. “What is MCP and what problem does it solve?” → Standard protocol connecting AI apps to tools/data; kills the M×N glue-code explosion.
  2. “Tools vs resources vs prompts?” → Tools = model decides (verb); prompts = user decides (workflow); resources = app decides (context).
  3. “MCP vs function calling?” → Function calling is one agent’s private mechanism; MCP is a standardized, cross-application protocol with discovery, isolation, and reusability.
  4. “How does capability negotiation work?” → At initialization, client and server exchange protocol versions and capabilities; features work only if both sides support them.
  5. “How do you secure an MCP server?” → OAuth 2.0 for remote servers, credential abstraction, scoped permissions, audit logs, host approval for destructive tools.
  6. “stdio vs Streamable HTTP?” → Local child process vs remote service; stdio for dev tools, authenticated HTTP for production.

TL;DR

  • AI models are smart but disconnected — connecting them used to mean M×N custom integrations.
  • MCP is USB-C for AI tools: one standard protocol, everything plugs in. M×N collapses to M+N.
  • Three parts: host (the app), clients (one per server), servers (narrow capability providers).
  • Three primitives: tools (model decides), prompts (user decides), resources (app decides).
  • Life after MCP: less glue code, tools as reusable products, cleaner security, and boring plumbing — which is the goal.
  • Need it around 5+ tools or 2+ consuming applications; below that, function calling is fine.

Leave a Comment

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

Scroll to Top