Model Context Protocol

Showing posts with label Model Context Protocol. Show all posts
Showing posts with label Model Context Protocol. Show all posts

Saturday, July 25, 2026

MCP vs RAG vs AI Agents: They Don't Compete


Every week someone asks me to settle the debate: should we use RAG, build an agent, or “just do MCP”? The question sounds reasonable. It has the shape of a real architecture decision. It is also the wrong question, and picking one of the three because you think you have to is how teams end up with an agent that should have been a SQL query, or a RAG pipeline that still hallucinates.

These three things are not competitors. RAG is a knowledge pattern, MCP is a connection protocol, and an agent is a control loop — they sit at different layers, and most production systems use all three at once.

MCP vs RAG vs AI Agents — CodezTech
MCP vs RAG vs AI Agents — three layers, not three choices.

The below topics are covered in this blog -
1. Why the “vs” framing is a category error
2. RAG — retrieval, not reasoning
3. MCP — the connector, not the brain
4. AI Agents — the loop that decides
5. Putting it together: where each layer lives
6. A comparison across the dimensions that actually matter
7. Common mistakes
8. The Takeaway

1. Why the “vs” framing is a category error

Ask “MCP or RAG or agent?” and you are comparing a protocol, a data pattern, and an execution model as if they were three brands of the same thing. They are not interchangeable, and none of them can be swapped in for another.

Here is the clean split. RAG answers the question “how does the model get the right knowledge at inference time?” MCP answers “how does the model reach a tool or system in a standardized way?” An agent answers “who decides what to do next, and how many steps does it take?” Different questions. You can answer all three in the same system, and in anything non-trivial you will.

A concrete example. A support assistant retrieves policy docs (RAG), calls your order system and Slack through standardized servers (MCP), and runs a loop that decides whether to answer, escalate, or issue a refund (agent). Take any one layer out and it is a different, weaker system — not a cheaper version of the same one.

2. RAG — retrieval, not reasoning

Retrieval-Augmented Generation is the oldest and least glamorous of the three, and it is still the highest-leverage thing most teams can ship. You embed your documents, store the vectors, and at query time you fetch the most relevant chunks and stuff them into the prompt before the model answers. That is the whole trick.

What RAG buys you: current, private, and citable knowledge without retraining a model. What it does not buy you: correctness. RAG grounds the answer in retrieved text; it does not verify that the retrieved text is relevant, complete, or being read correctly. Bad retrieval produces confident wrong answers — now with footnotes, which makes them harder to catch.

query
  -> embed(query)                      # same model as your index
  -> vector_store.search(k=8)          # over-fetch, then filter
  -> rerank(candidates) -> top 3-4     # rerank is where quality lives
  -> build_prompt(context, question)
  -> llm.generate()                    # answer is only as good as top 3-4

Ninety percent of “our RAG is bad” problems are retrieval problems, not model problems: wrong chunk size, no reranker, a query embedded with a different model than the index, or a knowledge base that was never cleaned. Fix retrieval before you touch the prompt.

3. MCP — the connector, not the brain

The Model Context Protocol is an open standard that Anthropic introduced in November 2024 and open-sourced. It standardizes how an AI application connects to external tools and data — the same role USB-C plays for devices. Instead of writing a bespoke integration for every model-to-tool pair, you expose a tool once through an MCP server and any MCP-capable client can use it.

It stopped being a single-vendor idea fast. OpenAI adopted it in March 2025 across its Agents SDK and ChatGPT; Google DeepMind followed for Gemini in April 2025; Microsoft wired it into Copilot Studio and Windows. In December 2025 Anthropic donated MCP to the Agentic AI Foundation under the Linux Foundation, moving it to vendor-neutral governance.

Version detail matters here because I am publishing this under my name. The current finalized spec is the 2025-11-25 revision. A much larger revision, dated 2026-07-28, has been in release-candidate form since May 2026 and is scheduled to publish on July 28, 2026 — days from this writing. It is the biggest change since launch: a stateless protocol core (the initialize handshake and protocol-level session are gone), an extensions framework, Tasks moved out of core into an extension, server-rendered UIs via MCP Apps, tighter OAuth/OIDC-aligned authorization, and a formal deprecation policy with a twelve-month minimum window. Parts are not backward compatible — new-revision servers may not talk to old clients. If you are deploying now, check which revision your SDK and clients target before you commit.

