OwlTheEngineer
AI Explained VisuallyEpisode 64 · AI

5 AI Protocols — One Progression: Prompt → Tool Call → RAG → MCP → A2A (Architecture Cheat Sheet)

The complete 5-level AI engineering progression: how each protocol solves the exact bottleneck of the one before it, with JSON schemas, pgvector SQL, MCP config, A2A Agent Cards, and a 1-page architecture decision tree.

Owl · 3 min read · 12 views
– comments
Ep 64 · AI
60s VISUAL BREAKDOWN
Episode 64
Watch the fast visual breakdown or discuss on social:

Most developers learn Prompting, Tool Calling, RAG, MCP, and A2A as five disconnected buzzwords.

In reality, they form one strict engineering progression—where each level was invented solely to fix the breaking point of the level before it.

📥 Download the 1-Page Printable Cheat Sheet:


1. The 5-Level AI Protocol Comparison Matrix

LevelProtocolCore MechanismWhat It SolvesBreaking Point (Why You Need the Next Level)
01Raw PromptsText In → Frozen Weights → Text OutSummarization, translation, zero-setup text generationHallucinates live facts and cannot trigger real-world actions or APIs
02Tool CallingModel emits structured { name, arguments } JSON; your server executes the functionLive API lookups (Stripe, weather, SQL row by ID) & deterministic actionsContext overflow—you cannot stuff 10,000 internal PDFs into a function argument
03Vector RAGEmbed query → Cosine similarity search → Inject only Top-$K$ relevant chunksGrounded answers over millions of private documents with citations$M \times N$ Glue Code—every AI app still rewrites custom wrappers for every tool
04MCPUniversal JSON-RPC 2.0 pipe exposing Tools, Resources, and PromptsWrite 1 MCP Server once; plug into Claude Code, Cursor, Windsurf, or custom hostsSingle-Agent Bottleneck—one agent’s context window overflows on complex multi-domain workflows
05A2A ProtocolPeer-to-peer task delegation via /.well-known/agent.json & HTTP/SSE streamsMulti-agent teamwork across opaque security boundaries without sharing internal memory or API keysFull enterprise multi-agent mesh (combines all 5 layers!)

2. Level 01 → Level 05: Copy-Paste Schemas & Payloads

Level 01: Raw Prompts (POST /v1/chat/completions)

A stateless text completion call. The model only knows what was baked into its weights before its training cutoff.

{
  "model": "claude-sonnet-4-20250514",
  "messages": [
    {
      "role": "user",
      "content": "What was our Q3 Stripe revenue?"
    }
  ]
}
  • Failure mode: Because the model has zero live database access, it either refuses or guesses a hallucinated number.

Level 02: Tool Calling (Structured Function Intent)

Instead of guessing, the LLM pauses generation and outputs a structured JSON object matching your function schema. The LLM does not execute the code—your backend executes it and feeds the result back.

// 1. LLM emits structured tool_use intent:
{
  "type": "tool_use",
  "id": "toolu_01A09q90qw90lq917835lq9",
  "name": "get_stripe_revenue",
  "input": {
    "quarter": "2026-Q3",
    "currency": "USD"
  }
}

// 2. Your backend executes stripe.revenue("2026-Q3") and returns:
{
  "role": "tool",
  "tool_use_id": "toolu_01A09q90qw90lq917835lq9",
  "content": "{\"quarter\":\"2026-Q3\",\"net_revenue_usd\":1420000}"
}

Level 03: Vector RAG (Retrieval-Augmented Generation with pgvector)

When a user asks a question spanning 10,000 internal runbooks or PDFs, you embed their query into a dense vector (1536 floats) and retrieve only the Top-3 closest chunks via cosine distance (<=>):

-- Retrieve Top-3 semantically relevant chunks in PostgreSQL + pgvector
SELECT
  doc_id,
  section_title,
  chunk_text,
  1 - (embedding <=> $1::vector) AS cosine_similarity
FROM company_knowledge_chunks
WHERE 1 - (embedding <=> $1::vector) > 0.78
ORDER BY embedding <=> $1::vector ASC
LIMIT 3;

Level 04: MCP (Model Context Protocol — .mcp.json)

Instead of writing custom API wrappers for GitHub, Postgres, and Sentry in every single agent, MCP standardizes tool discovery (tools/list), execution (tools/call), and data attachment (resources/read) over a single JSON-RPC 2.0 pipe:

{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-postgres", "postgresql://localhost/prod_ro"]
    },
    "github": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_TOKEN}"
      }
    }
  }
}

Level 05: A2A Protocol (Agent-to-Agent Task Delegation)

While MCP connects an agent to tools, A2A connects an agent to other specialist agents. Each specialist publishes an Agent Card at /.well-known/agent.json so peer agents can delegate tasks without ever seeing the specialist’s internal prompts, memory, or credentials:

// GET https://security-agent.internal/.well-known/agent.json
{
  "name": "SecurityAuditAgent",
  "description": "Autonomous SAST/DAST and dependency vulnerability auditor for pull requests.",
  "url": "https://security-agent.internal/a2a",
  "version": "1.0.0",
  "capabilities": {
    "streaming": true,
    "pushNotifications": false
  },
  "skills": [
    {
      "id": "audit-pr",
      "name": "Audit Pull Request",
      "inputModes": ["application/json"],
      "outputModes": ["application/json"]
    }
  ]
}

3. Architecture Decision Tree: Which Layer Should You Use?

  1. Does the task only need text transformation or reasoning over text the user already pasted? $\to$ Stop at Level 01 (Raw Prompt). Keep it simple.
  2. Does the model need to check 1–5 live APIs or trigger a database mutation? $\to$ Add Level 02 (Tool Calling).
  3. Does the model need to search across thousands of unstructured docs, tickets, or runbooks? $\to$ Add Level 03 (Vector RAG).
  4. Are you connecting multiple tools across IDEs (Claude Code, Cursor) and backend services? $\to$ Standardize on Level 04 (MCP).
  5. Do you have separate domain agents (Coding, Security, Data, Billing) owned by different teams or security boundaries? $\to$ Connect them at Level 05 (A2A Protocol).
SYSTEM DESIGN CHECK

Test Your Understanding

Quick architectural scenario challenge based on this breakdown.

SCENARIO

A 3rd-party payment gateway starts timing out with 504 errors during peak traffic.

Q1.How should a downstream dependency failure be handled to protect upstream service availability?

Comments –