getProjectDashboard
Generate a detailed dashboard to track and analyze project statistics, including translation components, using the project slug for Weblate MCP Server.
Instructions
Get a comprehensive dashboard overview for a project with all component statistics
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectSlug | Yes | The slug of the project |
Implementation Reference
- src/tools/statistics.tool.ts:89-119 (handler)The primary handler for the 'getProjectDashboard' tool, including @Tool decorator with name, description, input schema, and the async function logic that delegates to the statistics service and formats the response.@Tool({ name: 'getProjectDashboard', description: 'Get a comprehensive dashboard overview for a project with all component statistics', parameters: z.object({ projectSlug: z.string().describe('The slug of the project'), }), }) async getProjectDashboard({ projectSlug }: { projectSlug: string }) { try { const dashboard = await this.statisticsService.getProjectDashboard(projectSlug); return { content: [ { type: 'text', text: this.formatProjectDashboard(projectSlug, dashboard), }, ], }; } catch (error) { this.logger.error(`Failed to get project dashboard for ${projectSlug}`, error); return { content: [ { type: 'text', text: `Error getting project dashboard: ${error.message}`, }, ], isError: true, }; }
- src/app.module.ts:79-79 (registration)The WeblateStatisticsTool class is registered as a provider in the AppModule, enabling NestJS to discover and expose its @Tool-decorated methods as MCP tools.WeblateStatisticsTool,
- Core helper method in the statistics service that aggregates project statistics and per-component statistics to construct the full dashboard data./** * Get dashboard overview for a project with all component statistics */ async getProjectDashboard(projectSlug: string) { try { // Get project info and components const [projectStats, components] = await Promise.all([ this.getProjectStatistics(projectSlug), this.componentsService.listComponents(projectSlug), ]); // Get statistics for each component const componentStats = await Promise.all( components.map(async (component) => { try { const stats = await this.getComponentStatistics(projectSlug, component.slug); return { component: component.name, slug: component.slug, statistics: stats, }; } catch (error) { this.logger.warn(`Failed to get stats for component ${component.slug}`, error); return { component: component.name, slug: component.slug, statistics: null, error: error.message, }; } }), ); return { project: projectStats, components: componentStats, }; } catch (error) { this.logger.error(`Failed to get project dashboard for ${projectSlug}`, error); throw error; } }
- src/tools/statistics.tool.ts:381-410 (helper)Private helper function that formats the raw dashboard data into a human-readable markdown string with project summary and component breakdowns.private formatProjectDashboard(projectSlug: string, dashboard: any): string { const project = dashboard.project; const components = dashboard.components || []; let result = this.formatProjectStatistics(projectSlug, project); result += '\n\n## 📋 Component Breakdown\n\n'; components.forEach((comp: any, index: number) => { if (comp.statistics) { const stats = comp.statistics; const formatPercent = (value: any) => { return typeof value === 'number' ? `${value.toFixed(1)}%` : 'N/A'; }; result += `**${index + 1}. ${comp.component}** (${comp.slug}) - 🎯 Progress: ${formatPercent(stats.translated_percent)} - ✅ Approved: ${formatPercent(stats.approved_percent)} - 📝 Total Strings: ${stats.total || 'N/A'} `; } else { result += `**${index + 1}. ${comp.component}** (${comp.slug}) - ❌ Error: ${comp.error || 'Unable to load statistics'} `; } }); return result; }