File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -110,7 +110,10 @@ def get_entity_filter_type(entity: Any) -> Optional[str]:
110110TELEGRAM_API_ID = int (os .getenv ("TELEGRAM_API_ID" ))
111111TELEGRAM_API_HASH = os .getenv ("TELEGRAM_API_HASH" )
112112
113- mcp = FastMCP ("telegram" )
113+ # The shared HTTP service can be consumed by long-lived MCP clients. Stateless requests keep
114+ # those clients usable across server-process restarts instead of rejecting their next call
115+ # with "No valid session ID provided". Stdio transport remains unaffected.
116+ mcp = FastMCP ("telegram" , stateless_http = True )
114117
115118# Annotate all tool results with audience=["user"] so MCP clients know
116119# the content is user-generated data, not instructions for the model.
Original file line number Diff line number Diff line change @@ -43,6 +43,11 @@ def write_tool():
4343 return server
4444
4545
46+ def test_shared_server_uses_stateless_http_transport ():
47+ """A service restart must not invalidate long-lived Streamable HTTP clients."""
48+ assert runtime .mcp .settings .stateless_http is True
49+
50+
4651def test_get_exposed_tools_mode_defaults_to_all (monkeypatch ):
4752 monkeypatch .delenv ("TELEGRAM_EXPOSED_TOOLS" , raising = False )
4853
You can’t perform that action at this time.
0 commit comments