prismic_upsert_documents
Batch create or update documents in Prismic's Migration API workflow for content management. Use dry runs and fail-fast options for controlled execution before publishing.
Instructions
Batch create/update documents in the Prismic Migration API.
Important behavior:
This writes to the Migration workflow (Migration UI/release flow).
Batch-created/updated documents may not be visible via Content API master reads until release/publish workflow makes them readable.
For read-back before publish, use a release ref with read tools (
refparameter), plusPRISMIC_CONTENT_API_TOKENif repo settings require authenticated reads.Supports
dry_runandfail_fastfor safer execution.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| documents | Yes | ||
| fail_fast | No | ||
| dry_run | No |
Implementation Reference
- prismic_content_mcp/server.py:466-528 (handler)The implementation of the `handle_prismic_upsert_documents` handler which performs the batch upsert operations.
async def handle_prismic_upsert_documents( *, documents: list[DocumentWrite], fail_fast: bool = False, dry_run: bool = False, service_factory: ServiceFactory = _build_service, ) -> dict[str, Any]: """Batch create/update documents in the Migration API.""" created = 0 updated = 0 failed = 0 results: list[dict[str, Any]] = [] async with service_factory(require_write_credentials=True) as service: service.validate_batch_size(len(documents)) for index, document in enumerate(documents): input_ref = _document_reference(document, index) try: if dry_run: plan = service.plan_upsert(document) status = plan["status"] resolved_id = plan["id"] else: response = await service.upsert_document(document) status = response["status"] resolved_id = response["id"] if status == "created": created += 1 else: updated += 1 results.append( { "input_ref": input_ref, "ok": True, "id": resolved_id, "error": None, "dry_run": dry_run, } ) except RECOVERABLE_BATCH_EXCEPTIONS as exc: failed += 1 results.append( { "input_ref": input_ref, "ok": False, "id": None, "error": _safe_batch_error(exc), "dry_run": dry_run, } ) if fail_fast: raise return { "results": results, "summary": { "created": created, "updated": updated, "failed": failed, }, } - prismic_content_mcp/server.py:838-857 (registration)The registration of the `prismic_upsert_documents` tool using the @server.tool decorator.
@server.tool(name="prismic_upsert_documents") async def prismic_upsert_documents( documents: list[DocumentWrite], fail_fast: bool = False, dry_run: bool = False, ) -> dict[str, Any]: """Batch create/update documents in the Prismic Migration API. Important behavior: - This writes to the Migration workflow (Migration UI/release flow). - Batch-created/updated documents may not be visible via Content API master reads until release/publish workflow makes them readable. - For read-back before publish, use a release ref with read tools (`ref` parameter), plus `PRISMIC_CONTENT_API_TOKEN` if repo settings require authenticated reads. - Supports `dry_run` and `fail_fast` for safer execution. """ return await handle_prismic_upsert_documents( documents=documents,