Skip to main content
Glama
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

NameRequiredDescriptionDefault
idYesID of the document to get statistics for

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "id": { "description": "ID of the document to get statistics for", "type": "string" } }, "required": [ "id" ], "type": "object" }

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);

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