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 <noreply@anthropic.com>
This commit is contained in:
2026-04-02 16:02:44 -04:00
parent 8a54daf3c9
commit 746b21fa4c
2 changed files with 11 additions and 9 deletions
+10 -8
View File
@@ -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: "):]
+1 -1
View File
@@ -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 = [