Skip to main content
Glama
trainual

Tiptap Collaboration MCP Server

by trainual

create_document

Initiate a collaborative document with a specified name and optional initial content using the Tiptap Collaboration MCP Server for efficient team editing and management.

Instructions

Create a new collaborative document

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentNoInitial content for the document
nameYesName of the document

Implementation Reference

  • The asynchronous function that executes the 'create-document' tool logic. It makes a POST request to the /api/documents/{name} endpoint with the provided content in Tiptap JSON format, handles various HTTP responses including errors like 409 (already exists), and returns formatted text content indicating success or failure.
    async ({ name, content }) => {
      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/${name}?format=json`,
          {
            method: 'POST',
            headers,
            body: JSON.stringify(content),
          }
        );
    
        if (!response.ok) {
          if (response.status === 409) {
            return {
              content: [
                {
                  type: 'text',
                  text: `Document with name ${name} already exists. Choose a different name or delete the existing document first.`,
                },
              ],
            };
          }
          return {
            content: [
              {
                type: 'text',
                text: `Failed to create document. HTTP error: ${response.status} ${response.statusText}`,
              },
            ],
          };
        }
    
        // Handle successful response - 204 No Content means success with empty body
        if (response.status === 204) {
          return {
            content: [
              {
                type: 'text',
                text: `Document '${name}' created successfully.`,
              },
            ],
          };
        }
    
        // For other success status codes, try to parse JSON response
        try {
          const documentData = await response.json();
          return {
            content: [
              {
                type: 'text',
                text: `Document created successfully: ${JSON.stringify(
                  documentData,
                  null,
                  2
                )}`,
              },
            ],
          };
        } catch (parseError) {
          // If JSON parsing fails, just return success message
          return {
            content: [
              {
                type: 'text',
                text: `Document '${name}' created successfully (no response data).`,
              },
            ],
          };
        }
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: `Error creating document: ${
                error instanceof Error ? error.message : 'Unknown error'
              }`,
            },
          ],
        };
      }
    }
  • Zod schema for the tool inputs: 'name' (required string) and 'content' (optional Tiptap JSON object with a sensible default).
    {
      name: z.string().describe('name of the new document'),
      content: z
        .object({})
        .passthrough()
        .default({
          type: 'doc',
          content: [
            {
              type: 'paragraph',
              attrs: {
                indent: 0,
                textAlign: 'left',
              },
              content: [
                {
                  text: 'Test',
                  type: 'text',
                },
              ],
            },
          ],
        })
        .describe(
          'Document content in Tiptap JSON format (uses default if not provided)'
        ),
    },
  • The server.tool() call that registers the 'create-document' tool with its name, description, input schema, and handler function within the registerCreateDocument module.
    server.tool(
      'create-document',
      'Create a new collaborative document',
      {
        name: z.string().describe('name of the new document'),
        content: z
          .object({})
          .passthrough()
          .default({
            type: 'doc',
            content: [
              {
                type: 'paragraph',
                attrs: {
                  indent: 0,
                  textAlign: 'left',
                },
                content: [
                  {
                    text: 'Test',
                    type: 'text',
                  },
                ],
              },
            ],
          })
          .describe(
            'Document content in Tiptap JSON format (uses default if not provided)'
          ),
      },
      async ({ name, content }) => {
        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/${name}?format=json`,
            {
              method: 'POST',
              headers,
              body: JSON.stringify(content),
            }
          );
    
          if (!response.ok) {
            if (response.status === 409) {
              return {
                content: [
                  {
                    type: 'text',
                    text: `Document with name ${name} already exists. Choose a different name or delete the existing document first.`,
                  },
                ],
              };
            }
            return {
              content: [
                {
                  type: 'text',
                  text: `Failed to create document. HTTP error: ${response.status} ${response.statusText}`,
                },
              ],
            };
          }
    
          // Handle successful response - 204 No Content means success with empty body
          if (response.status === 204) {
            return {
              content: [
                {
                  type: 'text',
                  text: `Document '${name}' created successfully.`,
                },
              ],
            };
          }
    
          // For other success status codes, try to parse JSON response
          try {
            const documentData = await response.json();
            return {
              content: [
                {
                  type: 'text',
                  text: `Document created successfully: ${JSON.stringify(
                    documentData,
                    null,
                    2
                  )}`,
                },
              ],
            };
          } catch (parseError) {
            // If JSON parsing fails, just return success message
            return {
              content: [
                {
                  type: 'text',
                  text: `Document '${name}' created successfully (no response data).`,
                },
              ],
            };
          }
        } catch (error) {
          return {
            content: [
              {
                type: 'text',
                text: `Error creating document: ${
                  error instanceof Error ? error.message : 'Unknown error'
                }`,
              },
            ],
          };
        }
      }
    );
  • src/server.ts:47-47 (registration)
    The call to registerCreateDocument which sets up the tool on the main McpServer instance.
    registerCreateDocument(server, getBaseUrl, getToken);
  • src/server.ts:3-3 (registration)
    Import of the registerCreateDocument function used to register the tool.
    import registerCreateDocument from './tools/create-document.js';
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. 'Create a new collaborative document' implies a write operation but doesn't specify permissions needed, whether the document becomes immediately editable, what happens if a document with the same name exists, or any rate limits. This leaves significant behavioral questions unanswered for a creation tool.

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 simple creation tool and front-loads the essential information.

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 document creation tool with no annotations and no output schema, the description is insufficient. It doesn't explain what happens after creation, what the collaborative aspects entail, how to access the created document, or address any potential constraints. Given the complexity of collaborative document systems and the lack of structured metadata, more context is needed.

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 description provides no parameter information, but the input schema has 100% description coverage with clear documentation for both 'content' and 'name' parameters. Since schema coverage is high, the baseline score of 3 is appropriate - the schema does the heavy lifting for parameter documentation.

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 action ('Create') and resource ('collaborative document'), making the purpose immediately understandable. However, it doesn't differentiate this tool from sibling tools like 'duplicate_document' or 'import_markdown', which also create documents through different mechanisms.

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. With siblings like 'batch_import_documents', 'duplicate_document', 'import_markdown', and 'update_document', there's no indication of when this specific creation method is appropriate versus those other document creation or modification tools.

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