Generate a unique MIME boundary string (e.g., a UUID) and construct the Content-Type header as multipart/related; type=application/dicom; boundary=BOUNDARY_STRING
For each DICOM instance file, write a MIME part header --BOUNDARY_STRING\r\nContent-Type: application/dicom\r\n\r\n followed by the raw binary DICOM P10 bytes
Terminate the multipart body with --BOUNDARY_STRING-- and send the complete payload via HTTP POST to .../studies (for a full study) or .../studies/{studyUID} (to append to an existing study)
Parse the STOW-RS response body (Content-Type: application/dicom+xml or application/dicom+json) to extract the ReferencedSOPSequence entries and verify that the expected SOP Instance UIDs appear in the success list
For very large studies, consider chunked transfer encoding or split the study into multiple STOW-RS requests per series, verifying each batch before proceeding to the next
Known gotchas
The MIME boundary string must not appear anywhere in the binary DICOM payload; while extremely unlikely with a random UUID boundary, validate against each file to guarantee compliance
STOW-RS servers may enforce a maximum request body size; uploading a 2 GB CT series in a single multipart request may exceed server limits — check the server's conformance statement for body size caps
Some servers require the Content-Length header to be accurate for multipart bodies; streaming uploads without a known content length may be rejected — pre-calculate body size or use chunked encoding if the server declares support
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp