Перейти к содержимому

My Store Now Has an AI Agent 🤖 LangChain + MCP Tools, Middleware & Memory (Day 6)

ConnectXeo

0:00 / 0:00

My Store Now Has an AI Agent 🤖 LangChain + MCP Tools, Middleware & Memory (Day 6)

84 просмотра · 4 дн. назад
ConnectXeo
257 подписчиков
84 просмотра · 4 дн. назад
Day 6 of building ZEK, an agentic commerce system from scratch 🤖 Our MCP server is ready, so now it's time to give it a brain. In this episode I build the ZEK AI shopping agent with LangChain: an agent that talks to shoppers, searches products, and securely uses each shopper's own tools through our MCP server. You'll see the real code behind it: create_agent() with an OpenAI-compatible model (free frontier models via Agnes AI), a system prompt that stops the agent from inventing products or prices, runtime context with the shopper's JWT, a custom middleware that loads and caches MCP tools per shopper, and a Postgres store for long-term memory. 💻 Source code (100% open source): https://github.com/Sami606713/zek 📺 Previous episode (Day 5, MCP Server):    • MCP Server Explained & Built: FastAPI to M...   📺 Backend episode (Day 4):    • Built the Brain of My AI Store | Full Back...   ⏱️ Chapters 0:00 Intro 0:15 Welcome to Day 6: building the AI agent 0:43 Recap: what we built in the last episode 1:10 The agent folder structure 1:56 LangChain: building agents with the latest docs 3:39 The model: OpenAI-compatible API with Agnes AI (free) 4:27 create_agent(): model, system prompt, tools, context & middleware 5:07 Why we wrap create_agent in a function 5:26 Running the MCP server & the agent 6:35 First run: ZEK replies for the first time 7:16 Context: passing the shopper's JWT to the agent 9:00 Middleware in LangChain: node-style vs wrap-style hooks 9:38 The 6 middleware hooks explained 10:30 What middleware can do: guard, monitor, rate-limit, remove PII 12:05 ZekAuthMiddleware: loading MCP tools per shopper 12:21 Token auth & caching the tool list 14:01 wrap_model_call: injecting MCP tools into every model call 15:21 Recap: what we built in this video 15:58 Store: long-term memory for personalised recommendations 16:57 Outro & what's next 🧠 What you'll learn • How to build an AI agent with LangChain's create_agent() • Using any OpenAI-compatible model by changing just the base_url • Writing a system prompt that keeps the agent honest (no invented products or prices) • Passing runtime context (like a user's JWT) to an agent • LangChain middleware: the 6 hooks and when to use them • Securely connecting an agent to an MCP server with per-user tools and caching • Long-term memory with a Postgres store and embeddings ⏭️ Coming next: a middleware deep dive, connecting the agent to the frontend, and tracing with LangSmith. 👍 If this helped you, like, subscribe and share it with someone building AI agents. Questions? Drop them in the comments! #AIAgents #LangChain #MCP #AgenticAI #Python #FastAPI #LLM #AIShoppingAssistant #BuildInPublic #ZEK Follow along: Instagram:   / connectxeo   Agens AI: https://agnes-ai.com/ Github: https://github.com/Sami606713/zek X: https://x.com/0xAgentHQ TikTok:   / connectxeo   YouTube:    / @connectxeo