> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Why We Need MCPs

> Beginner introduction to Model Context Protocols explaining how MCPs describe service APIs, prompts, and schemas to enable agents to discover, call tools, and orchestrate real world tasks.

Everyone's talking about MCPs — but what exactly are they?

This is a concise introduction to Model Context Protocols (MCPs) for absolute beginners. No prior knowledge required.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/nYh5ESbtPa0_kgi9/images/Crash-Course-MCP-For-Beginners/Model-Context-Protocol-MCP/Why-We-Need-MCPs/ai-agents-mcp-checklist-beginners.jpg?fit=max&auto=format&n=nYh5ESbtPa0_kgi9&q=85&s=511a365c79843649102ebe3d9b50ef0f" alt="A dark presentation slide showing a pink icon labeled &#x22;AI Agents&#x22; connected by a double-headed arrow to a white MCP logo. A left-side checklist notes features like &#x22;Crisp&#x22; and &#x22;For the Absolute Beginners&#x22; alongside crossed-out items such as &#x22;No-Nonsense&#x22; and &#x22;No-BS.&#x22;" width="1920" height="1080" data-path="images/Crash-Course-MCP-For-Beginners/Model-Context-Protocol-MCP/Why-We-Need-MCPs/ai-agents-mcp-checklist-beginners.jpg" />
</Frame>

In this article we'll cover:

* Why MCPs are needed
* What MCPs are
* The MCP architecture
* How to use an existing MCP server
* How to build a simple MCP server and client

Example MCP server response (JSON-RPC listing available prompts):

```json theme={null}
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "prompts": [
      {
        "name": "flight_search_instruction",
        "title": "Flight Search Instruction",
        "description": "Guides the LLM to behave as a flight assistant and use the searchFlights tool effectively.",
        "arguments": [
          {
            "name": "userRequest",
            "description": "The user's flight search request in natural language",
            "required": true
          }
        ]
      }
    ]
  },
  "nextCursor": null
}
```

You’ll also get links to hands-on labs, exercises, and resources to follow along with this lesson.

Now, let’s start by understanding why MCPs are needed.

Start with something familiar: ChatGPT. The basic flow is a request → response loop — you send a message to an LLM and it returns generated text (or other supported formats such as images or audio).

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/nYh5ESbtPa0_kgi9/images/Crash-Course-MCP-For-Beginners/Model-Context-Protocol-MCP/Why-We-Need-MCPs/chatgpt-llm-request-response-loop.jpg?fit=max&auto=format&n=nYh5ESbtPa0_kgi9&q=85&s=0324897f6a2d97e281066c8afda512d1" alt="A dark-themed diagram showing the ChatGPT chat interface on the left connected by green dashed arrows to a large &#x22;LLM (GPT)&#x22; label on the right. The arrows are labeled &#x22;request&#x22; and &#x22;response,&#x22; illustrating the request-response loop." width="1920" height="1080" data-path="images/Crash-Course-MCP-For-Beginners/Model-Context-Protocol-MCP/Why-We-Need-MCPs/chatgpt-llm-request-response-loop.jpg" />
</Frame>

Why this isn’t enough for real-world automation

* LLMs are excellent at reasoning, summarizing, and extracting structure from text.
* LLMs cannot directly call third-party APIs, maintain durable state, or perform actions on external systems by themselves.
* For practical applications (e.g., “Book a flight to New London”), you need components that can call APIs, fetch and store preferences, and execute transactions.

This is where AI agents and tools fit in.

What are AI agents and tools?

* AI agents are software components that orchestrate actions: they call LLMs to interpret intent, choose steps, interact with tools/APIs, and iterate until a goal is reached.
* Tools are adapters or connectors that translate the agent’s requests into service-specific API calls (normalizing different vendor APIs into a consistent schema).

High-level agent process (example: flight booking)

1. User sends a natural-language request.
2. Agent calls the LLM to extract structured details (origin, destination, dates).
3. Agent decides which third-party tools/APIs to call (often with LLM assistance).
4. Agent calls those APIs (airlines, hotels, cars).
5. Agent retrieves user preferences from memory or DB.
6. Agent asks the LLM to evaluate options and choose.
7. Agent performs booking and returns results to the user.

At many steps the agent consults the LLM to parse input, pick tools, and decide whether the goal is complete.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/nYh5ESbtPa0_kgi9/images/Crash-Course-MCP-For-Beginners/Model-Context-Protocol-MCP/Why-We-Need-MCPs/llm-gpt-process-flow-scripts-integrations.jpg?fit=max&auto=format&n=nYh5ESbtPa0_kgi9&q=85&s=8a7328a968907e357de4013d2508f2e7" alt="A colorful flowchart titled &#x22;LLM (GPT)&#x22; showing a process flow with labeled boxes like &#x22;Process Input&#x22; and many &#x22;Script&#x22; nodes, decision diamonds (&#x22;If&#x22;, &#x22;Which&#x22;, &#x22;Loop&#x22;), and branches out to several &#x22;Third Party&#x22; endpoints. It maps conditional steps and external integrations for handling inputs." width="1920" height="1080" data-path="images/Crash-Course-MCP-For-Beginners/Model-Context-Protocol-MCP/Why-We-Need-MCPs/llm-gpt-process-flow-scripts-integrations.jpg" />
</Frame>

