db_stats
Retrieve global statistics for a YOURLS URL shortener instance, including click data and usage metrics, to monitor and analyze performance.
Instructions
Get global statistics for the YOURLS instance
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/dbStats.js:16-47 (handler)The createDbStatsTool factory function defines the MCP tool 'db_stats' including its name, description, input schema (empty), and the main execute handler that fetches database statistics from the YOURLS API via yourlsClient.dbStats() and formats the response using createMcpResponse.export default function createDbStatsTool(yourlsClient) { return { name: 'db_stats', description: 'Get global statistics for the YOURLS instance', inputSchema: { type: 'object', properties: {} }, execute: async () => { try { const result = await yourlsClient.dbStats(); if (result['db-stats']) { const stats = result['db-stats']; return createMcpResponse(true, { total_links: stats.total_links || 0, total_clicks: stats.total_clicks || 0 }); } else { return createMcpResponse(false, { message: result.message || 'Unknown error', code: result.code || 'unknown' }); } } catch (error) { return createMcpResponse(false, { message: error.message }); } } }; }
- src/index.js:161-166 (registration)Registration of the db_stats tool with the MCP server using server.tool(), providing name, description, empty input schema ({}), and the execute handler.server.tool( dbStatsTool.name, dbStatsTool.description, {}, dbStatsTool.execute );
- src/api.js:386-388 (helper)The underlying dbStats method in YourlsClient class that makes the 'db-stats' API request to the YOURLS server, called by the tool handler.async dbStats() { return this.request('db-stats', {}); }
- src/tools/dbStats.js:20-22 (schema)Input schema definition for the db_stats tool: an empty object indicating no input parameters required.inputSchema: { type: 'object', properties: {}