C.W.K.
Stream
Lesson 03 of 04 · published

Webhook 과 Async Event

~22 min · webhooks, async, push, mcp-async-tasks

Level 0호기심 많은 독자
0 XP0/48 lessons0/14 achievements
0/100 XP to next level100 XP to go0% complete

대부분 API 가 pull 모양: client 가 묻고 server 가 답. Webhook 이 방향 뒤집음: server 가 — 뭔가 일어날 때 — client 가 등록한 URL 로 event push. 소비자가 producer 가 발생시키는 event 에 빨리 반응해야 할 때 맞는 답 — payment 확인, build 완료, 메시지 도착.

OpenAPI 3.1 이 webhook 을 first-class spec 시민으로 격상; 문서가 request/response API 와 API 가 push 할 event 둘 다 묘사. Webhook-받는 service 가 한 문서로 묘사 가능 — MCP server 가 소비 가능 (server 가 검증 · normalize · resource 또는 notification 으로 재노출).

MCP 도 이제 async 스토리. 2025-11-25 revision 이 async task extension 추가: tool call 이 — 기다리는 대신 — task handle (working, input_required, completed, failed, cancelled) 반환 가능. Client 가 poll 또는 task 완료 시 notification 받음. MCP 안의 'call now, fetch later' — webhook 과 같은 모양인데 별도 URL 대신 protocol 용어로.

결정: Webhook 이 producer 가 event source of truth 이고 소비자가 우연히 HTTP-닿을 수 있을 때 맞음. MCP async task 가 — 소비자가 protocol 통해 long-running operation 시작하고 결과 나중에 받기만 하면 될 때 — 맞음. 경쟁자 X — '이거 시간 걸렸고 다시 들을 거야' 의 다른 ergonomics.

Code

Webhook 받기 — 최소 FastAPI 모양·python
@app.post("/hooks/stripe")
async def stripe_hook(request: Request):
    payload = await request.body()
    sig = request.headers.get("Stripe-Signature")
    event = stripe.Webhook.construct_event(payload, sig, WH_SECRET)
    if event["type"] == "payment_intent.succeeded":
        await record_payment(event["data"]["object"])
    return {"received": True}
MCP async-task lifecycle·json
// 초기 tool call 이 task handle 반환
{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"build_codebase",...}}
// → result: {"taskId":"task_42","state":"working"}

// Client 가 poll (또는 push notification 받음)
{"jsonrpc":"2.0","id":2,"method":"tasks/get","params":{"taskId":"task_42"}}
// → result: {"taskId":"task_42","state":"working","progress":0.6}
// 나중에 → result: {"taskId":"task_42","state":"completed","value":{...}}

External links

Exercise

Integrate 하는 외부 service (Stripe, GitHub, Linear) 골라. Capability 중 어느 게 pull 모양, 어느 게 push 모양 (webhook), 어느 게 MCP async task 로 이득 볼지 identify. 섞임이 보통 사람 놀라게; 명백한 케이스가 드물어.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.