@josephyan/qingflow-app-user-mcp 0.2.0-beta.43 → 0.2.0-beta.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -3,13 +3,13 @@
3
3
  Install:
4
4
 
5
5
  ```bash
6
- npm install @josephyan/qingflow-app-user-mcp@0.2.0-beta.43
6
+ npm install @josephyan/qingflow-app-user-mcp@0.2.0-beta.44
7
7
  ```
8
8
 
9
9
  Run:
10
10
 
11
11
  ```bash
12
- npx -y -p @josephyan/qingflow-app-user-mcp@0.2.0-beta.43 qingflow-app-user-mcp
12
+ npx -y -p @josephyan/qingflow-app-user-mcp@0.2.0-beta.44 qingflow-app-user-mcp
13
13
  ```
14
14
 
15
15
  Environment:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@josephyan/qingflow-app-user-mcp",
3
- "version": "0.2.0-beta.43",
3
+ "version": "0.2.0-beta.44",
4
4
  "description": "Operational end-user MCP for Qingflow records, tasks, comments, and directory workflows.",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/pyproject.toml CHANGED
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "qingflow-mcp"
7
- version = "0.2.0b43"
7
+ version = "0.2.0b44"
8
8
  description = "User-authenticated MCP server for Qingflow"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -2,4 +2,4 @@ from __future__ import annotations
2
2
 
3
3
  __all__ = ["__version__"]
4
4
 
5
- __version__ = "0.2.0b43"
5
+ __version__ = "0.2.0b44"
@@ -2,6 +2,7 @@ from __future__ import annotations
2
2
 
3
3
  from dataclasses import dataclass
4
4
  from threading import Event
5
+ from time import sleep
5
6
  from typing import Any
6
7
  from urllib.parse import urlsplit, urlunsplit
7
8
  from uuid import uuid4
@@ -307,18 +308,25 @@ class BackendClient:
307
308
  failure_event_received = Event()
308
309
  sio = socketio.Client(reconnection=False, logger=False, engineio_logger=False)
309
310
 
311
+ def _unwrap_socket_event_payload(payload: Any) -> Any:
312
+ if isinstance(payload, list) and payload:
313
+ return payload[0]
314
+ return payload
315
+
310
316
  def _handle_initial(payload: Any) -> None:
311
- if isinstance(payload, dict):
312
- import_result["initial_event"] = payload
313
- process_id = payload.get("processIdStr") or payload.get("process_id_str") or payload.get("processId")
317
+ normalized_payload = _unwrap_socket_event_payload(payload)
318
+ import_result["initial_event"] = normalized_payload
319
+ if isinstance(normalized_payload, dict):
320
+ process_id = normalized_payload.get("processIdStr") or normalized_payload.get("process_id_str") or normalized_payload.get("processId")
314
321
  if process_id is not None:
315
322
  import_result["process_id_str"] = str(process_id)
316
323
  initial_event_received.set()
317
324
 
318
325
  def _handle_failure(payload: Any) -> None:
319
- if isinstance(payload, dict):
320
- import_result["failure_event"] = payload
321
- process_id = payload.get("processIdStr") or payload.get("process_id_str") or payload.get("processId")
326
+ normalized_payload = _unwrap_socket_event_payload(payload)
327
+ import_result["failure_event"] = normalized_payload
328
+ if isinstance(normalized_payload, dict):
329
+ process_id = normalized_payload.get("processIdStr") or normalized_payload.get("process_id_str") or normalized_payload.get("processId")
322
330
  if process_id is not None:
323
331
  import_result["process_id_str"] = str(process_id)
324
332
  failure_event_received.set()
@@ -326,7 +334,7 @@ class BackendClient:
326
334
  try:
327
335
  sio.connect(
328
336
  socket_base_url,
329
- transports=["polling", "websocket"],
337
+ transports=["websocket"],
330
338
  socketio_path="socket.io",
331
339
  headers=self._base_headers(
332
340
  context.token,
@@ -335,6 +343,8 @@ class BackendClient:
335
343
  ),
336
344
  wait_timeout=ack_timeout_seconds,
337
345
  )
346
+ sio.emit("token", [context.token])
347
+ sleep(0.2)
338
348
  ack = sio.call(
339
349
  "dataImport",
340
350
  [
@@ -348,7 +358,19 @@ class BackendClient:
348
358
  ],
349
359
  timeout=ack_timeout_seconds,
350
360
  )
351
- import_id = ack[0] if isinstance(ack, list) and ack else ack
361
+ ack_payload = ack[0] if isinstance(ack, list) and ack else ack
362
+ if isinstance(ack_payload, dict):
363
+ error_code = ack_payload.get("error")
364
+ ack_message = ack_payload.get("message")
365
+ import_id = ack_payload.get("data")
366
+ if error_code not in (None, 0):
367
+ raise QingflowApiError(
368
+ category="backend",
369
+ message=str(ack_message or f"socket import rejected with error {error_code}"),
370
+ details={"socket_error_code": error_code, "import_id": import_id},
371
+ )
372
+ else:
373
+ import_id = ack_payload
352
374
  if not import_id:
353
375
  raise QingflowApiError(category="backend", message="socket import ack did not return import_id")
354
376
  import_result["import_id"] = str(import_id)