Skip to content

Fix stats tool validation failures#28

Merged
bezata merged 1 commit into
mainfrom
fix/stats-output-parse-issues
Jun 5, 2026
Merged

Fix stats tool validation failures#28
bezata merged 1 commit into
mainfrom
fix/stats-output-parse-issues

Conversation

@bezata
Copy link
Copy Markdown
Owner

@bezata bezata commented Jun 5, 2026

What this changes

Fixes two stats-related MCP failures:

  • notes.read with include: ["stats"] now returns schema-compatible numeric headings and links values while preserving the underlying count aliases.
  • stats.vault now skips individual notes that fail per-note statistics parsing instead of failing the whole vault scan, and reports skipped note paths in skippedNotes.

This is user-visible as previously failing stats calls now return structured results.

Closes #26
Closes #27

Why

notes.read was returning the rich getNoteStatistics() shape directly. That shape uses object-valued headings and links, but the registered MCP output schema expects numeric counts for those fields, causing output validation errors.

stats.vault also treated any per-note stats error as fatal, so one malformed/frontmatter-like note could prevent vault-wide stats from returning at all.

How

  • Added a toNotesReadStats() adapter in src/server/tools/notes.ts that converts note statistics into the public notes.read schema shape.
  • Wrapped per-note stats collection in src/domain/statistics.ts so vault stats continue scanning and collect skipped note paths.
  • Added MCP integration regressions in tests/server-integration.test.ts for both failing behaviors.

What behavior is preserved

The domain-level getNoteStatistics() return shape remains unchanged for internal callers. stats.vault still aggregates counts from successfully parsed notes.

Risk remains

Skipped notes are excluded from aggregate totals. The response reports skippedNotes so callers can see when totals are partial.

How reviewers can verify it

Run:

bun run typecheck
bun run lint
bun run test
bun run build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant