MCPcopy Create free account
hub / github.com/anthropics/anthropic-sdk-python / AsyncCallableMiddleware

Class AsyncCallableMiddleware

tests/test_middleware.py:291–299  ·  view source on GitHub ↗

A middleware object that is a class instance with an async `__call__` method.

Source from the content-addressed store, hash-verified

289
290
291class AsyncCallableMiddleware:
292 """A middleware object that is a class instance with an async `__call__` method."""
293
294 def __init__(self) -> None:
295 self.requests: list[APIRequest] = []
296
297 async def __call__(self, request: APIRequest, call_next: AsyncCallNext) -> Any:
298 self.requests.append(request)
299 return await call_next(request)
300
301
302class SyncCallableMiddleware:

Calls

no outgoing calls