What has stayed stable across revisions is the shape of a tool definition, which is the part you actually author:

{
  "name": "refund_order",
  "description": "Issue a refund for an order. Use only after policy check.",
  "inputSchema": {
    "type": "object",
    "properties": {
      "order_id": { "type": "string" },
      "amount":   { "type": "number" },
      "reason":   { "type": "string" }
    },
    "required": ["order_id", "amount"]
  }
}

Note what MCP is not. It does not decide when to call the tool — that is the model or the agent. It does not remove authentication, rate limits, or the blast radius of a tool that can write to production. The spec itself flags that tools are arbitrary code execution and must be treated with caution. MCP standardizes the wire; it does not standardize away the risk.

4. AI Agents — the loop that decides

An agent is not a model and it is not a tool. It is a control loop wrapped around a model: observe the current state, decide the next action, take it, observe the result, repeat until done or stuck. The autonomy lives in that loop — the model chooses which tool to call and when to stop, instead of you hard-coding the sequence.

state = initial(task)
for step in range(MAX_STEPS):          # always cap the loop
    action = model.decide(state, tools)  # which tool, or "finish"
    if action.is_final:
        return action.answer
    result = run(action)               # tool call, often over MCP
    state = state.update(result)       # memory / observation
raise StepLimitExceeded                # failure is a real branch

That loop is powerful and expensive. Every iteration is another model call, so latency and cost scale with the number of steps, and the path is non-deterministic by design. That is the whole point when the task genuinely cannot be predetermined — and pure overhead when it can. The two failure modes to design against: the loop that never converges (cap the steps) and the wrong-tool cascade (scope the tool set).

5. Putting it together: where each layer lives

Stack them and the roles stop overlapping. Retrieval feeds knowledge into the model. MCP is the standardized pipe the model reaches through to touch systems. The agent loop sits on top and decides which of those moves to make, in what order. The diagram below lays all three out side by side — read it as three layers of one system, not three options on a menu.

MCP vs RAG vs AI Agents architecture comparison
How MCP, RAG, and AI Agents map onto a real system. Infographic credit: ByteByteGo.

The decision order that keeps costs sane: start with the cheapest thing that solves the problem. Need current knowledge? Add retrieval. Need to touch a system? Expose it as a tool, and use MCP if more than one client will consume it. Is the path fixed? Write a deterministic pipeline. Only when the control flow is genuinely dynamic — the next step depends on the last result in ways you cannot enumerate — do you hand the wheel to an agent loop.

6. A comparison across the dimensions that actually matter

Dimension RAG MCP AI Agent
What it actually isA knowledge-injection patternAn open tool-connection protocolA model-driven control loop
Problem it solvesModel lacks current or private knowledgeEvery tool needs a custom integrationThe path can’t be predetermined
Where it sitsBetween query and promptBetween model and external systemsAbove the model, orchestrating
Latency addedOne retrieval hop (tens of ms)One protocol round-trip per callN model calls (grows per step)
Main cost driverEmbedding + vector storage + context tokensNegligible protocol overheadModel calls multiplied by step count
Dominant failure modeBad retrieval → confident wrong answersOver-broad tool permissionsLoops that don’t converge; wrong-tool cascades
Security surfaceData leakage via retrieved contextTools are code execution — trust boundaryAutonomous actions with real side effects
StateStateless per queryStateless core in the 2026-07-28 revisionStateful across the loop (memory)
When it’s overkillKnowledge fits in the prompt alreadyOne model, one tool, one codebaseThe steps are fixed and known
Maturity (Jul 2026)Mature, well-understoodStandardized, mid-migration to 2026-07-28Production-viable but operationally young

