Back to blog

Text In, Text Out: Demystifying AI agents, MCP, and RAG

AI agents MCP RAG

If you’ve been paying attention to AI lately, you’ve probably heard terms like “agents,” “MCP,” and “RAG” thrown around. Sometimes it feels like the industry invents new acronyms just to make things sound more complicated than they are.

Let me break these down in plain terms.

The foundation: Text in, text out

Before we get into the fancy stuff, let’s ground ourselves. Large language models (LLMs) like GPT-4 or Claude are, at their core, text prediction machines. You give them text, they give you text back. That’s it.

Everything else—agents, RAG, tool use—is just clever ways of:

  1. Deciding what text to send to the model
  2. Doing something useful with the text that comes back

Keep that mental model. It’ll save you from a lot of hype-induced confusion.

Agents: Models that can take action

An “agent” is an LLM that can do more than just respond to a single prompt. It can:

  • Break down a complex task into steps
  • Decide which tools or actions to use
  • Execute those actions
  • Use the results to inform next steps

Think of it like the difference between asking someone a question and asking them to complete a project. The question gets one response. The project might involve research, drafts, revisions, and decisions along the way.

Under the hood, agents are still just text-in, text-out. The magic is in the loop: the model outputs text that says “I need to search for X,” your code executes that search, and then you send the results back to the model as more text.

RAG: Giving the model context it doesn’t have

Retrieval-Augmented Generation sounds fancy, but it’s straightforward. LLMs have a knowledge cutoff—they don’t know about things that happened after they were trained, and they don’t know about your specific documents, codebase, or business data.

RAG solves this by:

  1. Taking a user’s question
  2. Searching your documents/data for relevant information
  3. Including that information in the prompt to the model
  4. Having the model answer using that context

That’s it. You’re just stuffing relevant text into the prompt before the model sees it.

The hard parts are:

  • Chunking: How do you break up documents into searchable pieces?
  • Embedding: How do you convert text into vectors for similarity search?
  • Retrieval: How do you find the right chunks for a given question?

But conceptually? It’s just “find relevant text, add it to the prompt.”

MCP: A protocol for tool use

Model Context Protocol (MCP) is Anthropic’s open protocol for connecting LLMs to external tools and data sources. If you’ve used function calling or tool use with any LLM, you’re already familiar with the concept.

MCP standardizes how:

  • Tools describe themselves to the model
  • The model requests tool execution
  • Results get passed back to the model

Why does this matter? Without a standard, every AI tool integration is custom. With MCP, you build a connector once and it works with any MCP-compatible system.

For developers, this means:

  • Less boilerplate for each integration
  • Reusable tool servers
  • Cleaner architecture for complex AI applications

Putting it together

In practice, modern AI applications often combine all three:

  1. Agent loop: The model decides what to do step by step
  2. RAG: Relevant documents are retrieved and included in context
  3. MCP/Tools: The model can search the web, query databases, or call APIs

But remember—strip away the complexity and it’s still text in, text out. The model reads text. It writes text. Everything else is infrastructure to make that text more useful.

Why this matters

Understanding these concepts at a practical level helps you:

  • Cut through vendor hype: When someone says “AI agent,” you know it’s just an LLM in a loop
  • Design better systems: You can make informed choices about when to use RAG vs. fine-tuning, or when an agent is overkill
  • Debug effectively: When something breaks, you can trace it back to what text went in and what text came out

The AI landscape moves fast, but the fundamentals are simpler than the marketing suggests. Master the basics, and the new stuff becomes much easier to evaluate.

Read More

Explore more thoughts on AI, architecture, and shipping software.

View all posts