Coders In Hoods
  • Courses
  • Roles
  • Blog
  • Setup

Coders In Hoods AI Academy

Every course is free. Sign in to start, and your progress, quiz scores and bookmarks follow you.

AI Academy

  • Courses
  • Paths
  • Setup guides
  • How we teach

Role roadmaps

  • AI Engineer
  • Forward Deployed Engineer
  • Machine Learning Engineer
  • All roles

Coders In Hoods

  • The agency
  • Coaching for teams
  • Blog
  • LinkedIn
  • X (Twitter)

Contact

codersinhoods@gmail.com

© Coders In Hoods · since 2019

Course overview

Building MCP Servers

Free · sign in to start and track progress

1 · The protocol and its mental model

  • 1MCP and REST: two mental models
  • 2The protocol on the wire

2 · Designing servers agents use well

  • 3Designing tools, not endpoints
  • 4Testing and evaluating servers
  • 5Resources, prompts and asking for input

3 · Running servers in production

  • 6Remote servers and authorization

    Exercise answers

    • Answer: Serve the server over Streamable HTTP
    • Answer: Protect it as an OAuth resource server
  • 7Securing MCP servers
  • 8Shipping and evolving servers
CapstoneShip an MCP server for an existing REST APIReference implementation

Module 3 · Running servers in production · Lesson 6

Remote servers and authorization

Serve an MCP server over Streamable HTTP as a stateless OAuth resource server, with per-request instances, Host and Origin checks, protected resource metadata, and tokens checked for issuer, audience and scope before they are mapped to a user.

80 min 2 videos 3 exercises 7-question quiz Answers
Setup for the exercises:Install Claude CodeNode.js, pnpm and TypeScriptMCP servers in Claude CodeThe Larchmere Desk mock API

By the end of this lesson you can

  • Serve a server over Streamable HTTP with a per-request factory, and measure what statelessness costs and buys
  • Protect a locally bound HTTP server against DNS rebinding with Host and Origin validation
  • Trace MCP's authorization flow from a 401 challenge through protected resource metadata, client registration, PKCE and the issuer check to a bearer token
  • Verify an access token's signature, issuer, audience, expiry and scopes, and map its subject to a user without passing the token downstream
  • Connect Claude Code to a remote server, and list what a hosted Claude connector needs from one

On this page

  • From one process to one endpoint
  • What a per-request instance costs
  • Scaling out
  • Host and Origin: stopping DNS rebinding
  • Authorization: the server is a resource server
  • Discovery: from a 401 to an authorization server
  • How a client gets a token
  • Checking every token
  • Scopes and step-up
  • From token to staff member, and never further
  • Connecting hosts
  • Misconceptions and limits
  • Connections
  • Summary
  • Sources & further reading
  • Quiz

In this lesson

  1. 01From one process to one endpoint
  2. 02Host and Origin: stopping DNS rebinding
  3. 03Authorization: the server is a resource server
  4. 04Connecting hosts
  5. 05Misconceptions and limits
  6. 06Connections
  7. 07Summary

Sources & further reading

  • A First Measurement Study on Authentication Security in Real-World Remote MCP ServersPaper · Huijun Zhou, Xiaohan Zhang, Haozhe Zhang, Haoyang Zhang, Mi Zhang, Min Yang · 2026A recent preprint: 7,973 live remote servers, of which 40.55% expose tools without authentication, and a flaw taxonomy from 119 OAuth servers that all had at least one flaw. Read the taxonomy before you build or choose an authorization server.
  • Authorization (2026-07-28)Docs · Model Context Protocol · 2026The OAuth 2.1 profile this lesson follows. Read Roles, the flow diagram, Resource Parameter Implementation, Token Handling and Scope Challenge Handling; the Client Registration subpage covers client ID metadata documents and the deprecated dynamic registration.
  • Serve over HTTP (TypeScript SDK v2)Docs · Model Context ProtocolcreateMcpHandler, the per-request factory, mounting on Node with Host and Origin guards, and passing authInfo through. The Sessions, state, and scaling page next to it covers cross-node notifications.
  • Require authorization (TypeScript SDK v2)Docs · Model Context ProtocolrequireBearerAuth, the verifier you write, expectedResource, protected resource metadata, and per-tool scope challenges. The code in this lesson's exercises follows it.
  • RFC 9728: OAuth 2.0 Protected Resource MetadataDocs · M. Jones, P. Hunt, A. Parecki · IETF · 2025How a resource server tells clients which authorization servers it trusts, and the resource_metadata parameter of WWW-Authenticate. Sections 2, 3 and 5.
  • RFC 8707: Resource Indicators for OAuth 2.0Docs · B. Campbell, J. Bradley, H. Tschofenig · IETF · 2020The resource parameter that lets an authorization server put the MCP server in a token's audience. Short; read section 2.
  • Build an MCP server for ClaudeDocs · AnthropicWhat a real host expects from a remote server: transport, the authorization revisions it follows, the callback URL, supported features and the size and timeout limits.
Free · sign in to start

Sign in to keep reading.

Free, no card. We use your account to save progress, quiz scores, bookmarks and occasionally send updates from our team.

  • 7 more sections
  • 3 hands-on exercises
  • A 7-question quiz
  • Progress, quiz scores and bookmarks