Загрузка...

MCP Core Concepts Explained| JSON-RPC, Prompts, Sampling, stdio vs SSE | Sunday 2–5 | Sir Ali jawad

In this **Sunday 2–5 session (Class 22)**, we explored the **core concepts of the Model Context Protocol (MCP)** and how communication happens between an MCP Client and MCP Server.

**Anthropic** introduced MCP to standardize how AI models interact with tools, data, and external systems. One of the most important parts of MCP is how messages are exchanged between the client and server.

---

## 🔹 Topics Covered in This Class

### 1️⃣ JSON-RPC — The Language of MCP

JSON-RPC is the communication protocol used between the MCP client and server. Every action like listing tools, calling a tool, or reading resources happens through JSON-RPC messages.

We covered the main message types:

* **Request** → Client asks the server to perform an action
* **Response** → Server sends the result back
* **Error** → Sent when something goes wrong
* **Notification** → Informational message that doesn’t require a response

We also discussed common JSON-RPC error codes such as:

* **Parse Error (-32700)**
* **Invalid Request (-32600)**
* **Method Not Found (-32601)**
* **Invalid Params (-32602)**
* **Internal Error (-32603)**

📚 JSON-RPC specification:
[https://www.jsonrpc.org/specification](https://www.jsonrpc.org/specification)

---

### 2️⃣ MCP Prompts

MCP Prompts are **ready-made prompt templates** that servers provide to clients.

Instead of creating prompts every time, users can simply request them from the server and use them directly.

Example idea:

* Server = teacher who prepares exam questions
* Client = student who requests the exam paper

This makes expert knowledge reusable across many users.

---

### 3️⃣ MCP Sampling

Sampling allows the **server to request the client to query an LLM**.

Normal flow:
Client → Server → Result

Sampling flow:
Server → Client → LLM → Server

This design exists for two main reasons:

* **Security** – the API key stays with the client
* **Billing control** – the client pays for the LLM usage

The server never gets direct access to the API key.

---

### 4️⃣ MCP Transports (How Messages Travel)

MCP supports two main transport methods:

#### 🔹 stdio (Standard Input / Output)

* Direct communication through input/output streams
* No network required
* Best for local development and testing
* One client per server process

#### 🔹 SSE (Server-Sent Events)

* Communication over HTTP using a server URL
* Server runs independently
* Multiple clients can connect at the same time
* Suitable for web apps and production environments

Even though the **transport changes**, the message format (JSON-RPC) stays the same.

---

## 🔑 Key Takeaway

* **JSON-RPC** → Message format used by MCP
* **Prompts** → Reusable expert prompt templates
* **Sampling** → Secure way for servers to use LLMs through the client
* **Transports (stdio / SSE)** → How the messages travel

Together, these concepts form the foundation for building **AI agents and MCP-powered applications**.

---

📚 Official MCP Documentation:
[https://docs.anthropic.com/en/docs/mcp](https://docs.anthropic.com/en/docs/mcp)

Видео MCP Core Concepts Explained| JSON-RPC, Prompts, Sampling, stdio vs SSE | Sunday 2–5 | Sir Ali jawad канала know how coding
Яндекс.Метрика
Все заметки Новая заметка Страницу в заметки
Страницу в закладки Мои закладки
На информационно-развлекательном портале SALDA.WS применяются cookie-файлы. Нажимая кнопку Принять, вы подтверждаете свое согласие на их использование.
О CookiesНапомнить позжеПринять