OAuth MCP proxy

OAuth 2.1 authentication library for Go MCP servers.

Supports both MCP SDKs:

  • ✅ mark3labs/mcp-go

  • ✅ modelcontextprotocol/go-sdk (official)

One-time setup: Configure provider + add WithOAuth() to your server. Result: All tools automatically protected with token validation and caching.

mark3labs/mcp-go

import "github.com/tuannvm/oauth-mcp-proxy/mark3labs"

oauthServer, oauthOption, _ := mark3labs.WithOAuth(mux, &oauth.Config{
    Provider: "okta",
    Issuer:   "https://your-company.okta.com",
    Audience: "api://your-mcp-server",
})

mcpServer := server.NewMCPServer("Server", "1.0.0", oauthOption)
streamable := server.NewStreamableHTTPServer(mcpServer, /*options*/)
mux.HandleFunc("/mcp", oauthServer.WrapMCPEndpoint(streamable))

Official SDK

GitHub Workflow Statusarrow-up-right Go Versionarrow-up-right Go Report Cardarrow-up-right Go Referencearrow-up-right GitHub Releasearrow-up-right License: MITarrow-up-right


Why Use This Library?

  • Dual SDK support - Works with both mark3labs and official SDKs

  • Simple integration - One WithOAuth() call protects all tools

  • Automatic 401 handling - RFC 6750 compliant error responses with OAuth discovery

  • Zero per-tool config - All tools automatically protected

  • Fast token caching - 5-min cache, <5ms validation

  • Production ready - Security hardened, battle-tested

  • Multiple providers - HMAC, Okta, Google, Azure AD


How It Works

Request Flow

spinner

Token Validation Flow

spinner

What oauth-mcp-proxy does:

  1. Extracts Bearer tokens from HTTP requests

  2. Validates against your OAuth provider (with caching)

  3. Adds authenticated user to request context

  4. All your tools automatically protected


Quick Start

Using mark3labs/mcp-go

1. Install

2. Add to Your Server

3. Access Authenticated User


Using Official SDK

1. Install

2. Add to Your Server

Your MCP server now requires OAuth authentication.


Examples

See examples/README.md for detailed setup guide including Okta configuration.

SDK
Example
Description

mark3labs

Minimal setup - copy/paste ready

mark3labs

ConfigBuilder, multiple tools, logging

Official

Minimal setup - copy/paste ready

Official

ConfigBuilder, multiple tools, logging


Supported Providers

Provider
Best For
Setup Guide

HMAC

Testing, development

Okta

Enterprise SSO

Google

Google Workspace

Azure AD

Microsoft 365


Documentation

Getting Started:

Advanced:


License

MIT License - See LICENSEarrow-up-right

Last updated

Was this helpful?