All posts
AFFiNE
Toeverything·Published Aug 20, 2026
Three stacked layers — retrieval, a port, and code brackets — joined by connectors beside a spark

MCP vs API vs RAG: Which Layer Solves Your Problem?

MCP, APIs, and RAG are not competitors — they are three different layers: an API is a service's own interface for programmers, RAG is a retrieval technique inside one application's pipeline, and MCP is the open standard that lets any AI assistant discover and call tools across all of them. The confusion comes from all three showing up in the same sentence: "the assistant used MCP to call a search tool that runs RAG over documents fetched through an API." That sentence is not choosing between them; it is stacking them.

This guide gives each layer a precise job description, a decision path for which question you are actually asking, and the patterns where they combine — with one worked example you can try in minutes.

The one-table version

One table separates the three by job description — what each is, who consumes it, whether it can act, and what you end up maintaining:

APIMCPRAG
What it isA service's programmatic interfaceA standard interface layer for AI applicationsA retrieval technique in a generation pipeline
Who consumes itDevelopers writing codeAI assistants and agentsOne specific application
Unit of designEndpoints and payloadsTyped tools, resources, promptsChunks, embeddings, ranking
DiscoveryDocumentation read by humansCapability negotiation at connect timeNone — wired by the builder
Can it act (side effects)?Yes — whatever you code against itYes — tools can act, gated by client approvalNo — retrieval only
What you maintainGlue code per integrationServer choice, credentials, approvalsChunking, embeddings, re-indexing
Standardized byEach vendor separatelyThe Model Context Protocol specNot a standard; a pattern
Replaces the others?No — usually sits underneath MCPNo — usually wraps APIsNo — often served through MCP
Connected protocol, API interface, and retrieval layers with separate responsibilities in an AI application
MCP, APIs, and RAG solve different layers of the system and often work together rather than replacing one another.

What an API is (in this comparison)

An API is how a service exposes itself to software: endpoints, authentication, request and response shapes, documented for humans who write code. It is model-agnostic and assistant-agnostic — nothing about a REST endpoint knows or cares that a language model exists.

That is exactly why raw APIs fall short as an assistant interface. A model calling an arbitrary API needs hand-written glue for every service: what the endpoints are, how to authenticate, what the types mean, what errors look like. Multiply by every assistant and every tool and you get the N×M integration problem that motivated MCP in the first place.

Choose "just an API" when a human developer is building a fixed integration between known systems, no assistant in the loop. It remains the right default for software talking to software.

What MCP is (and is not)

The Model Context Protocol standardizes the layer between AI applications and tools. A server declares typed tools, resources, and prompts; any client — Claude, ChatGPT, Cursor, the rest — discovers those capabilities at connect time and lets the model call them safely. Tools are not read-only by definition: they can act — send, create, update — which is why compliant clients gate consequential calls behind human approval. One protocol on each side, every pairing works; the full mechanics are in our MCP server explainer.

Two boundaries keep the concept sharp:

  • MCP does not replace APIs. Most MCP servers are deliberate wrappers around existing APIs, re-expressed as model-callable tools with types and descriptions. The API stays; MCP standardizes how assistants consume it.
  • MCP is not "function calling with branding." Function calling is a model-side mechanism: the model emits a structured call, and your own code executes whatever you wired up, per application. MCP standardizes the other half — how tools are described, discovered, transported, and authorized across applications — so the same server works in every compliant client, no per-app wiring.

Choose MCP when the consumer is an assistant, and you want the integration to survive switching assistants. That portability is the entire point.

What RAG is (and where it lives)

Retrieval-augmented generation is a technique, not an interface: before generating, an application retrieves relevant material — typically via embeddings and semantic search over a corpus — and feeds it to the model as context. It answers one question extremely well: "how does this application ground its answers in these documents?" Note the boundary, because it decides architectures: RAG retrieves; it never acts. The moment a workflow needs to create the ticket rather than cite the runbook, you have left RAG's territory and entered tool calling.

RAG says nothing about how an external assistant reaches your corpus. The retrieval pipeline is private to whoever built it. That is not a flaw — it is scope. A support bot grounding answers in a help center needs RAG and may never need MCP.

Owning RAG also means owning a pipeline, not a feature: chunking strategy, embedding model, and — the part teams forget — re-indexing whenever the corpus changes. An index that drifts from its documents keeps answering fluently; the answers are just wrong. Budget for the maintenance, not only the build.

Choose RAG when you are building the application and need grounded answers over a corpus you control — and evaluate it by retrieval quality, not by interface elegance.

The decision path

The right layer falls out of which question is actually yours:

  1. "Two systems need to exchange data, no assistant involved" → API, full stop.
  2. "My application must answer from my documents" → RAG inside that application.
  3. "Any assistant my team uses should reach this tool or corpus" → MCP, wrapping whatever API or retrieval already exists.
  4. "My assistant should both search our knowledge and act on other tools" → MCP as the interface, RAG behind the search tool — the stack, not a choice.

How they combine in practice

The pattern that makes the debate moot: expose retrieval through the standard. AFFiNE's built-in MCP server is a concrete example — its search tool runs keyword plus semantic retrieval across a workspace's documents and whiteboard canvases, and returns bounded passages with locators. The retrieval layer is RAG-shaped; the interface is MCP; the storage underneath is reached through the product's own APIs. Connect once and every assistant you use inherits the same grounded search, instead of each app rebuilding its own pipeline. And because the server searches the live workspace, freshness ships with the product — there is no embedding pipeline for your team to re-run when documents change.

The same stacking shows up across the ecosystem: documentation servers front curated indexes, database servers front SQL, browser servers front a live engine. In every case the API did not go away and the retrieval did not go away — MCP made them reachable by any assistant.

FAQ

Is MCP just an API?

No. An API is one service's own interface, designed for developers; MCP is a cross-application standard that describes tools so models can discover and call them safely in any compliant client. Most MCP servers wrap existing APIs — the relationship is layering, not replacement.

Does MCP replace RAG?

No. RAG is how an application retrieves grounding material before generating; MCP is how assistants reach external tools at all. They combine naturally: an MCP server can expose a retrieval-backed search tool, which is exactly how AFFiNE serves workspace search to any connected assistant.

What is the difference between MCP and function calling?

Function calling is the model-side mechanism for emitting a structured call that your own application code executes — wired per app. MCP standardizes tool description, discovery, transport, and authorization across applications, so one server works in every compliant client without custom glue.

Can I use RAG with MCP?

Yes, and it is the recommended shape for shared knowledge: implement retrieval once, expose it as an MCP search tool, and every assistant gets the same grounded results. The alternative — each application building its own pipeline against your corpus — is the N×M problem RAG alone cannot solve.

When should I not use MCP?

When no assistant is in the loop (plain service-to-service integration), when a single application fully owns its retrieval and no external client needs access, or when latency-critical paths cannot afford an extra hop — and note that every connected server also spends context-window tokens on its tool definitions. MCP earns its layer when tools must serve many AI applications — that is the case it was designed for.

Do AI agents use RAG or MCP?

Typically both, in different roles: agent frameworks consume external capabilities through MCP because it standardizes discovery and authorization across tools, while the knowledge-lookup tools those agents call are often RAG pipelines behind the interface. The split is clean — retrieval grounds what the agent knows, tools define what it can do — so the practical question is not which one to adopt but which layer each requirement belongs to.


Pick by question, not by hype: API for software-to-software, RAG for grounding inside your app, MCP for making either reachable by every assistant you use. And if the corpus you want reachable is your team's documents and whiteboards, the standard-speaking server is already built.