Skip to main content
Glama

YOURLS-MCP

by kesslerio
dbStats.js1.43 kB
/** * Database Statistics tool implementation * * Uses the standardized MCP response format via createMcpResponse utility: * - Success: {content: [{type: 'text', text: JSON.stringify({status: 'success', ...data})}]} * - Error: {content: [{type: 'text', text: JSON.stringify({status: 'error', ...data})}], isError: true} */ import { createMcpResponse } from '../utils.js'; /** * Create a database statistics tool * * @param {object} yourlsClient - YOURLS API client * @returns {object} Tool definition with standardized MCP response format */ 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 }); } } }; }

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/kesslerio/yourls-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server