Dayward AIWeChat Mini Program
MCP in 7 Days: Wire Tools Into Any Agent
Week 1 · D4🔒 LockedAbout 6 hours

Remote MCP: the Streamable HTTP Binding, the Stateless Model and Request Metadata, OAuth 2.1 Authorization, Container Deployment

Move a server from a local subprocess onto the public internet: one POST endpoint, two response shapes, one set of required headers, plus OAuth 2.1 audience validation and a container deployment that can scale out.

Today's goals 0/3

Sign in to tick these off and save your progress.

Today's Goals

  1. Implement a Streamable HTTP server with a single POST endpoint that returns JSON or an event stream as needed
  2. State how a client must change now that sessions, the GET stream, and stream resumption are gone in this version
  3. Explain the token audience validation an MCP server must do as a protected resource, and what happens if it doesn't

For three days your server lived locally, launched by the host as a child process, taking credentials from environment variables, with nobody able to touch it from outside. Today it moves onto the public internet — a step that pushes three questions in front of you at once: who may connect, whose account this counts against, and what happens when it dies. Come back and tick off the three goals above.

Plain-Language Walkthrough

From a cable run across the room to joining the public grid

stdio is a cable you ran across the room: both ends are in your house, the plug shape is yours to decide, and nobody comes to steal power. Streamable HTTP is joining the public grid: voltage, frequency, and socket standard all follow the public specification, because you do not know who is at the other end of the line.

Four classes of problem appear, each with a corresponding hard requirement.

The first is who is knocking. Any web page in a browser can send a request to http://127.0.0.1:3034, which is the entry point for a DNS rebinding attack: an attacker controls a domain, resolves it to their own server first to pass the origin check, then re-resolves it to 127.0.0.1, and your local file-reading MCP server is taken over by a stranger's page. The spec is hard here: a server must validate the Origin header and must return 403 when it is present and invalid. When running locally it should also bind only the loopback address 127.0.0.1 rather than 0.0.0.0 — plenty of people habitually write 0.0.0.0 inside containers and carry the habit back to bare metal.

The second is whose account this counts against. Under stdio a server naturally serves one user; on the public internet one endpoint faces thousands. The spec is blunt: all connections should implement authentication. The specifics come in the OAuth section below.

The third is how many of me there are. Locally there is always one process; on the internet you run three or five replicas and a request must be handleable wherever it lands. That one is the stateless protocol's biggest dividend, and the last section works out the arithmetic.

The fourth is when it counts as finished. A local call returns in milliseconds, while a tool taking thirty seconds is normal on the internet, and during that time the connection sits idle with the user unable to tell computing from dead.

The first is solved by one line of validation, and the rest all start from the transport layer's shape. So what does this endpoint actually look like?

Sign in and link WeChat to read

Sign in, then link your WeChat mini program account on the account page. Linked accounts share one free article per day. Unlock additional articles with rewarded videos in the mini program.

Mini program QR code

Scan in WeChat to open Dayward AI. Open the same course and chapter, choose the rewarded video, then refresh this page after completion.

Interview questions

  • The 2026-07-28 revision removed protocol-level sessions. How should a remote server that needs cross-call state — a shopping cart, a database transaction — be designed?2026-07-28 去掉了协议级会话。那一个需要跨调用保存状态的远程服务端——比如购物车、数据库事务——应该怎么设计?
    Common in ChinaCommon overseasIntermediate#statelessness#api-design

    🔒 Unlock this chapter to see the answer keys.

  • Streamable HTTP requires the Mcp-Method header to match the method in the request body. Why mirror it at all, and what breaks if the server does not validate the match?Streamable HTTP 要求 Mcp-Method 头必须和请求体里的 method 一致。为什么要抄一遍?不校验会有什么风险?
    Common in ChinaCommon overseasIntermediate#transport#security

    🔒 Unlock this chapter to see the answer keys.

  • Why must an MCP server never forward the client's access token straight to a downstream API?为什么 MCP 服务端绝对不能把客户端给的访问令牌直接转发给下游 API?
    Common in ChinaCommon overseasDeep dive#oauth#security

    🔒 Unlock this chapter to see the answer keys.

Comments