From 746b21fa4c49664529da0b4b6838e25cf73c13e8 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Thu, 2 Apr 2026 16:02:44 -0400 Subject: [PATCH] fix(fable-mcp): fix send_message to use correct two-step API flow POST .../messages to start generation, then stream from .../generation/stream. The previous implementation used a non-existent /stream endpoint. Co-Authored-By: Claude Sonnet 4.6 --- fable-mcp/fable_mcp/tools/chat.py | 18 ++++++++++-------- fable-mcp/pyproject.toml | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/fable-mcp/fable_mcp/tools/chat.py b/fable-mcp/fable_mcp/tools/chat.py index 89ff44c..740fda4 100644 --- a/fable-mcp/fable_mcp/tools/chat.py +++ b/fable-mcp/fable_mcp/tools/chat.py @@ -28,7 +28,8 @@ async def send_message( """Send a message to Fable and return the full assistant response. Creates a new MCP conversation if conversation_id is None. - Streams the SSE response and accumulates token chunks into a single string. + Posts the user message to start generation, then streams the SSE buffer + and accumulates token chunks into a single string. Returns: Dict with: @@ -41,18 +42,19 @@ async def send_message( "/api/chat/conversations", json={"conversation_type": "mcp"}, ) - conversation_id = conv["id"] + conversation_id = str(conv["id"]) - # Build SSE stream URL with message as query param - params: dict[str, Any] = {"message": message} - if think: - params["think"] = "true" + # Start generation + await client.post( + f"/api/chat/conversations/{conversation_id}/messages", + json={"content": message, "think": think}, + ) tokens: list[str] = [] tool_calls: list[Any] = [] - stream_path = f"/api/chat/conversations/{conversation_id}/stream" - async for raw_line in client.stream_get(stream_path, params=params): + stream_path = f"/api/chat/conversations/{conversation_id}/generation/stream" + async for raw_line in client.stream_get(stream_path): if not raw_line.startswith("data: "): continue payload_str = raw_line[len("data: "):] diff --git a/fable-mcp/pyproject.toml b/fable-mcp/pyproject.toml index 963e89d..14e3020 100644 --- a/fable-mcp/pyproject.toml +++ b/fable-mcp/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "fable-mcp" -version = "0.2.1" +version = "0.2.2" description = "MCP server for Fabled Assistant" requires-python = ">=3.12" dependencies = [