Example: LLM helps pick a flight

* The LLM can be asked to choose between candidate flights (e.g., "Pick JA123 based on user preference: cheap, aisle seat").
* The agent enforces booking once the LLM chooses an option.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/nYh5ESbtPa0_kgi9/images/Crash-Course-MCP-For-Beginners/Model-Context-Protocol-MCP/Why-We-Need-MCPs/llm-agent-chooses-ja123-flight.jpg?fit=max&auto=format&n=nYh5ESbtPa0_kgi9&q=85&s=ae4475c2ca3270d40a1dc63d47ece7d7" alt="A dark infographic showing an LLM (GPT) helping an agent choose flights, with a table of options (JA123, DR345, AR332) and the recommendation &#x22;It's JA123!&#x22;. Airline logos (Joyair, DracAir, AeroGo) and user preferences are also shown." width="1920" height="1080" data-path="images/Crash-Course-MCP-For-Beginners/Model-Context-Protocol-MCP/Why-We-Need-MCPs/llm-agent-chooses-ja123-flight.jpg" />
</Frame>

Consolidated pseudocode: a simplified agent orchestration

<Callout icon="lightbulb" color="#1CB2FE">
  The code below is illustrative pseudocode. It omits production concerns (authentication, retries, error handling, streaming responses, secret management). Treat it as conceptual guidance, not a drop-in implementation.
</Callout>

```python theme={null}
def call_llm(prompt):
    # Placeholder for an LLM call that returns structured data
    # e.g., returns {"origin": "NYC", "destination": "LON", "date": "2026-10-10"}
    pass

def call_api(url, params):
    # Placeholder for performing an HTTP request to a third-party API
    # Returns a parsed JSON response
    pass

def call_tool(tool_name, args):
    # Tool adapters normalize different airline APIs into a common flight schema
    if tool_name == "joyair_tool":
        response = call_api("https://www.joyair.com/api/flights", args)
        return [
            {
                "flightNumber": flight["flightNumber"],
                "origin": flight["origin"],
                "destination": flight["destination"],
                "price": flight.get("price")
            } for flight in response["flights"]
        ]

    elif tool_name == "dracair_tool":
        response = call_api("https://www.dracair.com/api/flights-list", args)
        return [
            {
                "flightNumber": flight["flightNum"],
                "origin": flight["from"],
                "destination": flight["to"],
                "price": flight.get("fare")
            } for flight in response["flight-info"]
        ]

    elif tool_name == "aerogo_tool":
        response = call_api("https://www.aerogo.com/api/list-flights", args)
        return [
            {
                "flightNumber": flight["flight"],
                "origin": flight["start"],
                "destination": flight["finish"],
                "price": flight.get("cost")
            } for flight in response["detail-flights"]
        ]

    else:
        raise ValueError("Unknown tool: " + tool_name)

def fetch_flight_details(origin, destination, date):
    # Aggregate results from multiple airline tools
    flights = []

    joyair_result = call_tool("joyair_tool", {"origin": origin, "destination": destination, "date": date})
    flights.extend(joyair_result)

    dracair_result = call_tool("dracair_tool", {"origin": origin, "destination": destination, "date": date})
    flights.extend(dracair_result)

    aerogo_result = call_tool("aerogo_tool", {"origin": origin, "destination": destination, "date": date})
    flights.extend(aerogo_result)

    return flights

def fetch_user_preferences(user_id):
    # Placeholder for DB/memory fetch
    return {"preference": "cheap", "seat": "aisle"}

def book_flight(flight):
    # Placeholder for booking API call
    return f"Flight {flight['flightNumber']} booking confirmed!"

# Main flow
user_input = input("Where do you want to fly?\n")

# Ask LLM to extract origin, destination, date
prompt = [
    {"role": "system", "content": "Extract origin, destination, and date from the user request."},
    {"role": "user", "content": user_input}
]
flight_query = call_llm(prompt)  # e.g., {"origin": "NYC", "destination": "LON", "date": "2026-10-10"}

origin = flight_query.get("origin")
destination = flight_query.get("destination")
date = flight_query.get("date")

flight_options = fetch_flight_details(origin, destination, date)
user_prefs = fetch_user_preferences(user_id="user-123")

# Ask LLM to pick the best flight given user preferences
decision_prompt = [
    {"role": "system", "content": f"User preferences: {user_prefs}"},
    {"role": "user", "content": f"Available flights: {flight_options}"}
]
decision = call_llm(decision_prompt)  # e.g., returns chosen flight identifier or flight dict

# Book the chosen flight (mock)
chosen = decision.get("chosen_flight") if isinstance(decision, dict) else flight_options[0]
print(book_flight(chosen))
```

