Skip to content

feat(agent-toolkit): add image from file upload to update_doc tool#262

Closed
RoniLandau wants to merge 3 commits intomasterfrom
feat/add-image-from-file-to-doc
Closed

feat(agent-toolkit): add image from file upload to update_doc tool#262
RoniLandau wants to merge 3 commits intomasterfrom
feat/add-image-from-file-to-doc

Conversation

@RoniLandau
Copy link
Copy Markdown
Collaborator

@RoniLandau RoniLandau commented Mar 23, 2026

Summary

  • Adds a new add_image_from_file operation to the update_doc tool that allows inserting images into monday.com documents from file data (base64-encoded) instead of requiring a public URL
  • Bumps @mondaydotcomorg/api from ^13.0.0 to ^14.0.0 to get the new file upload middleware from monday-graphql-api#87
  • Increases minimum Node.js requirement from 16.20.0 to 18.0.0 (required by SDK v14)

How it works

The add_image_from_file operation handles everything automatically — the caller only provides file_base64 and file_name:

Step 0 — Resolve board context

The tool uses the document's object_id (board ID) to find a file column and an item on the board via getBoardDataForAsset query. If only doc_id is provided, the tool first resolves it to object_id via getDocById.

Step 1 — Upload file

Decodes the base64 input and creates a File object (with proper MIME type derived from extension), then uploads via add_file_to_column. The SDK v14 middleware auto-detects the File/Blob in variables and converts the request to multipart/form-data.

Step 2 — Insert image block

Uses the returned asset ID to create an image block in the document via create_doc_blocks with the asset_id field on ImageBlockInput.

Schema changes

  • ImageBlockInput (GraphQL + generated types): Added asset_id: ID field, made public_url optional. Image blocks can now be created from either a public URL or an asset ID.
  • CreateBlockImageSchema (Zod): Both public_url and asset_id are optional; runtime validation in the helper ensures at least one is provided.
  • New AddImageFromFileOperation: Only requires file_base64 and file_name. Optional: after_block_id, parent_block_id, width. Board context (item_id, column_id) is auto-resolved from the document's object_id.
  • New GraphQL queries: getDocById (doc_id → object_id), getBoardDataForAsset (board → file column + item)

SDK v14 migration

  • Replaced timeouttimeoutMs in get-board-items-page-tool (breaking change in SDK v14)

Test plan

  • Happy path: resolves board context → uploads file → creates image block with asset_id
  • Resolves object_id from doc_id when only doc_id is provided
  • Error: board has no file column → clear error message
  • Error: board has no items → clear error message
  • Error: upload returns no asset ID → clear error message
  • Error: upload succeeds but block creation fails → clear error message
  • Existing create_block with public_url still works
  • Full test suite: 587/587 tests pass

🤖 Generated with Claude Code

RoniLandau and others added 3 commits March 23, 2026 14:13
Add `add_image_from_file` operation to the update_doc tool, enabling image
insertion from base64 file data instead of requiring a public URL.

The operation works in two steps:
1. Upload the file via `add_file_to_column` to create a monday.com asset
2. Create an image block in the doc using the returned asset ID

Also bumps `@mondaydotcomorg/api` from ^13 to ^14 which adds the file upload
middleware (auto-detects File/Blob in variables and converts to multipart/form-data).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Remove item_id/column_id from add_image_from_file input — the tool
  now auto-resolves them by querying the board (from object_id) for a
  file column and an item
- Add getBoardDataForAsset and getDocById GraphQL queries
- Fix File creation: use File with MIME type on Node 20+, Blob fallback
  with name+type on Node 18
- Add tests for board context resolution, missing file column, missing
  items

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Accept a local file path instead of base64-encoded data. The tool reads
the file from disk directly, avoiding the need to pass large base64
strings (~50KB+ for small images) through MCP tool call JSON parameters
which caused agents to choke.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@RoniLandau RoniLandau closed this Mar 24, 2026
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.

1 participant