Skip to main content
Glama
trainual

Tiptap Collaboration MCP Server

by trainual

get_document_statistics

Retrieve real-time statistics for a collaborative document, including active connections and connected IPs, to monitor usage and activity effectively.

Instructions

Get real-time statistics for a specific document including current connections and connected IPs

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesID of the document to get statistics for

Implementation Reference

  • The handler function that performs an HTTP fetch to the document statistics API endpoint, processes the response, and returns structured text content or error messages.
    async ({ id }) => {
      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}/statistics`, { headers });
    
        if (!response.ok) {
          if (response.status === 404) {
            return {
              content: [
                {
                  type: 'text',
                  text: `Document with ID ${id} not found.`,
                },
              ],
            };
          }
          return {
            content: [
              {
                type: 'text',
                text: `Failed to retrieve document statistics. HTTP error: ${response.status} ${response.statusText}`,
              },
            ],
          };
        }
    
        const statistics = await response.json();
    
        return {
          content: [
            {
              type: 'text',
              text: `Document Statistics for ${id}: ${JSON.stringify(statistics, null, 2)}`,
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: `Error retrieving document statistics: ${
                error instanceof Error ? error.message : 'Unknown error'
              }`,
            },
          ],
        };
      }
    }
  • Input schema using Zod, defining the required 'id' parameter as a string with description.
    {
      id: z.string().describe('ID of the document to get statistics for'),
    },
  • The exported registration function that calls server.tool() to register the 'get-document-statistics' tool with its name, description, schema, and handler on the MCP server.
    export default function registerGetDocumentStatistics(
      server: McpServer,
      getBaseUrl: () => string,
      getToken: () => string | undefined
    ) {
      server.tool(
        'get-document-statistics',
        'Get real-time statistics for a specific document including current connections and connected IPs',
        {
          id: z.string().describe('ID of the document to get statistics for'),
        },
        async ({ id }) => {
          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}/statistics`, { headers });
    
            if (!response.ok) {
              if (response.status === 404) {
                return {
                  content: [
                    {
                      type: 'text',
                      text: `Document with ID ${id} not found.`,
                    },
                  ],
                };
              }
              return {
                content: [
                  {
                    type: 'text',
                    text: `Failed to retrieve document statistics. HTTP error: ${response.status} ${response.statusText}`,
                  },
                ],
              };
            }
    
            const statistics = await response.json();
    
            return {
              content: [
                {
                  type: 'text',
                  text: `Document Statistics for ${id}: ${JSON.stringify(statistics, null, 2)}`,
                },
              ],
            };
          } catch (error) {
            return {
              content: [
                {
                  type: 'text',
                  text: `Error retrieving document statistics: ${
                    error instanceof Error ? error.message : 'Unknown error'
                  }`,
                },
              ],
            };
          }
        }
      );
    }
  • src/server.ts:54-54 (registration)
    The call to registerGetDocumentStatistics in the main server file, passing the server instance and utility functions for base URL and token.
    registerGetDocumentStatistics(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. It mentions 'real-time statistics' which implies freshness and possibly dynamic data, but doesn't cover critical aspects like whether this is a read-only operation, if it requires specific permissions, rate limits, or what the output format looks like (e.g., JSON structure). This leaves significant gaps for a tool that likely involves sensitive connection data.

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 front-loads the core purpose ('Get real-time statistics for a specific document') and adds specific details ('including current connections and connected IPs') without any wasted words. It's appropriately sized for a simple tool.

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?

Given the complexity of retrieving real-time connection data (which may involve permissions or sensitive info), no annotations, and no output schema, the description is insufficient. It doesn't explain what 'statistics' entail beyond connections/IPs, how data is returned, or any behavioral constraints, leaving the agent under-informed for safe and effective use.

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 description coverage is 100%, with the single parameter 'id' clearly documented as 'ID of the document to get statistics for'. The description adds no additional semantic context beyond this, such as format examples or constraints, so it meets the baseline for high schema coverage without compensating value.

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 'Get' and the resource 'real-time statistics for a specific document', specifying what statistics are included (current connections and connected IPs). It distinguishes from siblings like 'get_document' (which likely retrieves content) and 'get_server_statistics' (which is broader), but doesn't explicitly name these distinctions.

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 'get_document' or 'get_server_statistics', nor does it mention prerequisites such as needing an existing document ID. It only states what it does, not when it's appropriate.

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