main
py 24 lines 731 Bytes
Raw
1 """Small extension contracts for a later distributed resilience layer."""
2 from __future__ import annotations
3
4 from typing import Protocol
5
6 from app.contracts import McpAuthContext
7
8
9 class McpRateLimiter(Protocol):
10 """Authorize a call using a future shared/distributed rate-limit backend."""
11
12 async def authorize(
13 self, *, tool: str, auth: McpAuthContext, request_id: str
14 ) -> None: ...
15
16
17 class McpCircuitBreaker(Protocol):
18 """Track downstream health without prescribing an in-process implementation."""
19
20 async def before_call(self, *, dependency: str) -> None: ...
21
22 async def record_success(self, *, dependency: str) -> None: ...
23
24 async def record_failure(self, *, dependency: str) -> None: ...