From 8820ff6e4e3d2312ad8f684f228a9f232ca927ad Mon Sep 17 00:00:00 2001 From: K4bain <296577378+K4bain@users.noreply.github.com> Date: Thu, 27 Aug 2026 21:20:10 +0500 Subject: [PATCH] fix(server): pass MCP description via instructions, not version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Server(name, self.description) passed the description as the second positional arg of mcp Server.__init__, which is version — so MCP clients saw the server description as its version and no instructions at all. Pass both explicitly: version from the FastAPI app version and description as instructions. Adopted from #317 (original patch by @syf2211). --- fastapi_mcp/server.py | 6 +++++- tests/test_basic_functionality.py | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/fastapi_mcp/server.py b/fastapi_mcp/server.py index bb751067..157acd8e 100644 --- a/fastapi_mcp/server.py +++ b/fastapi_mcp/server.py @@ -141,7 +141,11 @@ def setup_server(self) -> None: # Filter tools based on operation IDs and tags self.tools = self._filter_tools(all_tools, openapi_schema) - mcp_server: Server = Server(self.name, self.description) + mcp_server: Server = Server( + self.name, + version=self.fastapi.version, + instructions=self.description, + ) @mcp_server.list_tools() async def handle_list_tools() -> List[types.Tool]: diff --git a/tests/test_basic_functionality.py b/tests/test_basic_functionality.py index 3557226e..9123934b 100644 --- a/tests/test_basic_functionality.py +++ b/tests/test_basic_functionality.py @@ -19,6 +19,10 @@ def test_create_mcp_server(simple_fastapi_app: FastAPI): assert len(mcp.tools) > 0, "Should have extracted tools from the app" assert len(mcp.operation_map) > 0, "Should have operation mapping" + assert mcp.server.version == simple_fastapi_app.version + assert mcp.server.instructions == "Test description" + assert mcp.server.version != mcp.server.instructions + # Check that the operation map contains all expected operations from simple_app expected_operations = ["list_items", "get_item", "create_item", "update_item", "delete_item", "raise_error"] for op in expected_operations: