learning-it by example

Back to the video

MCP Over HTTP: Remote Servers and a Token Check

An MCP server on a network with no check answers anyone who can reach it, so I added a token check.

Video #30 ยท AI agents and MCP

Steps in the video

  1. 0:00 A network MCP server with no check
  2. 0:33 The idea
  3. 1:13 Setup
  4. 1:37 The server
  5. 2:09 The client
  6. 2:39 Run it
  7. 3:17 What this does not show
  8. 3:50 Mistakes to avoid
  9. 4:17 My take and next steps
  10. 4:46 Recap

Files

  • client.py (44 lines)
  • run.py (17 lines)
  • server.py (31 lines)

Download the code (zip)

Tested with

Python 3.12.15 | mcp==2.3.0

What this does not show

The tokens are two made-up fixed strings that never expire. There is no authorisation server, no OAuth flow, no audience check, no HTTPS, and no test of scopes or of the Origin header check. Everything ran on the loopback address of one laptop.

Sources

Learning IT by Example.