7. Common mistakes

  1. “We’ll add RAG so the model stops hallucinating.” RAG grounds answers; it does not fact-check them. Retrieve the wrong chunk and you get the same hallucination with a citation stapled to it, which is worse because it looks trustworthy. Invest in retrieval quality and reranking, not just the presence of a vector database.
  2. “MCP replaces our API integrations.” MCP sits in front of the same APIs. It standardizes how the model reaches them, but the auth, rate limits, idempotency, and blast radius of a write-capable tool are all still your problem. You are moving the wiring, not deleting it.
  3. “Just make it an agent.” Reaching for an autonomous loop when a deterministic pipeline would do is the most expensive default in this space. Agents add latency, token cost, and non-determinism. If you can draw the flowchart, code the flowchart.
  4. “One big agent with forty tools.” Tool-selection accuracy degrades as the tool count climbs — the model starts picking plausible-but-wrong tools. Scope each agent to a narrow tool set, or route between several focused agents instead of one overloaded one.
  5. “It’s MCP, so security already reviewed it.” The spec itself states that tools represent arbitrary code execution and data access. A standardized protocol does not make an untrusted server safe. Treat every MCP server as a trust boundary and review what each tool can actually do.

8. The Takeaway

Stop shopping for one of the three. Pick by layer. Use retrieval when the model needs knowledge it doesn’t have. Use MCP when you need standardized, reusable access to tools across more than one client. Use an agent only when the control flow is genuinely dynamic and you have capped the loop and scoped the tools.

The unglamorous truth is that most strong production systems are all three at once: RAG for grounding, MCP for tool access, and a narrowly-scoped agent loop on top — with the cheapest layer doing as much of the work as it can before you spend a model call on the next one.

About the Author
Atique Ahmed — Principal AI Architect. 7x Microsoft MVP and Guinness World Record holder for Programming Excellence. Founder of Codez Tech.
atiqueahmed.com · LinkedIn · GitHub

This is Day [DAY_NUMBER] of a daily GenAI and agentic AI series on CodezTech.

Friday, July 24, 2026

MCP vs RAG vs Skills : Complete Guide to AI Agent Architecture


MCP vs RAG vs Skills : Complete Guide to AI Agent Architecture

Everyone building AI agents in 2026 runs into the same three words within the first week — MCP, RAG, and Skills — and almost everyone assumes they have to pick one. They don't. These are three different layers of the same stack, and picking the wrong one is the single most expensive architecture mistake I see on enterprise engagements.

In one line: RAG gives an agent knowledge. MCP gives it access. Skills give it judgment.

MCP vs RAG vs Skills - AI agent architecture guide by Codez Tech

4. MCP vs RAG vs Skills — Full Comparison

MCP vs RAG vs Skills architecture comparison diagram for AI agents
MCP vs RAG vs Skills — Architectures that power smarter AI agents

The below topics are covered in this blog -

1) What is MCP (Model Context Protocol)?
2) What is RAG (Retrieval Augmented Generation)?
3) What are Agent Skills?
4) MCP vs RAG vs Skills — full comparison table
5) When to use MCP vs RAG vs Skills — the decision rule
6) How the three layers compose in a real agent
7) Building your first Skill — SKILL.md example
8) Common architecture mistakes and how to avoid them

1. What is MCP (Model Context Protocol)?

MCP is an open, JSON-RPC based client-server protocol that lets an AI agent talk to live external systems — a database, a CRM, a ticketing system, Slack, a search API — through one standardized interface. It was created by Anthropic in late 2024 and later donated to the Agentic AI Foundation under the Linux Foundation, and it is now supported across all the major model vendors.

The architecture has three parts:

  • MCP Host — the application the user is talking to (Claude Desktop, your own agent app, an IDE).
  • MCP Client — lives inside the host, maintains one connection per server, and decides which server to route a request to.
  • MCP Server — the service that actually exposes capabilities. It publishes three primitives: Tools (actions the agent can invoke), Resources (data the agent can read), and Prompts (reusable templates).

The important word here is live. An MCP server holds real authentication, real session state, and returns data as it exists right now. That is why order status, inventory counts, and open incidents belong behind MCP and nowhere else.

A minimal MCP server configuration looks like this:

{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-postgres",
               "postgresql://localhost/orders"]
    },
    "slack": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-slack"],
      "env": { "SLACK_BOT_TOKEN": "xoxb-your-token" }
    }
  }
}

That is it. The agent now has live, authenticated access to two systems it had no idea existed thirty seconds ago.

