Skip to main content
Glama

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 (ref parameter), plus PRISMIC_CONTENT_API_TOKEN if repo settings require authenticated reads.

  • Supports dry_run and fail_fast for safer execution.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
documentsYes
fail_fastNo
dry_runNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • 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,
            },
        }
  • 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,
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden and does well by disclosing critical behavioral traits: it writes to Migration workflow, documents may not be visible via Content API until release/publish, and supports dry_run and fail_fast for safer execution. It doesn't mention rate limits or authentication requirements, but covers key operational constraints.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with a clear purpose statement followed by an 'Important behavior' section. Every sentence adds value: the first states the core function, and subsequent sentences explain workflow implications, read-back alternatives, and safety features. No wasted words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (batch write operation with 3 parameters, no annotations, but with output schema), the description is mostly complete. It covers purpose, usage context, and key behaviors, but lacks details on authentication, error handling, or response format, though some of this may be in the output schema.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It mentions dry_run and fail_fast parameters, explaining they are 'for safer execution,' which adds useful context beyond the schema's titles. However, it doesn't detail the documents array structure or DocumentWrite model, leaving some parameter semantics undocumented.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool performs 'Batch create/update documents in the Prismic Migration API,' specifying both the action (create/update) and resource (documents) with the batch qualifier. It distinguishes from sibling tools like prismic_upsert_document (singular) and prismic_get_documents (read-only).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit guidance on when to use alternatives: it states that for read-back before publish, use read tools with a release ref and PRISMIC_CONTENT_API_TOKEN. It also clarifies this writes to the Migration workflow, not directly to the Content API, helping differentiate from other write operations.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/rahulpowar/prismic-content-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server