Skip to main content
Glama
trainual

Tiptap Collaboration MCP Server

by trainual

update_document

Modify collaborative documents by updating or appending content in Tiptap JSON format, specifying the document ID and update mode (replace or append).

Instructions

Update a collaborative document with new content

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYesDocument content in Tiptap JSON format
idYesID of the document to update
modeNoUpdate mode: replace entire document or append content (default: replace)

Implementation Reference

  • The handler function that implements the core logic of the 'update-document' tool. It performs an HTTP PATCH request to the API to update the document content, handles specific error codes (404, 422), and returns structured content responses.
    async ({ id, content, mode = 'replace' }) => {
      try {
        const headers: Record<string, string> = {
          'User-Agent': 'tiptap-collaboration-mcp',
          'Content-Type': 'application/json',
        };
    
        const token = getToken();
        if (token) headers['Authorization'] = token;
    
        const response = await fetch(`${getBaseUrl()}/api/documents/${id}?mode=${mode}`, {
          method: 'PATCH',
          headers,
          body: JSON.stringify(content),
        });
    
        if (!response.ok) {
          if (response.status === 404) {
            return {
              content: [
                {
                  type: 'text',
                  text: `Document with ID ${id} not found.`,
                },
              ],
            };
          }
          if (response.status === 422) {
            return {
              content: [
                {
                  type: 'text',
                  text: `Invalid payload or update cannot be applied to document ${id}.`,
                },
              ],
            };
          }
          return {
            content: [
              {
                type: 'text',
                text: `Failed to update document. HTTP error: ${response.status} ${response.statusText}`,
              },
            ],
          };
        }
    
        return {
          content: [
            {
              type: 'text',
              text: `Document with ID ${id} updated successfully using ${mode} mode.`,
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: `Error updating document: ${
                error instanceof Error ? error.message : 'Unknown error'
              }`,
            },
          ],
        };
      }
    }
  • Zod schema for the tool's input parameters: document ID, content object, and optional update mode.
    {
      id: z.string().describe('ID of the document to update'),
      content: z.object({}).describe('Document content in Tiptap JSON format'),
      mode: z.enum(['replace', 'append']).optional().describe('Update mode: replace entire document or append content (default: replace)'),
    },
  • The registration function exported from the tool module, which calls server.tool to register the 'update-document' tool with its schema and handler.
    export default function registerUpdateDocument(
      server: McpServer,
      getBaseUrl: () => string,
      getToken: () => string | undefined
    ) {
      server.tool(
        'update-document',
        'Update a collaborative document with new content',
        {
          id: z.string().describe('ID of the document to update'),
          content: z.object({}).describe('Document content in Tiptap JSON format'),
          mode: z.enum(['replace', 'append']).optional().describe('Update mode: replace entire document or append content (default: replace)'),
        },
        async ({ id, content, mode = 'replace' }) => {
          try {
            const headers: Record<string, string> = {
              'User-Agent': 'tiptap-collaboration-mcp',
              'Content-Type': 'application/json',
            };
    
            const token = getToken();
            if (token) headers['Authorization'] = token;
    
            const response = await fetch(`${getBaseUrl()}/api/documents/${id}?mode=${mode}`, {
              method: 'PATCH',
              headers,
              body: JSON.stringify(content),
            });
    
            if (!response.ok) {
              if (response.status === 404) {
                return {
                  content: [
                    {
                      type: 'text',
                      text: `Document with ID ${id} not found.`,
                    },
                  ],
                };
              }
              if (response.status === 422) {
                return {
                  content: [
                    {
                      type: 'text',
                      text: `Invalid payload or update cannot be applied to document ${id}.`,
                    },
                  ],
                };
              }
              return {
                content: [
                  {
                    type: 'text',
                    text: `Failed to update document. HTTP error: ${response.status} ${response.statusText}`,
                  },
                ],
              };
            }
    
            return {
              content: [
                {
                  type: 'text',
                  text: `Document with ID ${id} updated successfully using ${mode} mode.`,
                },
              ],
            };
          } catch (error) {
            return {
              content: [
                {
                  type: 'text',
                  text: `Error updating document: ${
                    error instanceof Error ? error.message : 'Unknown error'
                  }`,
                },
              ],
            };
          }
        }
      );
    }
  • src/server.ts:59-59 (registration)
    Invocation of the registerUpdateDocument function on the main MCP server instance, integrating the tool into the server.
    registerUpdateDocument(server, getBaseUrl, getToken);
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. While 'update' implies mutation, it doesn't specify whether this requires specific permissions, whether changes are reversible, potential rate limits, or what happens to existing content not mentioned. For a mutation tool with zero annotation coverage, this leaves significant behavioral questions unanswered.

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 a single, efficient sentence that gets straight to the point with zero wasted words. It's appropriately sized for a basic update operation and front-loads the essential information without unnecessary elaboration.

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

Completeness2/5

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

For a mutation tool with no annotations and no output schema, the description is insufficient. It doesn't address important contextual aspects like what permissions are needed, whether the operation is idempotent, what the response contains, or how it differs from other document modification tools in the sibling list. The 100% schema coverage helps with parameters, but the overall context remains incomplete.

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

Parameters3/5

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

The schema has 100% description coverage, so the parameters are well-documented in the structured data. The description doesn't add any meaningful parameter semantics beyond what's already in the schema - it mentions 'new content' which aligns with the 'content' parameter but provides no additional context about format requirements or the implications of different 'mode' settings.

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

Purpose4/5

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

The description clearly states the verb ('update') and resource ('collaborative document') with the action ('with new content'), making the purpose immediately understandable. However, it doesn't distinguish this tool from potential alternatives like 'duplicate_document' or 'encrypt_document' that might also modify documents in different ways.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like 'create_document', 'duplicate_document', or 'encrypt_document'. There's no mention of prerequisites (e.g., needing an existing document ID) or when other tools might be more appropriate for different document modification scenarios.

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

Related 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/trainual/tiptap-collaboration-mcp'

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