2. What is RAG (Retrieval Augmented Generation)?

RAG solves a completely different problem: the model was never trained on your documents. Your policy manuals, product specs, past support tickets, and internal wikis are invisible to it.

The pipeline has two phases.

Indexing (offline, runs once and then on a schedule):

  1. Load the source documents.
  2. Chunk them into passages — typically 300 to 800 tokens with some overlap.
  3. Embed each chunk into a vector using an embedding model.
  4. Store the vectors in a vector database (pgvector, Pinecone, OpenSearch, Weaviate, Chroma).

Retrieval (online, runs on every query):

  1. Embed the user's query with the same model.
  2. Search for the nearest chunks — ideally hybrid, combining vector similarity with keyword BM25.
  3. Rerank the candidates with a cross-encoder to push the genuinely relevant ones to the top.
  4. Augment the prompt with those chunks and generate an answer with citations.

The thing to internalise: a vector index is a photograph, not a window. It is as fresh as your last indexing run and no fresher. If the answer must reflect the world right now, RAG is the wrong tool.

3. What are Agent Skills?

A Skill is the least glamorous and most underrated of the three. It is a folder. Inside it sits a SKILL.md file with YAML frontmatter and a set of instructions, plus optional scripts, templates, and reference documents.

The mechanism that makes it clever is progressive disclosure. The agent only ever holds the skill's name and description in context — a few dozen tokens. When a task matches that description, the full skill body loads on demand. Near-zero context cost until it fires.

---
name: incident-report
description: Writes a post-incident report. Use whenever the user asks
  for an RCA, incident summary, outage write-up, or postmortem.
---

# Incident Report Skill

## Required sections, in order
1. Impact summary (who was affected, for how long, revenue impact)
2. Timeline in UTC, one line per event
3. Root cause - the technical cause, not the human who typed it
4. Detection gap - why did we not know sooner
5. Action items, each with an owner and a date

## Rules
- Never name individuals. Name teams and systems.
- Severity uses our P0-P4 scale, defined in ./reference/severity.md
- Use the template in ./templates/incident.md
- If the timeline has gaps, ask before writing. Do not guess.

That file is roughly thirty lines. It is version controlled in Git, reviewable in a pull request, portable across agent runtimes, and it costs you nothing until the moment somebody says the word "postmortem." Now compare that to embedding your incident-management handbook into a vector store and praying the right paragraph gets retrieved.

4. MCP vs RAG vs Skills — Full Comparison

DimensionRAGMCPSkills
Core problemMissing knowledgeMissing accessMissing procedure
NatureRetrieval pipelineLive protocol, running serverStatic portable folder
Data freshnessAs fresh as the last index runReal time, every single callStable for weeks or months
State & authNoneYes — sessions, tokens, scopesNone
Can take actions?No, read onlyYesOnly through tools it invokes
Context costHigh — chunks fill the windowMedium — tool schemas occupy contextVery low until triggered
InfrastructureEmbedding model + vector DB + pipelineA deployed, monitored server processA file in a repo
Cost driverEmbedding + storage + retrieved tokensServer hosting + API callsEffectively zero
Latency addedRetrieval + rerank, typically 100–500msNetwork round trip per tool callNegligible
Change costRe-chunk and re-index everythingVersion the server, redeployEdit the markdown, commit
Fails whenChunking is poor, retrieval missesServer is down, token expired, tool sprawlDescription doesn't match the task
GovernanceIndex-level ACLs, hard to get rightStrong — real auth, scopes, audit logsWeak — it's just a file, use Git review

5. When to Use MCP vs RAG vs Skills

Ask these three questions in this exact order about whatever capability you are trying to add:

Question 1 — Does it change between invocations?
If the answer must reflect the world right now — an order status, a live inventory count, an open incident, a current account balance — you need MCP. Nothing else will do. A vector index cannot tell you whether a server is on fire at this moment.

Question 2 — Is it a large, slow-moving body of text the model was never trained on?
Policy documents, product manuals, three years of resolved tickets, research archives. That is RAG. The test is volume plus stability: too big to paste into a prompt, stable enough that a nightly index run is acceptable.

