π The fast, Pythonic way to build MCP servers and clients.
Advertise the same list_changed capabilities over stdio as other transports (#5311)
Asem ahmeda92e6bd5c343
diff --git a/fastmcp_slim/fastmcp/server/mixins/transport.py b/fastmcp_slim/fastmcp/server/mixins/transport.pyindex 4e098727c..75483d1b6 100644--- a/fastmcp_slim/fastmcp/server/mixins/transport.py+++ b/fastmcp_slim/fastmcp/server/mixins/transport.py@@ -9,7 +9,6 @@ from typing import TYPE_CHECKING, Any, Literalimport anyioimport uvicorn-from mcp.server.lowlevel.server import NotificationOptionsfrom mcp.server.stdio import stdio_serverfrom mcp.server.streamable_http import EventStorefrom starlette.middleware import Middleware as ASGIMiddleware@@ -246,11 +245,7 @@ class TransportMixin:await self._mcp_server.run(read_stream,write_stream,- self._mcp_server.create_initialization_options(- notification_options=NotificationOptions(- tools_changed=True- ),- ),+ self._mcp_server.create_initialization_options(),)finally:reset_transport(token)diff --git a/tests/client/test_stdio.py b/tests/client/test_stdio.pyindex 8749fdac2..4af92be94 100644--- a/tests/client/test_stdio.py+++ b/tests/client/test_stdio.py@@ -230,6 +230,31 @@ class TestParallelCalls:assert len(errors) == 0+class TestAdvertisedCapabilities:+ async def test_stdio_advertises_list_changed_for_all_components(self, tmp_path):+ """stdio advertises the same list_changed capabilities as other transports."""+ script = tmp_path / "server.py"+ script.write_text(+ "from fastmcp import FastMCP\n"+ "mcp = FastMCP()\n"+ "mcp.run(show_banner=False)\n",+ encoding="utf-8",+ )++ client = Client(PythonStdioTransport(script_path=script), mode="legacy")+ async with client:+ assert client.initialize_result is not None+ capabilities = client.initialize_result.capabilities++ assert capabilities.tools is not None+ assert capabilities.tools.list_changed is True+ assert capabilities.resources is not None+ assert capabilities.resources.list_changed is True+ assert capabilities.prompts is not None+ assert capabilities.prompts.list_changed is True++@pytest.mark.timeout(15)class TestKeepAlive:# https://github.com/PrefectHQ/fastmcp/issues/581