Files
Vincenzo Reina 4997674559 feat(python): Intercept MCP handshake with on_initialize middleware (#769)
* Wrap server session from MCP

* Update server and middleware

* Update middleware example

* Fix formatting and linting

* Update docs

* Fix monkeypatch for tests

* Update docs and remove comment

* feat(python): add tests, docs, and docstrings for on_initialize middleware

- Add 13 unit tests covering dispatch, chain order, rejection, and context enrichment
- Rewrite middleware.mdx documentation with Mintlify components (Tabs, Tips, Cards)
- Add comprehensive docstring to MiddlewareServerSession documenting single-server-per-process limitation
- Add docs/CLAUDE.md with documentation improvement guidelines
- Regenerate API documentation

* docs: highlight typed context feature in middleware docs

* example: add ClientCapabilitiesGuard demonstrating typed context

* style: fix linting in middleware example

* docs(examples): add comprehensive docstrings to middleware_example.py

- Add module docstring explaining key concepts and middleware hooks
- Document each middleware class with typed context details
- Organize code with section headers (CONNECTION, REQUEST, TOOL-SPECIFIC)
- Add ClientCapabilitiesGuard example showing typed context usage

---------

Co-authored-by: pietrozullo <pietro.zullo@gmail.com>
2026-01-14 16:47:57 +01:00

9.1 KiB