Go library only. The TypeScript OAuth 2.1 server (
createMcpModule) takes storage callbacks you write, see MCP OAuth 2.1. The full Go guide is go/docs/mcp-oauth-sqlite.md, and the store is documented in SQLite storage.1
Register a public client
Registration is closed unless configured. The client sends the user to/oauth/authorize with code_challenge_method=S256 and resource, then exchanges the code at /oauth/token.2
Open the database and build the server
You own the*sql.DB, so set the pragmas. New refuses a database without foreign keys. The busy timeout and immediate transactions make concurrent token requests wait, not fail with database is locked.Migrate applies migrations 0001 to 0034. The OAuth tables start at 0020.3
Protect the MCP routes
mcpresource checks the bearer token on each request against the endpoints above. A request without a token gets a 401 that names the protected resource metadata URL. A token without the scope gets a 403 insufficient_scope.4
Serve the well-known paths
The OAuth routes sit at the root of the handler you mount. If the issuer has a path, RFC 8414 and RFC 9728 clients request the well-known document under the origin root. Forward/.well-known/ as well, or those URLs return 404.What is enforced
mcpresource is a separate module and can run in another process. Check module versions in the Go docs before you copy imports.