원본 보기

이 자습서는 브라우저 흐름(Non-DCR)에서 작동하는 클라이언트를 위해 OAuth 설정으로 Couchbase MCP 서버를 Streamable HTTP 모드로 설정하는 방법을 보여줍니다. Microsoft Entra ID ID 제공자로서 — 사전 등록된 클라이언트가 완전한 브라우저 기반 인증 코드 + PKCE 흐름을 구동하여 MCP Inspector에서 테스트되었습니다.

ℹ️ Non-DCR이란 무엇인가? Non-DCR(동적 클라이언트 등록이 아닌)는 OAuth 클라이언트 앱이 연결하기 전에 Entra에서 수동으로 등록된 것을 의미합니다. 클라이언트 ID는 미리 제공되며, Entra는 브라우저 로그인 및 토큰 발급을 처리합니다. 이는 DCR(동적 클라이언트 등록)과 대조됩니다.RFC 7591), 여기서 클라이언트가 자동으로 등록됩니다. Entra는 오픈 DCR을 지원하지 않으므로, 여기서는 Non-DCR이 유일한 브라우저 기반 흐름입니다.

📖 더 자세히 읽을 수 있습니다. Couchbase MCP Server OAuth Authentication 및 Microsoft Entra ID 문서.

필수 조건

  • 관리자 액세스 권한이 있는 Microsoft Entra ID 테넌트
  • uvx MCP 서버를 실행하기 위해 설치되었습니다.
  • MCP 검사관 (npx @modelcontextprotocol/inspector) 또는 Non-DCR 지원이 있는 IDE
  • 신원 정보가 있는 Couchbase 클러스터 실행

어떤 것을 기대할 수 있을까요?

이 자습서의 끝에 여러분은 다음을 갖게 될 것입니다:

  • Couchbase MCP Server가 Entra에서 사용자 지정 범위가 있는 리소스 서버로 등록되었습니다.
  • Couchbase MCP 클라이언트, Entra에서 SPA 및 모바일/데스크톱 플랫폼을 통해 공개 클라이언트로 등록되었습니다.
  • PRM(보호된 리소스 메타데이터)를 활성화하여 실행되는 MCP 서버
  • MCP Inspector를 통한 검증된 작업 연결 및 브라우저 기반 로그인

이 자습서는 두 단계로 구성되어 있습니다:

단계 1 — Entra 설정

  • MCP 서버를 리소스 서버로 등록하고, 해당 서버의 Application ID URI를 해당 서버의 자체 URL로 설정합니다.
  • 정의를 정의하세요 couchbase-mcp:read 그리고 couchbase-mcp:write 사용자 지정 범위
  • 클라이언트 애플리케이션을 SPA 및 Mobile/Desktop 리디렉션 플랫폼 모두에 등록합니다.
  • 대리 권한 부여 API 권한 부여 및 동의

단계 2 — 비-DCR 브라우저 로그인 흐름

  • 클라이언트가 Entra를 자동으로 검색할 수 있도록 OAuth 및 PRM이 활성화된 상태에서 MCP 서버를 시작하세요.
  • MCP Inspector를 사용하여 연결을 검증하세요.

단계 1 — Entra 설치

단계 1.1 — MCP 서버 애플리케이션 등록

이 앱 등록은 리소스 서버 — Couchbase MCP 서버 자체입니다. 이 서버가 어떤 범위의 데이터를 제공하고, 토큰의 암호는 무엇인지 정의합니다. 오디오 이러한 주장은 있어야 합니다. 참조 신청서를 등록하세요 자세한 내용은 여기를 보세요.

  • 가기 Entra admin center → App registrations → New registration
  • Name it 쿠치베이스 MCP 서버 (in the image below i have named it Couchbase MCP Test Server)
  • Leave redirect URI blank (resource servers don’t need one) → 등록하기

Step 1.2 — Set the Application ID URI

그리고 Application ID URI is the globally unique identifier other apps use to ask for this API’s scopes. It’s what turns a bare scope name like couchbase-mcp:read into the fully-qualified scope a client actually requests (<Application ID URI>/couchbase-mcp:read, as you’ll see in Step 2.2), and it’s the value Entra matches against the resource parameter MCP clients send. See Application ID URI 자세한 내용은 여기를 보세요.

  • In the 쿠치베이스 MCP 서버 app, go to Expose an API

  • 클릭하기 Add next to Application ID URI

  • Instead of accepting the default api://{client_id}, set it to:

    http://127.0.0.1:8000/mcp
    

    This must exactly match the URL your MCP server will be running at, including the /mcp path — the server’s PRM document advertises this exact value, and Entra requires the Application ID URI to match it.

  • 클릭하기 저장

