Andrii · AI at work

All lessons

02

MCP from Scratch: Connecting Claude to My Own Data in 20 Minutes

14:28 · 11 steps

1 Materials repository github.com
  1. 1 00:00 The same question, the same Claude: before and after
  2. 2 01:10 Why you need MCP at all: where the model ends
  3. 3 02:10 A ready-made server from the docs: connecting and the first call
  4. 4 04:21 Data: a generator and two hundred fictional orders
  5. 5 05:25 Your own server: the task in words, not in syntax

    1 What to do

    I give Claude Code the task in words, and it finds the fresh SDK on its own and writes a server with three tools.

    2 Prompt

    EN · Prompt
    # Task: an MCP server over the orders of "«Три зерна»"
    
    The data is fictional, the company "«Три зерна»" does not exist. The coffee shop's orders are in the file
    `orders.json` at an absolute path outside the server folder (in the video — `C:\data\tri-zerna\orders.json`),
    as a list of two hundred records.
    Each order has a number, date, customer (the café's name), city, product, quantity, price per
    unit, total, status and manager.
    
    Write an MCP server in Python that gives the model three tools for working with these orders:
    
    1. **Order list** — with optional filters by status and by city and with a limit on the
       number of records returned (twenty by default).
    2. **Order search** — by a substring that is looked up both in the customer's name and in the product name.
    3. **Order card** — all fields of a single order by its number.
    
    Requirements:
    - the server works over stdio and doesn't open a separate network port;
    - each tool has a short description for the model — one sentence in Russian,
      without bureaucratic language, to the point about what the tool returns;
    - the whole server file is no longer than sixty lines;
    - use the Python SDK for MCP that is current today — find the right server
      class and the way to register a tool in its fresh documentation yourself, don't rely on what you
      already know about it.
    
    The server doesn't store or accept any secrets: it only reads the orders file.
    EN · Prompt from the screen
    # Задача: сервер MCP над заказами «Три зерна»
    
    Данные вымышленные, компания «Три зерна» не существует. Заказы кофейной лавки лежат в файле
    `orders.json` по абсолютному пути вне папки сервера (в ролике — `C:\data\tri-zerna\orders.json`),
    в виде списка из двухсот записей.
    У каждого заказа есть номер, дата, клиент (название кафе), город, товар, количество, цена за
    единицу, сумма, статус и менеджер.
    
    Напиши сервер MCP на Python, который отдаёт модели три инструмента для работы с этими заказами:
    
    1. **Список заказов** — с необязательными фильтрами по статусу и по городу и с ограничением на
       число возвращаемых записей (по умолчанию двадцать).
    2. **Поиск заказов** — по подстроке, которая ищется и в названии клиента, и в названии товара.
    3. **Карточка заказа** — все поля одного заказа по его номеру.
    
    Требования:
    - сервер работает через stdio, отдельного сетевого порта не поднимает;
    - у каждого инструмента есть краткое описание для модели — одно предложение на русском языке,
      без канцелярита, по существу того, что инструмент возвращает;
    - весь файл сервера — не длиннее шестидесяти строк;
    - используй актуальный на сегодня Python SDK для MCP — найди в его свежей документации нужный
      класс сервера и способ регистрации инструмента сам, не полагайся на то, что ты про него уже
      знаешь.
    
    Сервер не хранит и не принимает никаких секретов: он только читает файл с заказами.

    Ask in Telegram

  6. 6 07:35 Registering in .mcp.json, restart, three levels
  7. 7 08:55 What you see when the model calls a tool
  8. 8 09:43 The run: five questions, the fifth one about volume
  9. 9 11:14 Where it breaks: secrets, limits, when a script is simpler
  10. 10 13:36 Homework
  11. 11 14:14 What's next