Closedloop.ai
MCP Server

Document Versions

Append new content to a document and list its saved versions

Overview

A document's body is a series of saved versions. Each new version replaces the whole body, and earlier versions stay in the history. Metadata changes such as title, status, and assignee go through update-document instead.

ToolScopePurpose
create-document-versionwriteAppend a new version, optionally creating inline images in the same call
list-document-versionsreadList a document's saved versions, newest first

To read a version's body, use get-document with includeContent for the latest version, or get-document-content with version for an exact, chunked read of any version.

Both tools accept a document UUID or slug (PRD-7, PLN-12, ISS-42) as documentId. A failed call returns an MCP result with isError: true and a text block carrying the error's title, description, and any remediation steps.

create-document-version does not detect versions written since you last read the document. Call list-document-versions first and compare the latest version with the one you read, so you do not bury another author's edit.


Create Document Version

Tool: create-document-version Scope: write Underlying API: POST /documents/{documentId}/versions

NameTypeRequiredDescription
documentIdstringYesDocument UUID or slug (e.g. PRD-7, PLN-12, ISS-42).
contentstringYesThe full body of the new version.
inlineImagesarrayNoUp to 5 images to create in the same call.

Each inlineImages entry:

FieldTypeRequiredDescription
placeholderstringYes1–200 characters. The exact marker text in content to replace.
filenamestringYes1–255 characters.
mimeTypestringYesimage/jpeg, image/png, image/gif, or image/webp.
dataBase64stringYesRaw base64 image bytes with no data: prefix. 1–699052 characters (512 KiB of image data).
altTextstringNoUp to 500 characters of Markdown alt text.

Each placeholder must be unique, must appear in content, and must not overlap another placeholder. The server rewrites it to ![alt](attachment://<attachment-id>). The API also refuses a version whose content, once the references are expanded, would exceed 1,048,576 characters. The MCP server refuses any request body over 1 MiB, so several large images may not fit in one call. To add an image without writing a new version, use create-inline-image-attachment.

Returns the updated document as both a JSON text block and structuredContent. Fields the API does not return are omitted.

{
  "id": "3f8a…",
  "slug": "PLN-12",
  "title": "Checkout webhook retries",
  "type": "IMPLEMENTATION_PLAN",
  "status": "DRAFT",
  "priority": null,
  "latestVersion": 5,
  "updatedAt": "2026-10-03T08:30:00.000Z",
  "webUrl": "https://app.closedloop.ai/acme/documents/PLN-12",
  "versionContent": "## Plan\n…",
  "version": {
    "id": "c1d2…",
    "documentId": "3f8a…",
    "version": 5,
    "content": "## Plan\n…",
    "createdById": "71d0…",
    "createdAt": "2026-10-03T08:30:00.000Z"
  },
  "inlineImages": [
    {
      "placeholder": "{{diagram}}",
      "attachmentId": "a1b2…",
      "attachmentRef": "attachment://a1b2…",
      "markdownImage": "![Flow](attachment://a1b2…)",
      "attachment": {
        "id": "a1b2…",
        "artifactId": "3f8a…",
        "filename": "flow.png",
        "mimeType": "image/png",
        "sizeBytes": 48211,
        "purpose": "inline",
        "createdAt": "2026-10-03T08:30:00.000Z",
        "createdById": "71d0…"
      }
    }
  ]
}
  • The document fields the tool passes through include organizationId, projectId, fileName, createdById, createdBy, assigneeId, assignee, approverId, approver, repositorySnapshot, templateForType, sortOrder, createdAt, project, generationStatus, customFields, tags, and latestVersionContent, each when the API returns it.
  • priority: null means the document has no priority. The key is absent only when the API sent no priority at all.
  • versionContent is the API's versionContent, falling back to latestVersionContent.
  • inlineImages appears only when images were created. An attachment's previewUrl is included when the API returns one.
  • When the API returns an operation receipt, the response also carries an operationReceipt object.

Errors: the API refuses placeholders that are missing from content, duplicated, or overlapping, and expanded content over the limit. A document that does not resolve in your organization returns the API's not-found error.

create-document-version(documentId: "PLN-12", content: "## Plan\n\n1. Add retry with backoff\n2. …")

List Document Versions

Tool: list-document-versions Scope: read Underlying API: GET /documents/{documentId}/versions

Lists a document's saved versions, newest first.

NameTypeRequiredDescription
documentIdstringYesDocument UUID or slug (e.g. PRD-7, PLN-12, FEA-42).
limitintegerNo1–100. Default 25.
offsetintegerNoMinimum 0. Default 0.

The API returns every version, and the tool pages the result itself.

Returns a pagination envelope:

{
  "total": 5,
  "offset": 0,
  "limit": 25,
  "returned": 5,
  "hasMore": false,
  "nextOffset": null,
  "items": [
    {
      "id": "c1d2…",
      "version": 5,
      "createdAt": "2026-10-03T08:30:00.000Z",
      "createdById": "71d0…",
      "contentLength": null
    }
  ]
}

The versions list the API returns carries no content, so contentLength is null. Read a version's body with get-document-content.

Errors: a document that does not resolve in your organization returns the API's not-found error.

list-document-versions(documentId: "PLN-12", limit: 5)

On this page