Skip to content

PIGS-811: Add outputTarget to JSON-returning tools for inline results#81

Merged
RogerThomas merged 4 commits into
mainfrom
PIGS-811-inline-json-output
Jun 9, 2026
Merged

PIGS-811: Add outputTarget to JSON-returning tools for inline results#81
RogerThomas merged 4 commits into
mainfrom
PIGS-811-inline-json-output

Conversation

@RogerThomas

Copy link
Copy Markdown
Contributor

Summary

  • Add a shared outputTarget param (inline | file | both, default inline) to every JSON-returning tool so extracted data is returned directly in the tool result instead of only being written to disk.
  • Introduce src/tools/jsonOutput.ts (jsonResult helper) to centralize inline/file/both result shaping.
  • Apply to get_pdf_metadata, extract_pdf_forms, extract_pdf_tables, extract_pdf_text, extract_invoice_data, search_text_in_pdf, and extract_pii.

Why

Multi-step flows with a data step were broken: JSON-returning endpoints wrote results to the filesystem and returned only a filename, but Claude can't read the file back — so it couldn't chain steps (e.g. extract forms from several PDFs into one Excel, or PII-extract then redact a filtered subset). Defaulting to inline returns parsed data under data so follow-up steps can use it, and keeps transient flows from littering the working folder. file/both still write to disk and return outputFilename. Binary outputs (Excel/PDF) remain file-only and are orthogonal to outputTarget.

Test plan

  • task n:check (format + types + lint) passes
  • task n:test passes (161 passed, 1 skipped)
  • Manually verify inline data drives a chained flow (e.g. extract PII then report found names/emails)

🤖 Generated with Claude Code

RogerThomas and others added 2 commits June 8, 2026 16:08
JSON-producing tools wrote output to disk and returned only a filename,
which Claude's container cannot read back, breaking multi-step flows
where a JSON step is intermediate. Add a model-selected outputTarget
param (inline | file | both, default inline) via a shared jsonResult
helper, so extracted data is returned inline by default and can drive
follow-up steps without filesystem access.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Node.js MCP tool layer to support inline JSON results (optionally alongside file output) via a shared outputTarget parameter, enabling multi-step/chained flows without relying on filesystem reads.

Changes:

  • Add outputTarget (inline | file | both, default inline) to multiple extraction/PII tools and return JSON inline under data when requested.
  • Introduce node-version/src/tools/jsonOutput.ts (jsonResult) to centralize inline/file/both shaping for JSON-returning tools.
  • Update Vitest expectations for extraction + PII tools to cover default inline behavior and explicit file output.

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
node-version/src/tools/jsonOutput.ts New helper to shape JSON tool results for inline/file/both outputs.
node-version/src/tools/extractions.ts Apply outputTarget + jsonResult to JSON-returning extraction tools; update text extraction output behavior.
node-version/src/tools/pii.ts Apply outputTarget + jsonResult to extract_pii; expand redact tool parameter description.
node-version/src/models.ts Add outputTargetSchema shared input parameter.
node-version/tests/extractions.test.ts Update/expand tests for inline-by-default JSON extraction behavior and file-only cases.
node-version/tests/pii.test.ts Update/expand tests for inline-by-default PII extraction and file-only cases.
node-version/src/tools/transformations.ts Adjust watermark boundingBox schema typing (tuple → length-4 array).
node-version/src/handlers/platformHandler.ts Loosen WatermarkParams.boundingBox type to `number[]
CLAUDE.md Document the new outputTarget convention and shared helper usage.
pyproject.toml Add Python local-dev dependencies (despite file being marked legacy/archived).
uv.lock Lockfile updates for newly added Python local-dev dependencies (and related package updates).

Comment thread CLAUDE.md Outdated
Comment thread node-version/src/tools/pii.ts
Comment thread node-version/src/tools/extractions.ts
Comment thread node-version/src/models.ts
Comment thread pyproject.toml

export interface WatermarkParams {
readonly boundingBox?: [number, number, number, number] | null;
readonly boundingBox?: number[] | null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this broader definition better?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a local script which uses an agent to test the tool before I create a PR, when it was trying to load the tuple, it's not compatible for some reason.

@timshari-nitro timshari-nitro left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice 👍

- Correct jsonOutput.ts helper path in CLAUDE.md to node-version/src/...
- Reword extract_pii and search_text_in_pdf descriptions to reflect the
  inline-by-default outputTarget behaviour instead of "Returns a JSON file"
- Generalise outputTargetSchema description to cover JSON or text output

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 11 changed files in this pull request and generated 2 comments.

Comment thread node-version/src/tools/extractions.ts
Comment thread pyproject.toml
Use the shared `data` key for extract_pdf_text's inline payload instead
of `text`, matching every other outputTarget tool so results chain
generically. Update tests accordingly.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 11 changed files in this pull request and generated 1 comment.

Comment thread pyproject.toml
@RogerThomas RogerThomas merged commit 3575291 into main Jun 9, 2026
6 checks passed
@RogerThomas RogerThomas deleted the PIGS-811-inline-json-output branch June 9, 2026 08:46
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.

3 participants