Tip
See our YouTube video for a walkthrough of this demo.
This demo runs Pocket ID and an OAuth-protected MCP server with Docker Compose. Two Cloudflare quick tunnels provide temporary public HTTPS URLs for Pocket ID and the MCP server.
The MCP server provides the following tools:
list_notesreturns the notes for the authenticated user. It requires thenotes:readscope.add_noteadds a note for the authenticated user. It requires thenotes:writescope.clear_notesremoves all notes for the authenticated user. It requires thenotes:writescope.
You need the following software:
- Docker with Docker Compose
- Claude Desktop or Claude Code
The demo needs public HTTPS URLs for Pocket ID so we use Cloudflare tunnels.
Start the Cloudflare tunnel containers:
docker compose up -d pocket-id-tunnel mcp-tunnelThe tunnel containers generate new public URLs when they start. Get the URLs from the container logs:
echo "Pocket ID URL:"
docker compose logs pocket-id-tunnel | grep -oE 'https://[^ ]+\.trycloudflare\.com'
echo "MCP URL:"
docker compose logs mcp-tunnel | grep -oE 'https://[^ ]+\.trycloudflare\.com'Copy the example environment file:
cp .env.example .env... and replace the placeholders with the public URLs from the tunnel logs. The file should look like this:
POCKET_ID_URL=https://<pocket-id-tunnel>.trycloudflare.com
MCP_URL=https://<mcp-tunnel>.trycloudflare.com/mcp
POCKET_ID_ENCRYPTION_KEY=<generated-encryption-key>Start Pocket ID and the MCP server:
docker compose up -d-
Open
<POCKET_ID_URL>/setup. -
Create the administrator account and register a passkey.
-
Open Administration → APIs.
-
Select Add API.
-
Configure the API:
Field Value Name Notes MCP ServerAPI resource The exact MCP_URLfrom.env, including/mcp -
Add the following API permissions:
Key Name notes:readRead your notesnotes:writeManage your notes -
In the Access card, select Metadata document clients.
-
Enable Allow all metadata document clients.
-
Select
notes:readandnotes:write. -
Select Save.
The Compose configuration allows the Claude Code and Claude Desktop client metadata URLs through Pocket ID's CIMD_URL_ALLOWLIST. You do not need to create an OIDC client, a client secret, or a client-access rule.
Add the MCP server and start the sign-in flow:
claude mcp add --transport http demo <MCP_URL>
claude mcp login demoReplace <MCP_URL> with the complete value from .env.
After you sign in through Pocket ID, test the connection with the following prompt:
Add a note that says the Pocket ID OAuth demo works.
- Open Claude Desktop.
- Go to Settings → Connectors.
- Select Add → Add custom connector.
- Enter a name and the complete
MCP_URLfrom.env. - Select Add.
- Select Connect, and then sign in through Pocket ID.
Test the connection with the following prompt:
Add a note that says the Pocket ID OAuth demo works.
Stop the containers:
docker compose downCloudflare assigns new tunnel URLs the next time the tunnel containers are created. If the URLs change, update .env and the API resource in Pocket ID before restarting the services.
Setting up an OAuth 2.0 provider is often complex and time-consuming. We built Pocket ID because authentication should not be the hard part of building an MCP server or APIs. We can confidently say that Pocket ID is the easiest OAuth 2.0 provider to set up and use.
Setting up Pocket ID is easy. In fact, you have just set up your own instance. For production, deploy it on a server and place a reverse proxy in front of it.
Follow the Pocket ID installation guide for the production setup.
The short version is: verify the JWT.
Pocket ID issues JWT access tokens to clients such as Claude Code. The clients use these tokens to authenticate to your MCP server.
Use a maintained JWT or OpenID Connect library to validate each token. You can find a Go implementation in mcp-server/auth.go. Your library must perform the following checks:
- Verify the token signature with a key from Pocket ID's JWKS endpoint at
/.well-known/jwks.json. - Allow only the configured signing algorithms.
- Verify that the
issclaim matches the Pocket ID URL. - Verify that the
audclaim matches the MCP resource URL. - Verify that the token has not expired.
- Require a non-empty
subclaim.
Configure the library with the Pocket ID issuer, the MCP resource URL, and the Pocket ID JWKS endpoint. Do not implement JWT parsing or signature verification yourself. There is a library for that.
Inside your tools, check the scope claim before performing an action. This demo requires notes:read for list_notes and notes:write for add_note and clear_notes. See mcp-server/scopes.go for the scope checks.