---
id: wiki-2026-0508-protocols
title: Protocols
category: 10_Wiki/Topics
status: verified
canonical_id: self
aliases: [Communication Protocols, Network Protocols, Wire Protocols]
duplicate_of: none
source_trust_level: A
confidence_score: 0.9
verification_status: applied
tags: [networking, protocols, systems, MCP]
raw_sources: []
last_reinforced: 2026-05-10
github_commit: pending
tech_stack:
  language: multi
  framework: HTTP-gRPC-MCP
---

# Protocols

## 매 한 줄
> **"매 communicating parties 가 매 따라야 하는 rules 의 명시"**. 매 syntax (frame format), 매 semantics (meaning of fields), 매 timing (sequencing) 의 3 axes 로 정의. 매 2026 의 hot stack: HTTP/3 (QUIC), gRPC, MCP (Model Context Protocol), WebSocket, MQTT 5.

## 매 핵심

### 매 protocol 의 layers
- **Physical / Link**: Ethernet, Wi-Fi 7, 5G NR.
- **Network**: IPv6 (default 2026), IPv4 legacy.
- **Transport**: TCP, UDP, QUIC.
- **Application**: HTTP/3, gRPC, MCP, MQTT, AMQP.

### 매 design dimensions
- **Stateful vs stateless**: 매 server-side state 보관 여부.
- **Sync vs async**: 매 request-response vs publish-subscribe.
- **Push vs pull**: 매 server-initiated vs client-initiated.
- **Text vs binary**: 매 human-readable vs efficient.
- **Versioning**: 매 backward / forward compatibility 의 strategy.

### 매 응용
1. **Web**: HTTP/3 over QUIC — 매 default.
2. **AI tools**: MCP (Anthropic 2024) 매 LLM ↔ tool 의 universal.
3. **Microservices**: gRPC 매 internal RPC.
4. **IoT**: MQTT 5 매 lightweight pub-sub.
5. **Realtime**: WebSocket / WebTransport.

## 💻 패턴

### MCP server (Anthropic, 2026 standard)
```python
from mcp.server import Server
from mcp.types import Tool, TextContent

server = Server("knowledge-base")

@server.list_tools()
async def tools():
    return [Tool(
        name="query",
        description="Query the KB",
        inputSchema={
            "type": "object",
            "properties": {"q": {"type": "string"}},
            "required": ["q"],
        },
    )]

@server.call_tool()
async def call(name, args):
    return [TextContent(type="text", text=search(args["q"]))]
```

### gRPC service (.proto + Python)
```protobuf
// kb.proto
syntax = "proto3";
service KB {
  rpc Query(QueryRequest) returns (stream QueryChunk);
}
message QueryRequest { string q = 1; }
message QueryChunk { string text = 1; bool done = 2; }
```

```python
# server.py
import grpc, kb_pb2_grpc, kb_pb2

class KBServicer(kb_pb2_grpc.KBServicer):
    def Query(self, request, context):
        for chunk in stream_search(request.q):
            yield kb_pb2.QueryChunk(text=chunk, done=False)
        yield kb_pb2.QueryChunk(done=True)
```

### HTTP/3 client (QUIC)
```python
# httpx + h2/h3
import httpx

async with httpx.AsyncClient(http2=True, http3=True) as client:
    r = await client.get("https://api.example.com/v1/users")
    print(r.http_version)  # "HTTP/3"
```

### WebSocket realtime
```python
import asyncio
import websockets

async def handler(ws):
    async for msg in ws:
        await ws.send(f"echo: {msg}")

async def main():
    async with websockets.serve(handler, "0.0.0.0", 8765):
        await asyncio.Future()  # run forever
```

### MQTT 5 pub-sub (IoT)
```python
import paho.mqtt.client as mqtt

def on_message(client, userdata, msg):
    print(f"{msg.topic}: {msg.payload.decode()}")

client = mqtt.Client(protocol=mqtt.MQTTv5)
client.on_message = on_message
client.connect("broker.example.com", 1883)
client.subscribe("sensors/+/temperature")
client.loop_forever()
```

### Protocol negotiation (capabilities handshake)
```python
# Common pattern: client sends supported versions, server picks highest mutual
def negotiate(client_versions: set[str], server_versions: set[str]) -> str:
    common = client_versions & server_versions
    if not common:
        raise ProtocolError("no compatible version")
    return max(common, key=lambda v: tuple(map(int, v.split("."))))
```

## 매 결정 기준
| Scenario | Protocol |
|---|---|
| 매 LLM ↔ tools | MCP |
| 매 internal RPC, polyglot | gRPC over HTTP/2 |
| 매 public web API | HTTP/3 + JSON / OpenAPI |
| 매 realtime browser | WebSocket / WebTransport |
| 매 IoT constrained | MQTT 5 / CoAP |
| 매 message queue | AMQP 1.0 / Kafka |
| 매 streaming chat | Server-Sent Events / WebSocket |

**기본값**: 매 public = HTTP/3 + JSON, 매 internal = gRPC, 매 LLM tools = MCP.

## 🔗 Graph
- 부모: [[Distributed-Systems]]
- 변형: [[HTTP]] · [[gRPC]] · [[MCP]]
- 응용: [[API-Design]] · [[Microservices]] · [[클라우드 인프라 및 IaC 운영 표준|IoT]]
- Adjacent: [[Interoperability]]

## 🤖 LLM 활용
**언제**: 매 protocol selection, 매 wire format debugging, 매 backward-compat strategy review.
**언제 X**: 매 single-process in-memory calls — 매 protocol 무용.

## ❌ 안티패턴
- **Custom snowflake protocol**: 매 in-house wire format 매 ecosystem 의 X.
- **No version negotiation**: 매 deploy mismatch → cascade failure.
- **Stateful with no session**: 매 load balancer 매 sticky session 강제 → scaling pain.
- **Chatty protocols**: 매 N round trips 매 single op → latency.

## 🧪 검증 / 중복
- Verified (RFC 9114 HTTP/3, 9000 QUIC; gRPC.io; Anthropic MCP spec 2024; OASIS MQTT 5; OASIS AMQP 1.0).
- 신뢰도 A.

## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — protocol layers + 2026 modern stack (MCP, HTTP/3, gRPC) |
