File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -600,7 +600,7 @@ async def run_stdio_async(self) -> None:
600600 read_stream ,
601601 write_stream ,
602602 self ._mcp_server .create_initialization_options (),
603- stateless = self .settings .stateless_stdio
603+ stateless = self .settings .stateless_stdio ,
604604 )
605605
606606 async def run_sse_async (self , mount_path : str | None = None ) -> None :
Original file line number Diff line number Diff line change 1+ from mcp .server .fastmcp import FastMCP
2+
3+ # Create FastMCP server
4+ mcp = FastMCP ("StatelessTest" )
5+
6+
7+ # Register a simple echo tool
8+ @mcp .tool ()
9+ def echo (message : str ) -> str :
10+ """Echo a message back to the client."""
11+ return f"Echo: { message } "
12+
13+
14+ if __name__ == "__main__" :
15+ # Run in STDIO mode
16+ mcp .run ()
Original file line number Diff line number Diff line change @@ -295,7 +295,8 @@ async def test_server_session_stateless_mode():
295295 await server_session ._received_request (responder )
296296 except RuntimeError as e :
297297 if "initialization" in str (e ).lower ():
298- pytest .fail (f"Unexpected initialization error in stateless mode: { e } " )
298+ msg = f"Unexpected initialization error in stateless mode: { e } "
299+ pytest .fail (msg )
299300 finally :
300301 # Clean up the streams to prevent ResourceWarning
301302 await server_to_client_send .aclose ()
Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ async def test_stateless_stdio():
7979 """Test that stateless stdio mode allows tool calls without initialization."""
8080 with tempfile .TemporaryDirectory () as temp_dir :
8181 server_path = Path (temp_dir ) / "server.py"
82-
82+
8383 with open (server_path , "w" ) as f :
8484 f .write ("""
8585from mcp.server.fastmcp import FastMCP
You can’t perform that action at this time.
0 commit comments