Session 13. Build and secure an MCP server — Wed 30 Sep

Conclusion

You built the part of an MCP server that says no: one read-only tool, one narrow argument, an allowlist a caller cannot widen, and fetch_guard(url) consulted before any socket opens.

What you did

The failures you handled

A URL that points inside. 169.254.169.254 hands out the instance's credentials, 2130706433 and 0x7f000001 are 127.0.0.1 written so that ip_address() shrugs, and all three are refused on the string.

And a redirect. Two allowed hops and then a 302 to the metadata address — the guard runs on every hop, or it ran on a URL that was never fetched.

Into session 14

Session 14 assumes this guard exists and asks the question this session left open: what it takes to deploy it, where DNS resolution and the rebinding window get closed, and what the caps around the fetch have to be.

Homework

Add an external tools section to your project instructions — allowed hosts, data handling, who approves what. Then say what your guard does on a redirect.