Skip to content

Commit b5f76fa

Browse files
ochafikclaude
andcommitted
pdf-server: discourage base64 encoding in image annotation, clarify imageUrl accepts file paths
Models tend to encode images as base64 themselves instead of passing file paths. Make the schema descriptions and tool docs explicit: prefer imageUrl with a file path, no data: URIs, don't encode images yourself. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 51fc174 commit b5f76fa

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

examples/pdf-server/server.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,15 @@ const ImageAnnotation = AnnotationBase.extend({
183183
imageData: z
184184
.string()
185185
.optional()
186-
.describe("Base64-encoded PNG or JPEG image data (no data: prefix)"),
187-
imageUrl: z.string().optional().describe("URL or file path to the image"),
186+
.describe(
187+
"Base64-encoded PNG or JPEG image data (no data: prefix). Prefer imageUrl with a file path instead of encoding images yourself.",
188+
),
189+
imageUrl: z
190+
.string()
191+
.optional()
192+
.describe(
193+
"File path or HTTPS URL to the image. NO data: URIs — use imageData for raw base64. Prefer file paths over encoding images yourself.",
194+
),
188195
mimeType: z
189196
.string()
190197
.optional()
@@ -1810,7 +1817,7 @@ Annotation types:
18101817
• rectangle: x, y, width, height, color?, fillColor?, rotation? • circle: x, y, width, height, color?, fillColor?
18111818
• line: x1, y1, x2, y2, color? • freetext: x, y, content, fontSize?, color?
18121819
• stamp: x, y, label (any text, e.g. APPROVED, DRAFT, CONFIDENTIAL), color?, rotation?
1813-
• image: imageUrl or imageData (base64 PNG/JPEG), x?, y?, width?, height?, mimeType?, rotation?, aspect? — places an image (signature, logo, etc.) on the page. imageUrl can be a local file path or HTTP(S) URL; the server fetches and embeds it automatically. Width/height auto-detected from image if omitted.
1820+
• image: imageUrl or imageData, x?, y?, width?, height?, mimeType?, rotation?, aspect? — places an image (signature, logo, etc.) on the page. imageUrl accepts a local file path or HTTPS URL (NO data: URIs). Do NOT base64-encode images yourself — just pass the file path via imageUrl and the server fetches and embeds it. Width/height auto-detected if omitted.
18141821
18151822
TIP: For text annotations, prefer highlight_text (auto-finds text) over manual rects.
18161823

0 commit comments

Comments
 (0)