Question 3 — Is it procedure, judgment, formatting, or house style?
"How we write an incident report." "Our SQL naming conventions." "The seven checks before a deployment note ships." That is a Skill — and it is almost always the cheapest thing you have not tried yet.

6. How the Three Layers Compose in a Real Agent

In production this is never a choice. It is a stack. Take a customer support agent for an e-commerce company:

  • MCP layer — connects to the order database and the ticketing system. Live account state, live order status, and the ability to actually issue a refund or update a record.
  • RAG layer — retrieves from product documentation and the archive of resolved tickets. The slow-moving institutional knowledge.
  • Skills layer — encodes the escalation policy. What counts as a P1. The tone for a refund message. Which fields must be filled before a ticket can close. The exact template for the customer summary.

Now remove one layer at a time and watch the failure mode appear:

  • No MCP → the agent confidently hallucinates order status. Customer is told their package shipped. It did not.
  • No RAG → the agent invents product behaviour that does not exist and creates a support ticket about its own answer.
  • No Skills → the agent does technically correct things in a wildly inconsistent way. Every refund email has a different tone. No two tickets close the same. Nothing is auditable.

That third one is the sneaky failure, because nothing visibly breaks. It just quietly becomes unreviewable.

7. Building Your First Skill

Skills are the fastest win, so start there. The folder structure is:

.claude/skills/
  incident-report/
    SKILL.md              # required: frontmatter + instructions
    reference/
      severity.md         # loaded only when SKILL.md points to it
    templates/
      incident.md
    scripts/
      fetch_timeline.py   # optional executable helper

Three rules that decide whether your skill actually works:

  1. The description is the entire trigger mechanism. It is the only part the agent sees until the skill fires. Write it as "Use when the user asks for X, Y, or Z" — concrete trigger phrases, not an abstract summary. A vague description means the skill never loads, and you will spend an afternoon debugging a prompt when the actual bug was one sentence of metadata.
  2. Keep SKILL.md under roughly 500 lines. Push detail into reference files and link to them. That is what progressive disclosure is for.
  3. Write imperatives, not descriptions. "Never name individuals" beats "this report generally avoids naming individuals."

8. Common Architecture Mistakes

Mistake 1 — Reaching for RAG when you needed a Skill. Somebody wants consistent output, so they index the style guide, embed it, retrieve fragments, and hope the right paragraph surfaces. A single skill file would have made it deterministic, free, and reviewable in a pull request. This is the most common one by a distance.

Mistake 2 — Building an MCP server for data that changes once a quarter. That is a maintenance burden wearing an integration costume. Index it or put it in a reference file.

Mistake 3 — Tool sprawl. Connect twelve MCP servers and their tool schemas start eating your context window before the user has typed a single character — and the model gets measurably worse at choosing the right tool. On-demand tool loading has taken the edge off this, but the architectural pressure remains. Curate your tool surface the way you would curate a public API. Fewer tools with better descriptions beat a directory of everything.

Mistake 4 — Believing long context killed RAG. Long context solves small corpora. It does not solve a 40 GB document store, and it does not solve paying for a million input tokens on every single request. RAG is a cost and precision strategy, not just a capability one.

Mistake 5 — Believing Skills replaced MCP. A skill has no auth, no session, and no connection. It cannot fetch anything on its own. What it can do is tell the agent how and when to use the MCP tools that are already wired up. They compose; they do not compete.

9. The Takeaway

Stop asking which one wins. Ask which question you are answering:

  • Knowledge the model lacks → RAG
  • Systems the model must reach → MCP
  • Procedure the model must follow → Skills

And when a capability is genuinely both a system and a way of using that system — which describes most real engineering work — build a small MCP server for the access and a Skill for the workflow that drives it.

The teams shipping reliable agents right now are not the ones who picked the trendiest primitive. They are the ones who matched the primitive to the problem.


About the Author
Atique Ahmed — Principal AI Architect. 7x Microsoft MVP and Guinness World Record holder for Programming Excellence. Founder of Codez Tech.
Portfolio  |  LinkedIn  |  GitHub

This is Day 1 of a daily GenAI and agentic AI series on CodezTech. Tomorrow: the next topic.