Carry `capabilities.extensions` on legacy `initialize` handshakes

Merged
KL
25d ago
+58-22

Closes #3773.

On connections that negotiate 2025-11-25 or earlier, serialize_server_result("initialize", ...) sieves the result through the 2025 wire model, which has no extensions field, so a server could never advertise an extension (e.g. MCP Apps) to a legacy client.

  • scripts/gen_surface_types.py: add a schema patch that gives the 2025-11-25 ClientCapabilities/ServerCapabilities an optional extensions map, and regenerate _v2025_11_25. patch_schema now accepts old=None to mean "key absent".
  • Server.create_initialization_options no longer forwards self.extensions directly; get_capabilities already defaults to it and maps an empty dict to None, so servers without extensions still send no extensions key.
  • Flip the three "pinned gap" tests to assert the map survives a legacy handshake, add an initialize round-trip test per pre-2026 version, and update docs/advanced/extensions.md.

AI Disclaimer

This PR was developed with the assistance of either Claude or Codex. I've reviewed and verified the changes.