Skip to content

fix(xiaohongshu): robust JSON parsing + Windows timeouts for doctor check#161

Merged
Panniantong merged 1 commit intomainfrom
fix/xiaohongshu-doctor-windows-compat
Mar 13, 2026
Merged

fix(xiaohongshu): robust JSON parsing + Windows timeouts for doctor check#161
Panniantong merged 1 commit intomainfrom
fix/xiaohongshu-doctor-windows-compat

Conversation

@Panniantong
Copy link
Owner

Problem

Fixes #159

agent-reach doctor falsely reported XiaoHongShu MCP connection failure on Windows with mcporter 0.7.3, even when the MCP server was running and usable.

Root cause

The health-check used a rigid string match '"status": "ok"' in out on the lowercased mcporter list JSON output. On Windows, PowerShell can prepend a UTF-8 BOM, use CRLF line endings, or emit slightly different whitespace — all of which break the literal string comparison.

Additionally, the default 5 s / 10 s timeouts are too tight for mcporter on Windows.

Changes

  • _mcporter_status_ok() (new helper): parses the output with json.loads() first; strips UTF-8 BOM before parsing; falls back to normalised (BOM/CRLF/space-stripped) string search for backward compatibility.
  • Windows timeouts: config get 5 s → 15 s; list 10 s → 30 s. Unchanged on Linux/macOS.

Testing

  • All 49 existing tests pass (pytest tests/ -x -q)
  • Verified _mcporter_status_ok() handles: normal JSON, BOM-prefixed JSON, CRLF output, space-stripped JSON, case variants — all correctly.

…heck

- Replace brittle '"status": "ok"' string match with proper JSON parsing
  in _mcporter_status_ok(). Handles Windows BOM, CRLF line endings, and
  whitespace variations that caused false negatives on Windows + mcporter 0.7.3.
- Fallback to normalised string matching for backward compatibility.
- Extend config-get timeout to 15 s and list timeout to 30 s on Windows
  (unchanged on Linux/macOS: 5 s / 10 s).

Fixes #159
@Panniantong Panniantong merged commit 5461ca4 into main Mar 13, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

doctor falsely reports XiaoHongShu MCP connection failure on Windows with mcporter 0.7.3

1 participant