Skip to content

fix(xhs): format public MCP search and detail responses - #744

Open
rudycelekli wants to merge 2 commits into
Panniantong:mainfrom
rudycelekli:fix/xhs-mcp-format-20261002
Open

rudycelekli wants to merge 2 commits into
Panniantong:mainfrom
rudycelekli:fix/xhs-mcp-format-20261002

Conversation

@rudycelekli

Copy link
Copy Markdown

Problem

The documented mcporter call ... | agent-reach format xhs pipeline drops real xiaohongshu-mcp output. Its public Go structs serialize search as feeds with noteCard, displayTitle, xsecToken and other camelCase fields. The formatter recognizes only older items / snake_case data and outputs {}. Detail responses additionally put note and comments.list inside a data envelope.

Changes

  • Recognize search and HTTP/detail envelopes, retaining empty search results as [].
  • Normalize known MCP camelCase fields to the existing compact snake_case output.
  • Preserve the feed-level note ID and explicit token when note content is nested; keep inner canonical values authoritative.
  • Retain useful cover/detail image URLs and sibling comments while continuing to discard structural noise.

This only formats caller-provided JSON. It adds no network calls or authentication behavior.

Evidence

Public upstream response envelopes, feed/detail/comment structs, and MCP serialization. This completes the formatter contract introduced for #134; it does not restore the obsolete read/search wrappers.

Validation

  • Before: 9 regression failures and 1 compatibility control pass, including native formatter CLI invocations on upstream-shaped JSON.
  • After: 18 focused formatter tests pass; all 617 repository tests pass.
  • Ruff: all source and test checks pass; diff whitespace check is clean.
  • Formatting: the untouched base already fails ruff format --check in 54 files; this patch follows existing local formatting and does not reformat unrelated code.
  • mypy: the same 3 pre-existing diagnostics in integrations/mcp_server.py with the supplied MCP SDK 2.2 runtime; no new errors.

AI assistance: implementation and regression investigation prepared with Codex and reviewed before submission.

Signed-off-by: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com>
Signed-off-by: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com>
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.

1 participant