⚠️ Why not api://...? The MCP server’s auto-generated Protected Resource Metadata advertises its own HTTP URL as the resource. These two must match exactly, or you’ll hit AADSTS9010010: resource parameter doesn't match requested scopes. Using the literal server URL sidesteps this entirely.

Step 1.3 — Define the scopes

The Couchbase MCP server uses two scopes to enforce per-tool access control — couchbase-mcp:read for read-only tools and couchbase-mcp:write for mutation tools.

  • Still in Expose an API, 클릭하세요 + Add a scope
  • Create:
    • Scope name: couchbase-mcp:read
    • Who can consent: Admins and users
    • Admin/user consent display name & description: e.g. “Read Couchbase MCP data”
    • 클릭하기 Add scope
  • Repeat for couchbase-mcp:write

Step 1.4 — Set the access token version

The access token version determines what Entra puts in the 오디오 claim — and the MCP server validates 오디오 on every request, so this needs to be explicit rather than left at the tenant default.

  • 가기 Manifest
  • Find "requestedAccessTokenVersion" and change null to 2
  • 저장

This ensures Entra issues v2 access tokens. v2.0 access tokens always carry the resource’s client ID (GUID) in 오디오, which is why --oauth-audience takes the Server Application (Client) ID rather than the Application ID URI. (v1.0 tokens put the Application ID URI there instead — one reason to pin the version explicitly.) See access token claims for the full claim reference.

Step 1.5 — Register the Client application

This second registration is the OAuth client — the application that requests a token and calls the MCP server with it. In this tutorial that’s MCP Inspector or your IDE, not the MCP server itself: the server registration from Step 1.1 only declares the scopes, while this one is what actually asks for them and receives the token. Entra keeps them separate so the same API can be called by several apps, each with its own redirect URIs and its own set of granted permissions.

It’s a public client — it runs on the user’s own machine (a browser tab or a desktop editor), so it can’t keep a client secret private. That’s why no secret is created here and why the flow relies on PKCE instead: the client proves it started the request by sending a one-time verifier rather than a stored credential. See public and confidential client apps 자세한 내용은 여기를 보세요.

  • App registrations → New registration
  • Name it Couchbase MCP Client → 등록하기

Step 1.6 — Configure authentication platforms

The client needs two platform types because browser-based and native clients use different redirect mechanisms — MCP Inspector redirects to a local browser callback, while desktop editors use a native redirect.

For MCP Inspector (browser-based, SPA flow):

  • 가기 인증 → + Add a platform → Single-page application
  • Redirect URI: http://localhost:6274/oauth/callback
  • Configure

For other IDEs (native/desktop flow):

  • + Add a platform → Mobile and desktop applications
  • Add the redirect URIs needed by the IDE
  • Configure

⚠️ A redirect URI value can only exist under one platform type at a time.

Step 1.7 — Grant API permissions

Two sets of delegated permissions are needed: the custom Couchbase MCP scopes, and the standard OpenID permissions that make browser sign-in work.

Add the Couchbase MCP scopes:

  • 가기 API permissions → + Add a permission
  • 클릭하기 My APIs → select 쿠치베이스 MCP 서버
  • Choose Delegated permissions — the app acts on behalf of the signed-in user, which is what a browser login flow does. (Application permissions are for daemons running with no user present; see delegated vs application permissions.)
  • Check both couchbase-mcp:read 그리고 couchbase-mcp:write
  • Add permissions

Add the Microsoft Graph OpenID permissions:

  • + Add a permission again → Microsoft Graph → Delegated permissions
  • Under OpenId permissions, check openid, profile, email및 offline_access
  • Update permissions

ℹ️ These four are what make the browser flow work: openid lets Entra issue an ID token for the sign-in, offline_access gets you a refresh token so the session survives access-token expiry, and profile / email carry the basic user claims. Without them the sign-in can fail outright or drop the session as soon as the first token expires.

Finally, grant consent for both sets:

  • 클릭하기 Grant admin consent for [tenant] → confirm
  • All permissions should show a green checkmark under Status

Step 1.8 — Collect your IDs

These values are used in the MCP server startup command and in the MCP client configuration:

Value Where to find it
Directory (Tenant) ID 쿠치베이스 MCP 서버 app → 개요
Server Application (Client) ID 쿠치베이스 MCP 서버 app → 개요
Client Application (Client) ID Couchbase MCP Client app → 개요

