@@ -76,7 +76,10 @@ async def __call__(self, *args, **kwargs):
7676 GetPromptRequest = None
7777 ReadResourceRequest = None
7878
79- from fastmcp import __version__ as FASTMCP_VERSION
79+ try :
80+ from fastmcp import __version__ as FASTMCP_VERSION
81+ except ImportError :
82+ FASTMCP_VERSION = None
8083
8184# Collect available FastMCP implementations for parametrization
8285fastmcp_implementations = []
@@ -392,7 +395,11 @@ async def multiply_numbers(x: int, y: int) -> dict:
392395 request_id = "req-456" ,
393396 )
394397
395- if isinstance (mcp , StandaloneFastMCP ) and FASTMCP_VERSION .startswith ("2" ):
398+ if (
399+ isinstance (mcp , StandaloneFastMCP )
400+ and FASTMCP_VERSION is not None
401+ and FASTMCP_VERSION .startswith ("2" )
402+ ):
396403 assert result .json ()["result" ]["structuredContent" ] == {
397404 "result" : 42 ,
398405 "operation" : "multiplication" ,
@@ -1003,7 +1010,11 @@ def http_tool(data: str) -> dict:
10031010 },
10041011 )
10051012
1006- if isinstance (mcp , StandaloneFastMCP ) and FASTMCP_VERSION .startswith ("2" ):
1013+ if (
1014+ isinstance (mcp , StandaloneFastMCP )
1015+ and FASTMCP_VERSION is not None
1016+ and FASTMCP_VERSION .startswith ("2" )
1017+ ):
10071018 assert result .json ()["result" ]["structuredContent" ] == {"processed" : "TEST" }
10081019 elif isinstance (mcp , StandaloneFastMCP ):
10091020 assert result .json ()["result" ]["content" ][0 ]["text" ] == json .dumps (
0 commit comments