Skip to main content
Glama
mmntm

Weblate MCP Server

by mmntm

getProjectDashboard

Retrieve a comprehensive dashboard with component statistics for a Weblate translation project to monitor progress and manage localization workflows.

Instructions

Get a comprehensive dashboard overview for a project with all component statistics

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectSlugYesThe slug of the project

Implementation Reference

  • Tool registration via @Tool decorator, including name, description, and Zod input schema for parameters.
    @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'),
      }),
    })
  • The main handler function that invokes the statistics service, formats the dashboard output, and handles errors.
    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,
        };
      }
  • Private helper method to format the raw dashboard data into a comprehensive Markdown string with project stats 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;
      }
  • Core service method that implements the dashboard logic: fetches project statistics, lists components, retrieves stats for each component, and aggregates results.
    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;
      }
    }

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/mmntm/weblate-mcp'

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