Summary
When using the MCP Streamable HTTP transport (POST /mcp), tool calls (tools/call) consistently return HTTP 200 with an empty response body on newly-initialized sessions. The JSON-RPC result is never delivered. Sessions appear stuck — no data arrives on either the POST response body or the GET SSE channel.
Environment
- Logseq DB version (desktop app, macOS)
- MCP server enabled via Settings → AI → MCP Server
- Client: raw Python HTTP (socket-level), also reproduced with curl
Steps to Reproduce
import socket, json
HOST, PORT, TOKEN = "127.0.0.1", 12315, "<your-token>"
def post(path, body_dict, sid=None):
body = json.dumps(body_dict).encode()
h = [f"POST {path} HTTP/1.1", f"Host: {HOST}:{PORT}",
f"Authorization: Bearer {TOKEN}",
"Content-Type: application/json",
"Accept: application/json, text/event-stream",
f"Content-Length: {len(body)}"]
if sid: h.append(f"Mcp-Session-Id: {sid}")
return ("\r\n".join(h) + "\r\n\r\n").encode() + body
# Step 1: initialize
s = socket.socket(); s.connect((HOST, PORT))
s.sendall(post("/mcp", {"jsonrpc":"2.0","id":1,"method":"initialize",
"params":{"protocolVersion":"2024-11-05","capabilities":{},
"clientInfo":{"name":"test","version":"1.0"}}}))
s.settimeout(0.5)
buf = b""
while True:
try: c = s.recv(4096); buf += c if c else b"";
except: break
s.close()
# Extract session ID from mcp-session-id header
sid = next(l.split(":",1)[1].strip() for l in buf.decode().split("\r\n")
if l.lower().startswith("mcp-session-id:"))
print(f"SID: {sid}")
# NOTE: initialize response body is EMPTY — session ID is headers-only ✓
# Step 2: tool call
s2 = socket.socket(); s2.connect((HOST, PORT))
s2.sendall(post("/mcp", {"jsonrpc":"2.0","id":2,"method":"tools/call",
"params":{"name":"getPage","arguments":{"pageName":"some-existing-page"}}}, sid=sid))
s2.settimeout(15)
raw = b""
import time; deadline = time.time() + 15
while time.time() < deadline:
try: c = s2.recv(8192); raw += c if c else b""
except: pass
s2.close()
print(f"Response: {len(raw)} bytes")
print(repr(raw)) # Only HTTP headers, no body
Expected: Response body contains event: message\ndata: {"result": ...}\n\n
Actual: Response is HTTP headers only (220 bytes), no body, even after 15 seconds.
What Does Work
The tool call response body IS delivered intermittently — specifically, sessions appear to work reliably when established immediately after a graph finishes loading. We observed one successful response (6927 bytes, containing full getPage results) right after opening a graph, but subsequent calls on newly-initialized sessions returned empty bodies.
The GET SSE channel (persistent GET /mcp connection) also receives no data for tool call responses.
Workaround
Reusing a session ID from a session that successfully received responses continues to work across process restarts. This suggests the session is being registered correctly but tool call responses are not being routed to new sessions under some conditions.
Additional Notes
- The legacy HTTP API at
POST /api with {"method": "logseq.Editor.methodName", "args": [...]} works correctly and synchronously. This is the workaround we are currently using for mutations.
initialize response with empty body + session ID in header is consistent with MCP Streamable HTTP spec and is not itself a bug.
- Verified with MCP protocol version
2024-11-05.
Would be happy to provide additional reproduction details or logs if helpful.
Summary
When using the MCP Streamable HTTP transport (
POST /mcp), tool calls (tools/call) consistently return HTTP 200 with an empty response body on newly-initialized sessions. The JSON-RPC result is never delivered. Sessions appear stuck — no data arrives on either the POST response body or the GET SSE channel.Environment
Steps to Reproduce
Expected: Response body contains
event: message\ndata: {"result": ...}\n\nActual: Response is HTTP headers only (220 bytes), no body, even after 15 seconds.
What Does Work
The tool call response body IS delivered intermittently — specifically, sessions appear to work reliably when established immediately after a graph finishes loading. We observed one successful response (6927 bytes, containing full
getPageresults) right after opening a graph, but subsequent calls on newly-initialized sessions returned empty bodies.The GET SSE channel (persistent
GET /mcpconnection) also receives no data for tool call responses.Workaround
Reusing a session ID from a session that successfully received responses continues to work across process restarts. This suggests the session is being registered correctly but tool call responses are not being routed to new sessions under some conditions.
Additional Notes
POST /apiwith{"method": "logseq.Editor.methodName", "args": [...]}works correctly and synchronously. This is the workaround we are currently using for mutations.initializeresponse with empty body + session ID in header is consistent with MCP Streamable HTTP spec and is not itself a bug.2024-11-05.Would be happy to provide additional reproduction details or logs if helpful.