get_server_statistics
Retrieve server-wide metrics such as total documents, active connections, and usage statistics to monitor and manage Tiptap collaborative document services efficiently.
Instructions
Get server-wide statistics including total documents, connections, and usage metrics
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {},
"type": "object"
}
Implementation Reference
- src/tools/get-server-statistics.ts:12-56 (handler)Handler function that fetches server statistics via API call to /api/statistics, formats the response as text content, and handles errors gracefully.async () => { 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/statistics`, { headers }); if (!response.ok) { return { content: [ { type: 'text', text: `Failed to retrieve server statistics. HTTP error: ${response.status} ${response.statusText}`, }, ], }; } const statistics = await response.json(); return { content: [ { type: 'text', text: `Server Statistics: ${JSON.stringify(statistics, null, 2)}`, }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error retrieving server statistics: ${ error instanceof Error ? error.message : 'Unknown error' }`, }, ], }; }
- src/tools/get-server-statistics.ts:8-58 (registration)Registers the "get-server-statistics" tool on the MCP server using server.tool(), with tool name, description, empty schema, and handler function.server.tool( 'get-server-statistics', 'Get server-wide statistics including total documents, connections, and usage metrics', {}, async () => { 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/statistics`, { headers }); if (!response.ok) { return { content: [ { type: 'text', text: `Failed to retrieve server statistics. HTTP error: ${response.status} ${response.statusText}`, }, ], }; } const statistics = await response.json(); return { content: [ { type: 'text', text: `Server Statistics: ${JSON.stringify(statistics, null, 2)}`, }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error retrieving server statistics: ${ error instanceof Error ? error.message : 'Unknown error' }`, }, ], }; } } );
- Empty input schema indicating the tool takes no parameters.{},
- src/server.ts:55-55 (registration)Calls the registration function for get_server_statistics tool during main server setup.registerGetServerStatistics(server, getBaseUrl, getToken);