Skip to content
Vibe Coding · Blog

Vibe Coding 04 —
RAG, MCP & Agentic AI

The Engine Behind Smart Vibe Coding

These three concepts transform basic AI chatting into production-grade AI-assisted development. Understanding them means controlling cost, quality, and autonomy.

May 2026 RAG, MCP, Agentic AI 10 min read
Explore Core Concepts

Core Concepts

Three pillars that power smart AI-assisted development

RAG feeds AI your private knowledge. MCP gives AI hands to interact with your systems. Agentic AI lets it plan, execute, and self-correct. Together, they are the engine behind smart vibe coding.

RAG

Feed AI your knowledge, get precise answers

Knowledge Cutoff & The Problem

LLMs have a training cutoff date — they only know what existed when they were trained. They cannot access your private or sensitive business data, company workflows, or internal documentation. Without RAG, you get generic answers, hallucinations, and zero domain specificity. RAG solves this by letting you inject your own knowledge at query time.

The RAG Pipeline

The pipeline flows: Document → Chunking → Embedding → Vector DB → Query → LLM → Response. Chunking splits documents into token-sized pieces — by sentence, paragraph, or semantic boundary. Embedding models convert those chunks into numerical vectors. A vector database stores them and retrieves the most relevant chunks using distance algorithms like cosine similarity.

RAG pipeline diagram
RAG pipeline: Document → Chunking → Embedding → Vector DB → Query → LLM → Response
Embedding Models & Vector Databases

Cloud embedding models (OpenAI, Google, Anthropic) handle multi-modal content automatically — text, image, audio. Single-purpose local models (Ollama, LM Studio) are cheaper and faster for specific tasks. Vector databases store embeddings and retrieve by distance algorithms. The choice depends on your scale, privacy needs, and budget.

Embedding models comparison
Cloud vs local embedding models and vector database options
RAG in Practice: Knowledge Preparation

Before vibe coding, prepare your knowledge documents. Markdown files are preferred over PDF — fewer tokens, cleaner parsing. Use Gemini Gems or GPT assistants to create persistent knowledge spaces. Feed business workflows, competitor analysis, and domain documentation. Quality in equals quality out: RAG knowledge determines output quality. Remember: regular chat is session-based (in-memory only, gone when closed). Persistent knowledge survives across sessions.

RAG knowledge preparation
Knowledge preparation workflow: MD files → Knowledge space → Persistent RAG

MCP

Give AI hands to interact with your systems

What is MCP?

MCP (Model Context Protocol) is a standard protocol by Anthropic for AI-to-system communication. It uses a server/client architecture: MCP servers expose tools, and AI clients call them. Think of it as API endpoints specifically designed for AI agents to discover and use autonomously. MCP is built into Claude Code and configurable in settings as MCP servers.

MCP in Practice: Custom Servers

You can build custom MCP servers that define specific tools: list templates, connect accounts, publish to blog/Facebook/LinkedIn. AI calls these tools during workflow — no manual copy-paste. MCP integrates with any system: Gmail, Calendar, Google Drive, custom APIs. The key difference from regular APIs: MCP defines tool schemas that AI can discover and call autonomously.

MCP architecture diagram
MCP server/client architecture: AI discovers and calls tools autonomously
MCP Security & Permissions

Security is critical: scope permissions carefully using the principle of least privilege. Real risk exists — overpermissioned agents can cause rm -rf incidents. Example: Gmail MCP should not have delete permission if you only need read access. Always define exact actions the MCP can perform. Human-in-the-loop serves as a safety net: approve destructive actions before execution.

MCP security model
Least privilege principle: define exact MCP permissions, approve destructive actions

Agentic AI

AI that plans, executes, and self-corrects

The Agentic Loop

The agentic loop follows: Plan → Execute → Evaluate → Correct → Repeat. AI creates a plan, attempts execution, evaluates results, fixes errors, and loops until done. The key difference from basic chat: autonomous multi-step problem solving. Instead of one question/one answer, the agent orchestrates an entire workflow.

Agentic AI loop diagram
Agentic loop: Plan → Execute → Evaluate → Correct → Repeat
Human-in-the-Loop

AI is not fully autonomous — humans must be the final checkpoint. Quality control means human reviews AI output before publishing or deploying. Example: in a content system, AI writes the article and human approves before posting. Without human-in-the-loop: risk of garbage output, accidental data deletion, or security breaches. The human decides WHAT to do; the agent decides HOW.

FinOps: Token Cost Management

Know your models: use Opus for complex reasoning, Sonnet for everyday coding, Haiku for simple tasks, Gemini Flash for brainstorming. Early phase: use expensive models to build quality memory and history. Later phase: switch to cheaper or local models that reference stored knowledge. Open Router provides a single API to test multiple models and compare cost vs quality. Convert repeated MCP workflows to skills to save tokens. Periodically audit token usage and remove redundant patterns.

Ready to Build Smarter?

Try building your own RAG pipeline, spin up a custom MCP server, or let an agentic workflow handle your next project. The tools are ready — the question is whether you are.

Explore More Articles
99

Get In Touch

Complex infrastructure challenges deserve elegant solutions. Let's realize it together.

Email

gynlam328@gmail.com

Send email

Phone

+84-83314-1685

Call now

Location

Ban Co Ward - Previously known as District 3, HCMC

Connect with me

© 2025 - 2026 Lâm Trịnh Chí Tài (Gyn)

All rights reserved

Vibe Coding 04