Skip to main content
Glama
mmntm

Weblate MCP Server

by mmntm

getProjectStatistics

Retrieve project statistics including completion rates and string counts to monitor translation progress in Weblate.

Instructions

Get comprehensive statistics for a project including completion rates and string counts

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectSlugYesThe slug of the project

Implementation Reference

  • The primary MCP tool handler for 'getProjectStatistics'. Decorated with @Tool decorator for registration, validates input with Zod schema, delegates to statistics service, formats output using helper method, and handles errors.
    @Tool({ name: 'getProjectStatistics', description: 'Get comprehensive statistics for a project including completion rates and string counts', parameters: z.object({ projectSlug: z.string().describe('The slug of the project'), }), }) async getProjectStatistics({ projectSlug }: { projectSlug: string }) { try { const stats = await this.statisticsService.getProjectStatistics(projectSlug); return { content: [ { type: 'text', text: this.formatProjectStatistics(projectSlug, stats), }, ], }; } catch (error) { this.logger.error(`Failed to get project statistics for ${projectSlug}`, error); return { content: [ { type: 'text', text: `Error getting project statistics: ${error.message}`, }, ], isError: true, }; } }
  • Zod input schema definition for the tool parameters: projectSlug as a required string.
    parameters: z.object({ projectSlug: z.string().describe('The slug of the project'), }),
  • Helper service method that fetches raw project statistics data from the Weblate API using the projectsStatisticsRetrieve function.
    async getProjectStatistics(projectSlug: string) { try { const response = await projectsStatisticsRetrieve({ client: this.clientService.getClient(), path: { slug: projectSlug }, query: { format: 'json' }, }); if (response.error) { throw new Error(`Failed to get project statistics: ${response.error}`); } return response.data; } catch (error) { this.logger.error(`Failed to get project statistics for ${projectSlug}`, error); throw error; } }
  • Private helper method in the tool class that formats the raw statistics data into a human-readable Markdown string with progress percentages and counts.
    private formatProjectStatistics(projectSlug: string, stats: any): string { const getStatValue = (key: string, defaultValue = 'N/A') => { return stats?.[key] !== undefined ? stats[key] : defaultValue; }; const formatPercent = (value: any) => { return typeof value === 'number' ? `${value.toFixed(1)}%` : 'N/A'; }; return `## πŸ“Š Project Statistics: ${stats?.name || projectSlug} **Overall Progress:** - 🎯 Translation Progress: ${formatPercent(getStatValue('translated_percent'))} - βœ… Approved: ${formatPercent(getStatValue('approved_percent'))} - πŸ” Needs Review: ${formatPercent(getStatValue('readonly_percent'))} - ❌ Untranslated: ${formatPercent(getStatValue('nottranslated_percent'))} **String Counts:** - πŸ“ Total Strings: ${getStatValue('total')} - βœ… Translated: ${getStatValue('translated')} - 🎯 Approved: ${getStatValue('approved')} - ❌ Untranslated: ${getStatValue('nottranslated')} - πŸ” Read-only: ${getStatValue('readonly')} **Project Details:** - 🌐 URL: ${stats?.web_url || 'N/A'} - πŸ”— Repository: ${stats?.repository_url || 'N/A'}`; }
  • Registration of the StatisticsService and StatisticsTool in the AppModule providers array, making the tool available to the MCP server.
    WeblateProjectsTool, WeblateComponentsTool, WeblateLanguagesTool, WeblateTranslationsTool, WeblateChangesTool, WeblateStatisticsTool,

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