CPN 한국어 자습서 · 외부 문서 한국어 미러
MCP 문서 · Specification
Authorization · 원문: modelcontextprotocol.io/specification/2025-11-25/basic/authorization
아래는 원문을 한국어로 옮긴 미러입니다. 코드·명령은 원문 그대로이며, 가장 최신 정보는 하단 원문 링크에서 확인하세요.
Model Context Protocol은 전송 레이어에서 인가 기능을 제공하여 MCP 클라이언트가 리소스 소유자를 대신해 제한된 MCP 서버에 요청할 수 있게 합니다. 이 명세는 HTTP 기반 전송의 인가 흐름을 정의합니다.
인가는 MCP 구현에서 선택 사항(OPTIONAL)입니다. 지원하는 경우:
이 인가 메커니즘은 다음 명세를 기반으로 합니다:
보호된 MCP 서버는 액세스 토큰을 사용하여 보호된 리소스 요청을 수락하고 응답하는 OAuth 2.1 리소스 서버 역할을 합니다.
MCP 클라이언트는 리소스 소유자를 대신하여 보호된 리소스 요청을 하는 OAuth 2.1 클라이언트 역할을 합니다.
인가 서버(authorization server)는 사용자와 상호작용하고(필요한 경우) MCP 서버에서 사용할 액세스 토큰을 발급하는 역할을 합니다.
MCP 서버는 OAuth 2.0 Protected Resource Metadata(RFC9728) 명세를 구현해야 합니다(MUST). 반환되는 Protected Resource Metadata 문서에는 authorization_servers 필드가 포함되어야 합니다(MUST).
MCP 서버는 다음 탐색 메커니즘 중 하나를 구현해야 합니다(MUST):
WWW-Authenticate 헤더: 401 Unauthorized 응답 시 resource_metadata 아래에 리소스 메타데이터 URL을 포함합니다.
Well-Known URI: RFC9728에 지정된 well-known URI에서 메타데이터를 제공합니다:
* 경로: https://example.com/.well-known/oauth-protected-resource/public/mcp
* 루트: https://example.com/.well-known/oauth-protected-resource
MCP 클라이언트는 두 탐색 메커니즘 모두 지원해야 합니다(MUST).
MCP 서버는 WWW-Authenticate 헤더에 scope 파라미터를 포함해야 합니다(SHOULD).
scope 안내가 포함된 401 응답 예시:
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer resource_metadata="https://mcp.example.com/.well-known/oauth-protected-resource",
scope="files:read"
경로 구성 요소가 있는 발급자 URL(예: https://auth.example.com/tenant1)의 경우, 클라이언트는 다음 우선순위로 엔드포인트를 시도해야 합니다(MUST):
https://auth.example.com/.well-known/oauth-authorization-server/tenant1https://auth.example.com/.well-known/openid-configuration/tenant1https://auth.example.com/tenant1/.well-known/openid-configuration경로 구성 요소가 없는 발급자 URL의 경우:
https://auth.example.com/.well-known/oauth-authorization-serverhttps://auth.example.com/.well-known/openid-configurationsequenceDiagram
participant C as Client
participant M as MCP Server (Resource Server)
participant A as Authorization Server
Note over C: Attempt unauthenticated MCP request
C->>M: MCP request without token
M-->>C: HTTP 401 Unauthorized (may include WWW-Authenticate header)
alt Header includes resource_metadata
C->>M: GET resource_metadata URI
M-->>C: Resource metadata with authorization server URL
else No resource_metadata in header
C->>M: GET /.well-known/oauth-protected-resource/mcp
alt Sub-path metadata found
M-->>C: Resource metadata with authorization server URL
else Sub-path not found
C->>M: GET /.well-known/oauth-protected-resource
alt Root metadata found
M-->>C: Resource metadata with authorization server URL
else Root metadata not found
Note over C: Abort or use pre-configured values
end
end
end
C->>A: GET Authorization server metadata endpoint
A-->>C: Authorization server metadata
C->>A: Token request
A-->>C: Access token
C->>M: MCP request with access token
M-->>C: MCP response
MCP는 세 가지 클라이언트 등록 메커니즘을 지원합니다:
우선순위:
MCP 클라이언트와 인가 서버는 OAuth Client ID Metadata Documents를 지원해야 합니다(SHOULD). 이 방식은 클라이언트가 HTTPS URL을 클라이언트 식별자로 사용할 수 있게 합니다.
MCP 클라이언트의 경우:
* 클라이언트는 HTTPS URL에 메타데이터 문서를 호스팅해야 합니다(MUST)
* client_id URL은 "https" 스킴을 사용하고 경로 구성 요소를 포함해야 합니다(MUST)
* 메타데이터 문서에는 client_id, client_name, redirect_uris가 포함되어야 합니다(MUST)
인가 서버의 경우:
* URL 형식의 client_id를 만나면 메타데이터 문서를 가져와야 합니다(SHOULD)
* 가져온 문서의 client_id가 URL과 정확히 일치하는지 검증해야 합니다(MUST)
메타데이터 문서 예시:
{
"client_id": "https://app.example.com/oauth/client-metadata.json",
"client_name": "Example MCP Client",
"client_uri": "https://app.example.com",
"logo_uri": "https://app.example.com/logo.png",
"redirect_uris": [
"http://127.0.0.1:3000/callback",
"http://localhost:3000/callback"
],
"grant_types": ["authorization_code"],
"response_types": ["code"],
"token_endpoint_auth_method": "none"
}
인가 서버는 다음을 통해 지원을 알립니다:
{
"client_id_metadata_document_supported": true
}
MCP 클라이언트는 사전 등록 흐름에서 제공된 정적 클라이언트 자격증명을 위한 옵션을 지원해야 합니다(SHOULD).
MCP 클라이언트와 인가 서버는 하위 호환성을 위해 RFC7591을 지원할 수 있습니다(MAY).
인가 흐름을 구현할 때 MCP 클라이언트는 다음 우선순위를 따라야 합니다(SHOULD):
WWW-Authenticate 헤더에서 scope 파라미터를 사용합니다scope를 사용할 수 없는 경우 Protected Resource Metadata의 scopes_supported에 정의된 모든 범위를 사용합니다sequenceDiagram
participant B as User-Agent (Browser)
participant C as Client
participant M as MCP Server (Resource Server)
participant A as Authorization Server
C->>M: MCP request without token
M->>C: HTTP 401 Unauthorized with WWW-Authenticate header
C->>M: Request Protected Resource Metadata
M->>C: Return metadata
C->>A: GET Authorization server metadata endpoint
A-->>C: Authorization server metadata
alt Client ID Metadata Documents
Note over C: Client uses HTTPS URL as client_id
A->>C: Fetch metadata from client_id URL
C-->>A: JSON metadata document
else Dynamic client registration
C->>A: POST /register
A->>C: Client Credentials
else Pre-registered client
Note over C: Use existing client_id
end
C->>B: Open browser with authorization URL + code_challenge + resource
B->>A: Authorization request with resource parameter
Note over A: User authorizes
A->>B: Redirect to callback with authorization code
B->>C: Authorization code callback
C->>A: Token request + code_verifier + resource
A->>C: Access token (+ refresh token)
C->>M: MCP request with access token
M-->>C: MCP response
MCP 클라이언트는 RFC 8707에 정의된 OAuth 2.0용 Resource Indicators를 구현해야 합니다(MUST). resource 파라미터는:
유효한 표준 URI 예시:
* https://mcp.example.com/mcp
* https://mcp.example.com
* https://mcp.example.com:8443
유효하지 않은 예시:
* mcp.example.com (스킴 없음)
* https://mcp.example.com#fragment (fragment 포함)
MCP 클라이언트는 인가 서버의 지원 여부에 관계없이 resource 파라미터를 전송해야 합니다(MUST).
Authorization: Bearer <access-token>
인가는 모든 HTTP 요청에 포함되어야 합니다(MUST).
요청 예시:
GET /mcp HTTP/1.1 Host: mcp.example.com Authorization: Bearer eyJhbGciOiJIUzI1NiIs...
MCP 서버는 액세스 토큰을 검증하고 해당 서버를 위해 발급된 것인지 확인해야 합니다(MUST). 유효하지 않거나 만료된 토큰은 HTTP 401 응답을 받아야 합니다(MUST).
MCP 클라이언트는 MCP 서버의 인가 서버가 발급하지 않은 토큰을 전송해서는 안 됩니다(MUST NOT).
MCP 서버는 자신을 대상으로 하는 토큰만 수락해야 하며(MUST) 다른 토큰을 수락하거나 전달해서는 안 됩니다(MUST NOT).
| 상태 코드 | 설명 | 사용 |
|---|---|---|
| 401 | Unauthorized | 인가 필요 또는 토큰 유효하지 않음 |
| 403 | Forbidden | 유효하지 않은 범위 또는 권한 부족 |
| 400 | Bad Request | 잘못된 인가 요청 |
클라이언트가 토큰을 가지고 있지만 추가 권한이 필요한 경우:
error="insufficient_scope" 및 필요한 scope를 포함하는 WWW-Authenticate 헤더와 함께예시:
HTTP/1.1 403 Forbidden
WWW-Authenticate: Bearer error="insufficient_scope",
scope="files:read files:write user:profile",
resource_metadata="https://mcp.example.com/.well-known/oauth-protected-resource",
error_description="Additional file write permission required"
WWW-Authenticate 헤더에서 오류 정보를 파싱합니다구현체는 OAuth 2.1 보안 모범 사례를 따라야 합니다(MUST).
resource 파라미터를 포함해야 합니다(MUST)localhost이거나 HTTPS를 사용해야 합니다(MUST).MCP 클라이언트는 S256 코드 챌린지 방법을 사용하여 PKCE를 구현해야 합니다(MUST).
MCP 클라이언트는 인가 서버 메타데이터에서 code_challenge_methods_supported를 확인하고 없으면 진행을 거부해야 합니다(MUST).
MCP 서버가 업스트림 API에 요청하는 경우, MCP 클라이언트로부터 받은 토큰을 전달해서는 안 됩니다(MUST NOT).
핵심 프로토콜에 대한 인가 확장은: * 선택 사항 — 구현체가 선택적으로 채택할 수 있습니다 * 부가적 — 핵심 프로토콜 기능을 수정하거나 손상시키지 않습니다 * 조합 가능 — 충돌 없이 함께 동작하도록 설계되었습니다 * 독립적으로 버전 관리 — 핵심 MCP 버전 관리 주기를 따릅니다
MCP Authorization Extensions 리포지터리를 참조하세요.
원문(영어): https://modelcontextprotocol.io/specification/2025-11-25/basic/authorization · 본 문서는 학습용 한국어 번역이며 원본의 권리는 원저작자(Model Context Protocol)에게 있습니다.
원문(영어): https://modelcontextprotocol.io/specification/2025-11-25/basic/authorization