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
Files
- client.py (44 lines)
- run.py (17 lines)
- server.py (31 lines)
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.