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.
Prerequisites
Packages
@modelcontextprotocol/sdkzodResources 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
| Approach | Strengths | Tradeoffs |
|---|---|---|
| Standardized MCP Server | Write once; works across Claude, Cursor, Antigravity, and LangGraph | Requires strict schema & transport auth discipline |
| Ad-Hoc REST Wrappers | Quick for a single hardcoded client | Duplicated 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
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.