convez.ai
MCP ServerSegurançaAvançado
Smeldr

Servidor OAuth 2.1 para MCP Remoto

Smeldr/oauth

OAuth 2.1 authorization server para MCP remoto com PKCE e refresh tokens

Ver no GitHub
InicialPluginScore · de 0 a 100

Biblioteca Go que implementa um servidor OAuth 2.1 compliant para autorizar MCP servers remotos. Suporta PKCE obrigatório, refresh tokens e validação stateless de clientes via CIMD, permitindo que ChatGPT Plus e Claude.ai conectem a servidores MCP com segurança.

Instalação

$npx convez-ai Smeldr/oauth

1 comando no terminal: detecta o formato do repositório (marketplace ou plugin avulso) e instala via Claude Code. Requer Node 18+ e o Claude Code instalado.

Métricas

Estrelas
0
Forks
0
Acompanhando
0
Saúde
50%
Último commit
há 3 dias
Versão
v0.7.0
Issues abertas
0
Contribuidores
1

Casos de uso

  • Autenticar MCP servers remotos em ChatGPT Plus ou Claude.ai
  • Implementar fluxo OAuth 2.1 em aplicações Go sem banco de dados de clientes
  • Integrar serviços com validação stateless de credenciais via CIMD

Veredito

Implementação sólida de OAuth 2.1 moderno (draft-15) em Go, com PKCE obrigatório e suporte a refresh tokens. Ideal para integrar MCP servers remotos com APIs de IA, mas requer conhecimento profundo de fluxos OAuth e configuração de infraestrutura.

README

A tradução para o português deste README ainda está na fila.

smeldr.dev/oauth

OAuth 2.1 authorization server for remote MCP servers.

Go Reference v0.2.0 — MIT license.


smeldr.dev/oauth is a standalone Go library that implements an OAuth 2.1 authorization server for use with remote Model Context Protocol servers. ChatGPT Plus and Claude.ai require OAuth 2.1 to connect to remote MCP servers; smeldr.dev/oauth provides the server-side implementation.

Standards

  • OAuth 2.1 (draft-15): PKCE mandatory, no implicit flow, no ROPC
  • RFC 8414: Authorization Server Metadata
  • RFC 9728: Protected Resource Metadata (via smeldr.dev/mcp)
  • CIMD: Client ID Metadata Documents — stateless client validation

Features

  • Stateless client validation via CIMD (no client registration database)
  • PKCE S256 — mandatory for all authorization requests
  • Refresh tokens via offline_access scope (required for ChatGPT)
  • HTML authorization form — user pastes their Smeldr bearer token
  • SQLite storage out of the box (modernc.org/sqlite — no CGO)
  • slog-based structured logging

Installation

go get smeldr.dev/oauth

Requires Go 1.26.3+.

Migrating from v0.1.x

The package was renamed from forgeoauth to oauth in v0.2.0. Replace forgeoauth.X → oauth.X at all call sites (or drop the alias: import "smeldr.dev/oauth").

Quick start

import (
    "log"
    "net/http"

    "smeldr.dev/core"
    "smeldr.dev/oauth"
    forgemcp "smeldr.dev/mcp"
)

func main() {
    app := smeldr.New(smeldr.Config{...})

    store, err := oauth.NewSQLiteStore("./oauth.db")
    if err != nil {
        log.Fatal(err)
    }

    oauthSrv := oauth.New(oauth.Config{
        Issuer: "https://cms.example.com",
        VerifyBearer: func(token string) bool {
            // Validate Smeldr bearer token using smeldr.VerifyTokenString (v1.25.0+).
            _, ok := smeldr.VerifyTokenString(token, app.Secret(), app.TokenStore())
            return ok
        },
    }, store)

    mcpSrv := forgemcp.New(app, forgemcp.WithOAuth(oauthSrv))
    http.ListenAndServe(":8080", mcpSrv.Handler())
}

Endpoints

MethodPathDescription
GET/.well-known/oauth-authorization-serverRFC 8414 metadata
GET/oauth/authorizeAuthorization form
POST/oauth/authorizeForm submission
POST/oauth/tokenCode exchange and token refresh

ChatGPT / ngrok runbook

To test end-to-end with ChatGPT Plus:

  1. Install ngrok: winget install ngrok.ngrok
  2. Configure: ngrok config add-authtoken <your-token>
  3. Start your Smeldr + MCP server locally on port 8080
  4. Run ngrok http 8080 — note the HTTPS URL (e.g. https://abc123.ngrok-free.app)
  5. Set Issuer: "https://abc123.ngrok-free.app" in oauth.Config
  6. Restart the server with the ngrok URL
  7. In ChatGPT Plus: Settings → Connected Apps → Add → paste the ngrok HTTPS URL
  8. ChatGPT triggers the OAuth flow → browser opens the authorization form
  9. Paste your Smeldr bearer token → click Approve
  10. ChatGPT receives an access token and can call MCP tools (e.g. list_posts)

Storage

Three SQLite tables are created automatically by NewSQLiteStore:

TablePurpose
forge_oauth_codesShort-lived authorization codes (5 min default)
forge_oauth_tokensAccess tokens (1 hour default)
forge_oauth_refresh_tokensRefresh tokens (no expiry in v1)

License

MIT — see LICENSE.

Part of the Smeldr ecosystem.

Ver o original no GitHub

Bom para

Relacionados