@@ -98,17 +98,17 @@ async def session_lifespan(mcp: FastMCP) -> AsyncIterator[None]:
9898
9999 with warnings .catch_warnings (record = True ) as w :
100100 warnings .simplefilter ("always" )
101- _ = FastMCP (name = "TestServer" , session_lifespan = session_lifespan )
101+ _ = FastMCP (name = "TestServer" , lifespan = session_lifespan )
102102
103103 # Should have emitted a deprecation warning
104104 assert len (w ) == 1
105105 assert issubclass (w [0 ].category , DeprecationWarning )
106- assert "session_lifespan parameter is deprecated" in str (w [0 ].message )
107- assert "use the lifespan parameter instead" in str (w [0 ].message )
106+ assert "lifespan parameter is deprecated" in str (w [0 ].message )
107+ assert "use the session_lifespan parameter instead" in str (w [0 ].message )
108108
109- async def test_session_lifespan_still_works (self ):
109+ async def test_lifespan_still_works (self ):
110110 """Test that session_lifespan still functions despite deprecation."""
111- session_events = []
111+ session_events : list [ str ] = []
112112
113113 @asynccontextmanager
114114 async def session_lifespan (mcp : FastMCP ) -> AsyncIterator [None ]:
@@ -118,7 +118,7 @@ async def session_lifespan(mcp: FastMCP) -> AsyncIterator[None]:
118118
119119 with warnings .catch_warnings ():
120120 warnings .simplefilter ("ignore" )
121- mcp = FastMCP ("TestServer" , session_lifespan = session_lifespan )
121+ mcp = FastMCP ("TestServer" , lifespan = session_lifespan )
122122
123123 @mcp .tool
124124 def test_tool () -> str :
@@ -183,7 +183,8 @@ async def server_lifespan(mcp: FastMCP) -> AsyncIterator[None]:
183183 yield
184184
185185 with pytest .raises (
186- ValueError , match = "Cannot specify both session_lifespan and server_lifespan"
186+ expected_exception = ValueError ,
187+ match = "Cannot specify both" ,
187188 ):
188189 _ = FastMCP (
189190 name = "TestServer" ,
@@ -200,15 +201,15 @@ async def my_lifespan(mcp: FastMCP) -> AsyncIterator[None]:
200201
201202 with pytest .raises (
202203 expected_exception = ValueError ,
203- match = "Cannot specify both session_lifespan and server_lifespan " ,
204+ match = "Cannot specify both" ,
204205 ):
205206 _ = FastMCP (
206207 name = "TestServer" , lifespan = my_lifespan , server_lifespan = my_lifespan
207208 )
208209
209210 with pytest .raises (
210211 expected_exception = ValueError ,
211- match = "Cannot specify both session_lifespan and server_lifespan " ,
212+ match = "Cannot specify both" ,
212213 ):
213214 _ = FastMCP (
214215 name = "TestServer" ,
0 commit comments