SIGN IN SIGN UP

Accept JSON-encoded string heading targets from anyOf-challenged MCP clients

The MCP `target` parameter is a union of array-of-strings and string,
which serializes to an anyOf JSON Schema. Some MCP clients do not
resolve anyOf and forward the raw JSON text of an array argument as a
plain string; the union's string branch accepts it, and the handlers'
array checks then reject the call, making heading targeting completely
unavailable from those clients (#315).

vault_read and vault_patch now recover such values: a heading target
arriving as a string that JSON-parses to an array of strings (or null,
for vault_patch's document root) is treated as that value. This is
strictly additive — a bare string was always an error for heading
targets, so no currently-valid call changes meaning. Strings that don't
parse that way are still rejected, but the error now explains that the
caller's client may not support anyOf-typed parameters rather than
implying they passed the wrong type. Block and frontmatter targets are
never JSON-parsed, since a string is their legitimate type.

The shim lives here rather than in markdown-patch-2 so the library's
strict contract stays clean; this is purely a transport-level
accommodation for the MCP surface. The REST API is unaffected.

Fixes #315.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
A
Adam Coddington committed
eabde4c63570d8b966145c864b20a34835214038
Parent: ced3aa2