Repository navigation
Add opt-in data fields to get_document_content - #9
Conversation
get_document_content accepts include_data_fields, which fetches the document's data fields from GET v3/documents/:id alongside the markdown. If only the data fields request fails or times out (10s after the content arrives), the text is still returned with data_fields: null and data_fields_error. The data fields request is cancelled as soon as the markdown request fails, and both are cancelled when the MCP client cancels. Also: - share the data field formatter with get_template, which now outputs number formatting too - share errorMessage across tools - truncate HTTP error bodies to 500 characters and keep the HTTP status when an error response has a malformed JSON body - combine a caller-supplied signal with the 30s request timeout instead of replacing it - treat a markdown response that is not a document as an error rather than empty content Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
A few things before merging: 1. 2. Error truncation hits validation errors ( 3. Grace timeout / cancellation (
4. Code comments 5. 6. Spread instead of |
- pass data field formatting through as-is (keeps date formats) and tell the model values are raw and formatting is display-only - truncate only non-JSON HTTP error bodies so validation errors stay whole - reject instead of returning a result when the MCP client cancels while waiting for data fields - type the handler context as the SDK's ServerContext - build the result with a spread instead of mutating the content - remove code comments added in this PR Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
Thanks, addressed in eb0b31e:
Typecheck, lint, format and all 87 tests pass. I also checked that removing the new cancellation |
get_document_contentgets aninclude_data_fieldsflag that also fetches the document's data fields fromGET v3/documents/:id, in parallel with the markdown. If only that request fails or takes more than 10s after the text arrives, the tool still returns the text, withdata_fields: nulland adata_fields_error. The data fields request is cancelled as soon as the markdown request fails, and MCP client cancellation aborts both requests. Shared changes:get_templateuses the same data field formatter (so it now includesformatting, passed through as-is), all tools shareerrorMessage, non-JSON HTTP error bodies are capped at 500 characters and error responses keep their status when the body is malformed JSON, and a caller's abort signal now combines with the 30s timeout instead of replacing it. Tests cover partial failure, cancellation, the timeout and malformed responses, with newhang/bodyoptions and unused-route tracking in thefakeFetchhelper.🤖 Generated with Claude Code