Back to Learning Hub
Reliable AI agentsbuild Last tested 2026-11-27

How do I build a production MCP server with OAuth?

Worked Answer

Expose read-only data as MCP Resources, validate every Tool argument with strict JSON Schema, use Streamable HTTP for remote deployments, and bind each session to a scoped OAuth 2.1 token rather than a shared admin key.

Architect a Model Context Protocol (MCP) server in Go or TypeScript with separate read Resources and side-effecting Tools, Streamable HTTP transport, and per-tenant OAuth 2.1.

Packages

@modelcontextprotocol/sdkzod

Resources vs. Tools boundary

Keep read-only context (SQL views, docs, schemas) in MCP Resources and mutating actions (create ticket, send email) in MCP Tools with explicit per-tenant OAuth scopes and audit logging.

MCP Server vs. Custom Function Wrappers

ApproachStrengthsTradeoffs
Standardized MCP ServerWrite once; works across Claude, Cursor, Antigravity, and LangGraphRequires strict schema & transport auth discipline
Ad-Hoc REST WrappersQuick for a single hardcoded clientDuplicated glue code for every new model or IDE
Checkpoint

Why should remote multi-tenant MCP servers avoid a single shared admin API key?

Production Evidence & Architecture Guides

Official Sources

Next Lesson
When should an AI backend pair Go with Rust?

Want this architecture built for your team?

Fixed-scope engineering sprints for databases, AI agents, and production retrieval.

Mugesh Rao
AI Engineer & Full Stack Engineer