Frameworks and tools that help build these agent workflows include LangChain, LangGraph, and many emerging libraries. See:

* LangChain: [https://learn.kodekloud.com/user/courses/langchain](https://learn.kodekloud.com/user/courses/langchain)
* LangGraph: [https://learn.kodekloud.com/user/courses/langgraph](https://learn.kodekloud.com/user/courses/langgraph)

What exactly are MCPs?

* MCP (Model Context Protocol) is a protocol/specification that describes how a service exposes:
  * Which APIs and integrations are available
  * API endpoints, parameters, and authentication
  * Response schemas and example payloads
  * Prompts and helper instructions the model should use

MCPs make tool discovery and usage easier for agents by providing a standardized, machine-readable description of a service’s capabilities. Instead of hard-coding dozens of vendor APIs, agents query an MCP server to discover integrations, prompts, and schemas at runtime.

What MCPs provide (quick reference)

| Capability | Purpose | Example |
| - | - | - |
| Discovery | Find available integrations for a service | `GET /prompts`, `GET /tools` |
| Schemas | Describe request/response shapes for tools | JSON schemas, sample payloads |
| Usage guidance | Provide LLM prompts and examples for interacting with the tool | `flight_search_instruction` prompt |
| Auth & Endpoints | Explain how to call APIs (endpoints, headers, auth flow) | OAuth or API key instructions |

How MCP client-server architecture works

* MCP Server: hosted by a service owner or community contributor; publishes tools, prompts, schemas, and examples.
* MCP Client: embedded in agents, IDE assistants, or developer tools; queries the MCP server to discover how to call a service and which prompts to use.
* Agents combine MCP metadata with LLM outputs to choose and call the right tool adapter.

Real-world use cases

* Frontend development: an MCP server can expose browser console logs, DOM structure, and runtime context so an agent can diagnose UI issues and suggest fixes quickly.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/nYh5ESbtPa0_kgi9/images/Crash-Course-MCP-For-Beginners/Model-Context-Protocol-MCP/Why-We-Need-MCPs/frontend-agent-apis-mcp-browser.jpg?fit=max&auto=format&n=nYh5ESbtPa0_kgi9&q=85&s=9504d04d95d5739fb4749fc84e8ac374" alt="A presentation slide titled &#x22;Use Cases – Frontend Development&#x22; showing a pink &#x22;Agent&#x22; avatar on the left. Dotted green arrows lead from the agent to boxes labeled &#x22;Develop Frontend APIs&#x22; and &#x22;MCP Server Browser&#x22; and onward to an orange app icon." width="1920" height="1080" data-path="images/Crash-Course-MCP-For-Beginners/Model-Context-Protocol-MCP/Why-We-Need-MCPs/frontend-agent-apis-mcp-browser.jpg" />
</Frame>

* Data engineering: read-only MCP access to SQLite, BigQuery, or dbt Studio lets agents combine datasets, reason about missing data, and surface root causes.

Who builds MCP servers?

* Anyone who owns a service can publish an MCP server for that service.
* Vendors are publishing official MCP servers for their platforms; community contributors publish unofficial integrations.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/nYh5ESbtPa0_kgi9/images/Crash-Course-MCP-For-Beginners/Model-Context-Protocol-MCP/Why-We-Need-MCPs/community-servers-readme-mcp-list.jpg?fit=max&auto=format&n=nYh5ESbtPa0_kgi9&q=85&s=ae20eae51beb9528400d8888a6de214e" alt="Screenshot of a &#x22;Community Servers&#x22; README page showing a bulleted list of MCP server projects and links (e.g., 1Panel, A2A, Ableton Live, Ahrefs). The page has a globe icon header and a GitHub URL at the bottom." width="1920" height="1080" data-path="images/Crash-Course-MCP-For-Beginners/Model-Context-Protocol-MCP/Why-We-Need-MCPs/community-servers-readme-mcp-list.jpg" />
</Frame>

<Callout icon="warning" color="#FF6B6B">
  Community MCP servers can be extremely helpful for prototyping, but treat untrusted servers with caution. Verify sources, inspect schemas and endpoints before calling production systems, and never send secrets to an untrusted MCP server.
</Callout>

Summary

* MCPs provide a structured, discoverable layer that tells agents how to interact with services, tools, and APIs.
* By combining MCP metadata with LLM reasoning, agents can discover integrations at runtime, normalize vendor APIs, and safely orchestrate complex workflows (booking, debugging, data exploration).
* Next: we’ll dive into the MCP specification, architecture details, and step-by-step examples for using and building simple MCP servers and clients.

Before moving on, make sure you’re comfortable with the agent workflow described above — it’s the foundation for understanding MCP-driven integrations.

<CardGroup>
  <Card title="Watch Video" icon="video" cta="Learn more" href="https://learn.kodekloud.com/user/courses/crash-course-mcp-for-beginners/module/f1e44479-23c8-46ec-b1b9-d9e90146921b/lesson/f3d8fb73-35af-4c8b-83a9-ea157256f5b1" />
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.