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

Build an MCP Server from Scratch in Python (No SDK): Turn Your AI Agent's Tools into a Protocol

swa

0:00 / 0:00

Build an MCP Server from Scratch in Python (No SDK): Turn Your AI Agent's Tools into a Protocol

50 просмотров · 11 дней назад
swa
6 подписчиков
50 просмотров · 11 дней назад
Last video we built Ops, an AI agent with six tools, all locked inside one Python program. In this one we take those tools out of the agent and put them behind a Model Context Protocol (MCP) server, written from scratch in plain Python with no SDK, so you can see every byte on the wire. Then we write the client, plug the agent back in, and look at what changes. The approval gate moves to the client, and trust becomes the real design problem. We build to the current MCP spec. It is stateless: every request carries its own version and capabilities, and servers implement server/discover. The server also answers the older 2025-11-25 handshake, so older clients keep working. Chapters 0:00 Six tools, locked in one program 0:56 What MCP actually is (host, client, server · tools, resources, prompts) 2:53 What travels on the wire (JSON-RPC over stdio) 4:41 The server: its main loop 6:53 Stateless: _meta, versions, server/discover, caching hints 9:46 Tools over MCP: annotations, two kinds of errors, input validation 14:05 Staying compatible with older clients (dual-era) 15:37 The client: launch, discover, call, name prefixes 18:03 The approval gate moves to the client 20:56 Trust: tool poisoning, changed descriptions, pinning, local servers, OAuth 24:55 Proving it works (tests) 26:16 SDKs, recap, next: agent memory Notes: All code is standard-library Python and was run and tested. All wire traffic and terminal output on screen is real; abbreviations are marked. The poisoned tool description on screen is an illustrative reconstruction. The "Ops" tasks and notes are fictional. AI Agents series: 1) AI Agents from First Principles · 2) Build an AI Agent: Personal Ops Agent · 3) this video · next: agent memory. What's the first tool you'd put behind MCP, and would you trust its annotations? #MCP #AIAgents #Python Tags MCP, Model Context Protocol, MCP server, build MCP server, MCP from scratch, MCP Python, MCP tutorial, MCP client, JSON-RPC, stdio, AI agents, AI agent tools, tool calling, Claude tool use, tool annotations, destructiveHint, human in the loop, tool poisoning, prompt injection, MCP security, AI engineering, LLM engineering