Step 2 — Non-DCR Browser Login Flow

This flow uses a pre-registered public client with a browser-based authorization code + PKCE flow. The client ID is provided upfront, and Entra handles the browser login and token issuance.

Step 2.1 — Start the MCP server with PRM

uvx "couchbase-mcp-server" 
  --transport=http 
  --connection-string="<your-couchbase-connection-string>" 
  --username="<your-couchbase-username>" 
  --password="<your-couchbase-password>" 
  --read-only-mode=false 
  --oauth-jwks-uri="https://login.microsoftonline.com/<TENANT_ID>/discovery/v2.0/keys" 
  --oauth-issuer="https://login.microsoftonline.com/<TENANT_ID>/v2.0" 
  --oauth-audience="<SERVER_CLIENT_ID>" 
  --oauth-mcp-base-url="http://127.0.0.1:8000"

The addition of --oauth-mcp-base-url enables the PRM endpoint, which clients use to discover Entra as the authorization server.

Verify the PRM document:

curl -s http://127.0.0.1:8000/.well-known/oauth-protected-resource/mcp | python3 -m json.tool

Expected response:

{
  "resource": "http://127.0.0.1:8000/mcp",
  "authorization_servers": ["https://login.microsoftonline.com/<TENANT_ID>/v2.0"],
  "scopes_supported": ["couchbase-mcp:read", "couchbase-mcp:write"],
  "bearer_methods_supported": ["header"],
  "resource_name": "Couchbase MCP Server"
}

This resource value is exactly what must match the Application ID URI from Step 1.2 — if you change the server’s host/port, you’ll need to update the Application ID URI to match.

Step 2.2 — Connect via MCP Inspector

npx @modelcontextprotocol/inspector

In the Inspector UI:

Field Value
Transport Type Streamable HTTP
URL http://127.0.0.1:8000/mcp
Client ID Client Application (Client) ID
Client Secret (leave blank — public client)
Redirect URL http://localhost:6274/oauth/callback
범위 http://127.0.0.1:8000/mcp/couchbase-mcp:read http://127.0.0.1:8000/mcp/couchbase-mcp:write

⚠️ Entra requires fully-qualified scopes, so the scope format must be <Application ID URI>/<scope-name> — not the bare scope name. Since the Application ID URI is http://127.0.0.1:8000/mcp, each scope becomes http://127.0.0.1:8000/mcp/couchbase-mcp:read.

The Scope field is required. Leaving it blank makes Inspector fall back to the bare scope names from the PRM document, which Entra rejects — it needs the Application ID URI prefix to know which API you mean.

Entra strips the prefix when it writes the scp claim, leaving couchbase-mcp:read — which is what the MCP server matches against.

클릭하기 연결하기 → the Entra sign-in page opens → sign in → Inspector shows “Successfully authenticated with OAuth”.

Verify:

  • Tools 탭 → List Tools — tools should be visible
  • Run a read tool → success
  • Run a write tool → success
  • Auth tab → confirm the token claims:
    • 오디오 (audience) — the Server Application (Client) ID, matching --oauth-audience
    • iss (issuer) — https://login.microsoftonline.com/<TENANT_ID>/v2.0, matching --oauth-issuer
    • scp (scope) — Entra’s name for the granted scopes; should list couchbase-mcp:read 그리고 couchbase-mcp:write

Summary

You’ve secured the Couchbase MCP server with Microsoft Entra ID using the Non-DCR browser login flow:

  • The MCP server registered as a resource server whose Application ID URI is the server’s own URL — the piece that keeps Entra’s resource matching aligned with the PRM document
  • Two scopes, couchbase-mcp:read 그리고 couchbase-mcp:write, granted to a public client with admin consent
  • A client registration carrying both SPA and Mobile/Desktop redirect platforms, since browser-based and native clients redirect differently
  • The MCP server publishing a PRM document that lets MCP clients discover Entra with no hardcoded endpoints
  • The flow verified end to end through MCP Inspector

Because Entra does not support open Dynamic Client Registration, every client must be pre-registered — which also makes per-client scope control straightforward: register separate client apps (e.g. read-only vs read-write) and grant only the permissions each one should hold.

📖 Further reading: Couchbase MCP Server OAuth Authentication · Entra scopes and permissions · MCP Authorization specification

데이터베이스의 확장성을 과거의 일로 남겨두세요

각 스택 추가마다 추가 비용이 발생하고 관리해야 할 항목도 더 많아집니다. 2분 안에 절약할 수 있는 금액을 추산해 보세요.