1
+ import logging
1
2
from collections .abc import Awaitable , Callable
2
3
from datetime import timedelta
3
- import logging
4
4
from typing import Any , Protocol , TypeAlias
5
5
6
6
import anyio .lowlevel
14
14
from mcp .shared .session import BaseSession , ProgressFnT , RequestResponder
15
15
from mcp .shared .version import SUPPORTED_PROTOCOL_VERSIONS
16
16
17
-
18
17
logger = logging .getLogger (__name__ )
19
18
20
19
DEFAULT_CLIENT_INFO = types .Implementation (name = "mcp" , version = "0.1.0" )
21
20
21
+
22
22
class SamplingFnT (Protocol ):
23
23
async def __call__ (
24
24
self ,
@@ -451,6 +451,13 @@ async def _received_notification(
451
451
pass
452
452
453
453
454
+ class NoOpToolOutputValidator (ToolOutputValidationFnT ):
455
+ async def __call__ (
456
+ self , request : types .CallToolRequest , result : types .CallToolResult
457
+ ) -> bool :
458
+ return True
459
+
460
+
454
461
class SimpleCachingToolOutputValidator (ToolOutputValidationFnT ):
455
462
_schema_cache : dict [str , dict [str , Any ] | bool ]
456
463
@@ -475,7 +482,7 @@ async def __call__(
475
482
raise RuntimeError (f"Unknown tool { request .params .name } " )
476
483
elif schema is False :
477
484
# no schema
478
- logging .debug (' No schema found checking structuredContent is empty' )
485
+ logging .debug (" No schema found checking structuredContent is empty" )
479
486
return result .structuredContent is None
480
487
else :
481
488
try :
@@ -490,6 +497,7 @@ async def __call__(
490
497
async def _refresh_schema_cache (self ):
491
498
cursor = None
492
499
first = True
500
+ self ._schema_cache = {}
493
501
while first or cursor is not None :
494
502
first = False
495
503
tools_result = await self ._session .list_tools (cursor )
0 commit comments