2 Commits

Author SHA1 Message Date
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
Pietro Zullo ebef017114 python/server/middleware&tel (#650)
* chore: add example server pretty print JSON RPC for transparency

* updated telemetry module

* chore: agent side tel - langchain adapter - client tel

* server side tel:

* update API reference

* python transports and primitive reports are publishes only if not skipped

* remove wrongly generate files

* properly typed middleware

* remove examples

* feat(docs): add middleware and session management documentation

- Introduced new documentation for middleware, detailing hooks, minimal examples, and best practices for integrating middleware in MCP servers.
- Added a session management guide explaining session ID handling, usage patterns, and examples for managing per-client state in MCP servers.
- Updated  to include links to the new middleware and session management pages.

* generate docs

* remove few events

* adapter tel

* adapter tel

* api ref docs update

* google adapter fix

* fix version

* fix event naming

* server example is streamable and echo tool fix

* removed initialize middleware hook, initialize requests are not passed thorugh normal handlers

* api ref

* beta on middleware
2025-12-10 17:02:08 +01:00