Skip to content

feat(mcp): read_paper folds annotations by default (#185 PR1/5)#186

Merged
gerchowl merged 2 commits intodevfrom
land/185-pr1-read-paper-annotations
Apr 28, 2026
Merged

feat(mcp): read_paper folds annotations by default (#185 PR1/5)#186
gerchowl merged 2 commits intodevfrom
land/185-pr1-read-paper-annotations

Conversation

@gerchowl
Copy link
Copy Markdown
Contributor

Summary

First of 5 PRs landing #185 (agent↔human comment-and-reply loop). Closes the silent-miss bug where an agent calling the natural extraction tool (read_paper) would never observe a human comment.

  • read_paper now Returns: JSON {paper, annotations[] (live, with parent_id/root_id and full anchor), source_version, extractor, path, truncated, total_chars} by default
  • with_annotations: false preserves the legacy text shape byte-identically (escape hatch for any existing client)
  • get_annotated_paper is documented as superseded by read_paper for fetches that also need the body
  • Shared build_annotations_json helper so both tools agree on shape

Test plan

  • 7 new unit tests (default-on JSON envelope, opt-out text shape, truncation flag in JSON, truncation marker in text, soft-deleted excluded, zero annotations, replies carry root_id)
  • 56/56 cargo test -p scitadel-mcp --lib pass
  • cargo clippy -p scitadel-mcp --tests -- -D warnings clean
  • cargo fmt --check clean
  • E2E sanity: invoke via the running MCP host

[tape-exempt: MCP-only tool surface change; no TUI/CLI source touched]

Refs #185.

`read_paper` now returns a JSON envelope with paper, annotations[],
source_version, extractor, path, truncated, total_chars. An agent
calling the natural extraction endpoint will no longer silently miss
human comments — closing one of the three legs of #185 (agent↔human
comment loop). Pass `with_annotations: false` for the legacy text
shape so existing clients can opt out.

`get_annotated_paper` is documented as superseded by `read_paper` for
fetches that also need the extracted body.

Refs #185.

[tape-exempt: MCP-only tool surface change; no TUI/CLI source touched]
Review nits on the prior commit:
- assemble_read_paper_response now takes &Paper instead of paper_id +
  paper_title, dropping the second paper_repo.get on the with_annotations
  path. read_paper_tool already loaded the paper for the extraction
  cache check.
- New `read_paper_with_annotations_replies_carry_root_id` test mirrors
  the existing get_annotated_paper test so future refactors of
  build_annotations_json don't silently break parent_id/root_id
  propagation through the read_paper envelope.

Refs #185.

[tape-exempt: MCP-only refactor + test, no TUI/CLI surface touched]
@gerchowl gerchowl merged commit 23d61ba into dev Apr 28, 2026
12 of 14 checks passed
@gerchowl gerchowl deleted the land/185-pr1-read-paper-annotations branch April 28, 2026 16:22
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