Minor Changes
-
a199f80: fix(schema): finish #138 by moving to Zod v4, so no tool advertises an array-valued
typeStrict MCP clients and gateways reject an array-valued
type("type": ["string", "null"]) and silently drop the whole tool. The remaining occurrences after the previous fix were the mail-rule fields the API declares with no constraint to carry —filter_attachment_filename_include,filter_attachment_filename_exclude,action_parameter— andquery_documents'paperless_filters, none of which could be fixed by declaring constraints.They came from
zod-to-json-schema, which the MCP SDK uses for Zod v3 shapes and which collapses any union of unchecked primitives into that form. No SDK release changes this: 1.11.1 through 1.30.0 emit byte-identical schemas for a v3 shape. The SDK does convertzod/v4shapes with Zod's owntoJSONSchema, which emitsanyOfinstead, so the server now uses Zod v4 with@modelcontextprotocol/sdkat ^1.30.0 (1.23.0 is the first release that reads v4 shapes; earlier ones drop them from the advertised schema).zodis pinned to~4.4.3because 4.5.0 reintroduced the collapse.Alongside the bump:
matching_algorithmon tags, correspondents and document types is declared once and narrows toMatchingAlgorithmafter its range check, so the API request types take it without a cast. The advertised schema is unchanged.Document.storage_pathandDocument.archive_serial_numberare typednumber | null, matching the spec, which declares both as nullable integers. They were typedstring | null.- Tool schemas no longer carry
additionalProperties: falseat the top level. It was never enforced — unknown properties were stripped, not rejected — so the schemas now describe what the server actually does. Nested objects declared.strict(), such asbulk_edit_documents'set_permissions, still advertise and enforce it.
This also fixes a
tscout-of-memory crash: SDK 1.23.0 and later paired with Zod 3.25.x hits an unbounded type instantiation (modelcontextprotocol/typescript-sdk#1180) that exhausts the heap even at 8GB, which is why the SDK could not be upgraded on its own.
Patch Changes
-
ccd454d: fix(schema): declare the OpenAPI constraints on nullable document and mail-rule fields, which also stops
update_documentandbulk_edit_documentsfrom being dropped by strict MCP clientsPaperless_ngx_REST_API.yamldeclares the document foreign keys astype: integerand the mail-rule text filters asmaxLength: 256, but the tool schemas declared them as unconstrainedz.number()/z.string(). They now carry.int()and.max(256).This also fixes part of #138.
zod-to-json-schemacollapses a nullable primitive that carries no checks into"type": ["number","null"]; strict MCP clients and gateways reject an array-valuedtypeand silently drop the whole tool. Because the collapse only applies to check-less primitives, declaring the constraints the API already mandates makes the emitted schema{"anyOf":[{"type":"integer"},{"type":"null"}]}instead.nullis still accepted at call time, so clearing a correspondent, document type, storage path or owner keeps working.update_documentandbulk_edit_documentsno longer advertise any array-formtype.create_mail_ruleandupdate_mail_ruleare fixed for the four spec-bounded filters; theirfilter_attachment_filename_include,filter_attachment_filename_excludeandaction_parameterfields, andquery_documents'paperless_filters, are unchanged because the spec declares no constraint to carry there.