mcp-oauth

mcp-oauth is a skill for Claude Code, Codex from lucaperret/agent-skills. It costs 140 tokens per session (2,849 once invoked), scanned A, original, MIT.

A setup guide for adding OAuth 2.0 with PKCE to a remote MCP server. OAuth is a login and permission system; PKCE adds protection to the authorization-code login flow, and MCP is a standard way for AI clients to call tools.

In plain words
What is it for?
Use it to protect an MCP server with login, client discovery, registration, authorization, token exchange, and token refresh. It is suited to connectors that access services such as files, playlists, or accounts.
Why use it?
It prevents anyone who knows the server address from accessing user-specific accounts or data. It covers the connection between the MCP client, your authentication layer, and an upstream service.

Skill for Claude CodeCodex

Which agent this was written for is unclear — built for openclaw. Also seen: built for openclaw.

Good fit Use it to protect an MCP server with login, client discovery, registration, authorization, token exchange, and token refresh. It is suited to connectors that access services such as files, playlists, or accounts.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/lucaperret/agent-skills/mcp-oauth
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add lucaperret/agent-skills --skill mcp-oauth
Clone the repo
git clone --depth 1 https://github.com/lucaperret/agent-skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for mcp-oauth

README.md
[![agentmods](https://agentmods.dev/badge/skills/lucaperret/agent-skills/mcp-oauth/github.svg)](https://agentmods.dev/skills/lucaperret/agent-skills/mcp-oauth)
Your own site
<a href="https://agentmods.dev/skills/lucaperret/agent-skills/mcp-oauth"><img src="https://agentmods.dev/badge/skills/lucaperret/agent-skills/mcp-oauth/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for mcp-oauth

Your own site · 80×15
<a href="https://agentmods.dev/skills/lucaperret/agent-skills/mcp-oauth"><img src="https://agentmods.dev/badge/skills/lucaperret/agent-skills/mcp-oauth.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 140 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,849 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00140 $0.02849
Opus 5 $0.00070 $0.01425
Sonnet 5 $0.00028 $0.00570
Haiku 4.5 $0.00014 $0.00285

Measured 10d ago against content hash eb00bd0b1b01, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade A, and why

mcp-oauth scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 10d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/mcp-oauth/SKILL.md · 332 lines

How it starts

The opening of the file, as written. The whole thing — 332 lines — stays where its author put it; the contents beside it link to each section on GitHub.

OAuth 2.0 PKCE for MCP Servers

Add production-ready OAuth authentication to a remote MCP server. This implements the full MCP authorization spec — discovery, dynamic client registration, PKCE authorization, token exchange, and refresh.

When you need this

Your MCP server accesses user-specific data (their account, their files, their playlists). Without auth, anyone with your server URL could access anyone's data. OAuth lets each user authenticate with their own credentials and get their own token.

Architecture overview

Your MCP server plays two roles:

  1. OAuth server for MCP clients (Claude, Smithery) — issues your own tokens
  2. OAuth client to the upstream service (Tidal, GitHub, Slack, etc.) — exchanges for their tokens
MCP Client (Claude) → Your OAuth Server → Upstream Service (e.g., Tidal)
     │                      │                        │
     │  1. Discover OAuth   │                        │
     │  2. Register client  │                        │
     │  3. Authorize        │──→ 4. Redirect to      │
     │                      │      upstream login ──→ │
     │                      │  ←── 5. Callback ──────│
     │  ←── 6. Auth code    │                        │
     │  7. Exchange token   │                        │
     │  8. Call tools ─────→│──→ 9. API calls ──────→│

Required endpoints

1. OAuth Discovery

app/.well-known/oauth-authorization-server/route.ts:

import { NextResponse } from 'next/server';

const SITE_URL = process.env.NEXT_PUBLIC_SITE_URL || 'https://your-domain.com';

export async function GET() {
  return NextResponse.json({
    issuer: SITE_URL,
    authorization_endpoint: `${SITE_URL}/api/authorize`,
    token_endpoint: `${SITE_URL}/api/token`,
    registration_endpoint: `${SITE_URL}/api/register`,
    response_types_supported: ['code'],
    grant_types_supported: ['authorization_code', 'refresh_token'],
    code_challenge_methods_supported: ['S256'],
    token_endpoint_auth_methods_supported: ['none'],
  }, {
    headers: {
      'Access-Control-Allow-Origin': '*',
      'Access-Control-Allow-Methods': 'GET, OPTIONS',
    },
  });
}

export async function OPTIONS() {
  return new NextResponse(null, {
    status: 204,
    headers: {
      'Access-Control-Allow-Origin': '*',
      'Access-Control-Allow-Methods': 'GET, OPTIONS',
      'Access-Control-Allow-Headers': 'Content-Type, Authorization',
    },
  });
}

Read the full file on GitHub · 332 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 10d ago First seen · 332 lines · 140 tokens per session scan A eb00bd0b1b01

Subscribe to this mod's changes

mcp-oauth is a skill published in the GitHub repository lucaperret/agent-skills (6 stars, last pushed 5mo ago), licensed MIT. It adds 140 tokens to every session and 2,849 once invoked, about $0.0007 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

nylas-api

Build email, calendar, and contacts integrations with the Nylas v3 API. Use when code imports nylas, @nylas/nylas, nylas-python, or user asks about Nylas API, email API integration, calendar API, contacts API, OAuth grants, agent accounts, webhooks, scheduler, notetaker, smart compose, or transactional send. DO NOT…

nylas/skills · 90 tokens

project-architecture

Skill "project-architecture" from pjosols/pyfastmail-mcp, covering project architecture, package layout, key patterns and adding a new tool.

pjosols/pyfastmail-mcp · 0 tokens

api-implementation

Skill "api-implementation" from pjosols/pyfastmail-mcp, covering api implementation, jmap (mail, masked email), dav protocols (contacts, calendars, files), carddav (rfc 6352) — contacts and caldav (rfc 4791) — calendars.

pjosols/pyfastmail-mcp · 0 tokens

mem0-oss-to-platform

Plan and then execute a migration of a project from the mem0 open-source / self-hosted SDK (the local Memory class) to the mem0 Platform / hosted / managed SDK (the MemoryClient class). Use this whenever a developer wants to move, switch, or migrate their mem0 usage off OSS/self-hosted to the hosted API — e.g.…

mem0ai/mem0 · 273 tokens

agui-dotnet-protobuf

Use the protobuf wire transport (instead of the default Server-Sent Events) for an AG-UI connection with the AG-UI .NET SDK — a compact binary event stream negotiated via the Accept header. USE FOR: making an AGUIChatClient prefer protobuf by wiring an AGUIEventStreamHandler with ProtobufEventStreamFormatter (then…

ag-ui-protocol/ag-ui · 162 tokens

azure-mgmt-botservice-dotnet

Azure Resource Manager SDK for Bot Service in .NET. Management plane operations for creating and managing Azure Bot resources, channels (Teams, DirectLine, Slack), and connection settings. Triggers: "Bot Service", "BotResource", "Azure Bot", "DirectLine channel", "Teams channel", "bot management .NET", "create bot".

microsoft/skills · 78 tokens