Skip to main content
Glama
trainual

Tiptap Collaboration MCP Server

by trainual

batch_import_documents

Import multiple documents in bulk into Tiptap Collaboration MCP Server using a structured JSON format, enabling efficient document versioning and management.

Instructions

Import multiple documents in bulk using a predefined JSON structure

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
documentsYesArray of document arrays, where each inner array represents versions of a single document

Implementation Reference

  • The handler function for the 'batch-import-documents' tool. It sends a PUT request to `/api/admin/batch-import` with the provided documents data, handles errors, and returns success or error messages.
    async ({ documents }) => {
      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/admin/batch-import`, {
          method: 'PUT',
          headers,
          body: JSON.stringify(documents),
        });
    
        if (!response.ok) {
          if (response.status === 400) {
            return {
              content: [
                {
                  type: 'text',
                  text: 'Invalid data provided for batch import. Please check the document structure and format.',
                },
              ],
            };
          }
          return {
            content: [
              {
                type: 'text',
                text: `Failed to import documents. HTTP error: ${response.status} ${response.statusText}`,
              },
            ],
          };
        }
    
        return {
          content: [
            {
              type: 'text',
              text: `Successfully imported ${documents.length} document groups with their versions.`,
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: `Error importing documents: ${
                error instanceof Error ? error.message : 'Unknown error'
              }`,
            },
          ],
        };
      }
    }
  • Zod schema defining the input parameters for the tool: an array of arrays of document objects, each containing created_at, version, name, and tiptap_json.
    {
      documents: z.array(z.array(z.object({
        created_at: z.string().describe('Creation timestamp in ISO format'),
        version: z.number().describe('Document version number'),
        name: z.string().describe('Document name/identifier'),
        tiptap_json: z.object({}).describe('Document content in Tiptap JSON format'),
      }))).describe('Array of document arrays, where each inner array represents versions of a single document'),
    },
  • The registration function `registerBatchImportDocuments` that defines and registers the 'batch-import-documents' tool on the MCP server, including name, description, schema, and handler.
    export default function registerBatchImportDocuments(
      server: McpServer,
      getBaseUrl: () => string,
      getToken: () => string | undefined
    ) {
      server.tool(
        'batch-import-documents',
        'Bulk import multiple documents using predefined JSON structure',
        {
          documents: z.array(z.array(z.object({
            created_at: z.string().describe('Creation timestamp in ISO format'),
            version: z.number().describe('Document version number'),
            name: z.string().describe('Document name/identifier'),
            tiptap_json: z.object({}).describe('Document content in Tiptap JSON format'),
          }))).describe('Array of document arrays, where each inner array represents versions of a single document'),
        },
        async ({ documents }) => {
          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/admin/batch-import`, {
              method: 'PUT',
              headers,
              body: JSON.stringify(documents),
            });
    
            if (!response.ok) {
              if (response.status === 400) {
                return {
                  content: [
                    {
                      type: 'text',
                      text: 'Invalid data provided for batch import. Please check the document structure and format.',
                    },
                  ],
                };
              }
              return {
                content: [
                  {
                    type: 'text',
                    text: `Failed to import documents. HTTP error: ${response.status} ${response.statusText}`,
                  },
                ],
              };
            }
    
            return {
              content: [
                {
                  type: 'text',
                  text: `Successfully imported ${documents.length} document groups with their versions.`,
                },
              ],
            };
          } catch (error) {
            return {
              content: [
                {
                  type: 'text',
                  text: `Error importing documents: ${
                    error instanceof Error ? error.message : 'Unknown error'
                  }`,
                },
              ],
            };
          }
        }
      );
    }
  • src/server.ts:46-46 (registration)
    Invocation of the registration function in the main server file to register the tool.
    registerBatchImportDocuments(server, getBaseUrl, getToken);
  • src/server.ts:2-2 (registration)
    Import of the registration module for the batch import documents tool.
    import registerBatchImportDocuments from './tools/batch-import-documents.js';
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. It states 'Import' which implies a write operation, but doesn't clarify permissions required, whether it overwrites existing documents, error handling for invalid data, or the response format. This leaves significant gaps for a mutation tool with potential side effects.

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 directly states the tool's function without unnecessary words. It's appropriately sized for a tool with one parameter and good schema coverage, making it easy to parse while conveying 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 mutation tool with no annotations and no output schema, the description is inadequate. It doesn't explain what happens after import (success/failure responses), doesn't mention constraints like size limits or rate limits, and provides minimal guidance on usage context. Given the complexity of bulk operations and lack of structured safety information, more behavioral 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?

Schema description coverage is 100%, so the schema fully documents the single 'documents' parameter and its nested structure. The description adds minimal value by mentioning 'predefined JSON structure' which aligns with the schema, but doesn't provide additional context about format expectations or usage examples beyond what's in the schema descriptions.

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 ('Import multiple documents in bulk') and the method ('using a predefined JSON structure'), which distinguishes it from single-document operations like create_document. However, it doesn't explicitly differentiate from other import-related tools like import_markdown, leaving some ambiguity about when to choose this specific bulk import method.

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 for single documents or import_markdown for different formats. It mentions 'bulk' but doesn't specify thresholds or scenarios where batch processing is preferred, nor does it mention prerequisites or constraints for bulk 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

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