fix(xiaohongshu): robust JSON parsing + Windows timeouts for doctor check#161
Merged
Panniantong merged 1 commit intomainfrom Mar 13, 2026
Merged
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Fixes #159
agent-reach doctorfalsely 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 outon the lowercasedmcporter listJSON 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 withjson.loads()first; strips UTF-8 BOM before parsing; falls back to normalised (BOM/CRLF/space-stripped) string search for backward compatibility.config get5 s → 15 s;list10 s → 30 s. Unchanged on Linux/macOS.Testing
pytest tests/ -x -q)_mcporter_status_ok()handles: normal JSON, BOM-prefixed JSON, CRLF output, space-stripped JSON, case variants — all correctly.