From 0c9fd7c48278211fa7d753e56541242e8b775481 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Sat, 18 Jan 2025 17:43:35 +0100 Subject: [PATCH] Fix DeprecationWarnings in mcp_server (#135927) * Fix DeprecationWarnings in mcp_server * Spelling --- homeassistant/components/mcp_server/http.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/mcp_server/http.py b/homeassistant/components/mcp_server/http.py index da706d4a73b..433d978cef7 100644 --- a/homeassistant/components/mcp_server/http.py +++ b/homeassistant/components/mcp_server/http.py @@ -1,4 +1,4 @@ -"""Model Context Protocol transport portocol for Server Sent Events (SSE). +"""Model Context Protocol transport protocol for Server Sent Events (SSE). This registers HTTP endpoints that supports SSE as a transport layer for the Model Context Protocol. There are two HTTP endpoints: @@ -62,9 +62,9 @@ def async_get_config_entry(hass: HomeAssistant) -> MCPServerConfigEntry: if config_entry.state == ConfigEntryState.LOADED ] if not config_entries: - raise HTTPNotFound(body="Model Context Protocol server is not configured") + raise HTTPNotFound(text="Model Context Protocol server is not configured") if len(config_entries) > 1: - raise HTTPNotFound(body="Found multiple Model Context Protocol configurations") + raise HTTPNotFound(text="Found multiple Model Context Protocol configurations") return config_entries[0] @@ -147,7 +147,7 @@ class ModelContextProtocolMessagesView(HomeAssistantView): """Process incoming messages for the Model Context Protocol. The request passes a session ID which is used to identify the original - SSE connection. This view parses incoming messagess from the transport + SSE connection. This view parses incoming messages from the transport layer then writes them to the MCP server stream for the session. """ hass = request.app[KEY_HASS] @@ -156,14 +156,14 @@ class ModelContextProtocolMessagesView(HomeAssistantView): session_manager = config_entry.runtime_data if (session := session_manager.get(session_id)) is None: _LOGGER.info("Could not find session ID: '%s'", session_id) - raise HTTPNotFound(body=f"Could not find session ID '{session_id}'") + raise HTTPNotFound(text=f"Could not find session ID '{session_id}'") json_data = await request.json() try: message = types.JSONRPCMessage.model_validate(json_data) except ValueError as err: _LOGGER.info("Failed to parse message: %s", err) - raise HTTPBadRequest(body="Could not parse message") from err + raise HTTPBadRequest(text="Could not parse message") from err _LOGGER.debug("Received client message: %s", message) await session.read_stream_writer.send(message)