핵심 요약
MCP 2.0이 push notification, OAuth 2.1, structured tool output을 정식 spec에 포함. 사내 MCP 서버 14개를 6개월 운영하며 long-running 작업, 권한 위임, 멀티 클라이언트 동시 접속 패턴 정착. 토큰 비용 31% 절감, 응답 지연 평균 -1.4s.
1. push 알림 — long-running 작업 패턴
1.0은 polling만 가능. 2.0에서 서버가 클라이언트로 push 가능 → 30분 걸리는 deploy 작업도 클라이언트가 대기 안 하고 즉시 다음 작업. 종료 시 push 받아 결과 출력.
// server.ts
server.tool('deploy', { ... }, async ({ input, context }) => {
context.notify({ type: 'progress', stage: 'building' })
await build()
context.notify({ type: 'progress', stage: 'deploying' })
await deploy()
return { content: [{ type: 'text', text: 'done' }] }
})
2. OAuth 2.1 — remote MCP server
remote 서버는 OAuth 2.1 + PKCE 필수. Discovery → authorize → token exchange. Claude Desktop이 자동 처리, 자체 클라이언트는 SDK 사용.
3. structured tool output
tool 결과를 JSON schema로 정의 → LLM이 더 정확히 파싱. 예: {"status": "success", "id": 123} 같은 구조 응답.
4. 멀티 클라이언트 — session 격리
같은 서버에 Desktop, 사내 봇, CLI가 동시 접속. session id별 컨텍스트 격리 필요. SDK의 SessionStore 인터페이스 구현.
5. 함정
- 1.0 호환 — server는 2.0 spec, 클라이언트가 1.0이면 fallback. capability 협상 잘 챙기기
- push 알림은 SSE 또는 WebSocket — 방화벽·로드밸런서 timeout 90초 이상 설정
- OAuth state 저장 — Redis 만료 길게(15분), 짧으면 모바일에서 재인증 빈발
- tool 이름 충돌 — 클라이언트가 여러 서버 동시 연결하면 prefix 강제

댓글 0