Skip to main content
Glama
mmntm

Weblate MCP Server

by mmntm

getProjectStatistics

Analyze project data by retrieving statistics such as completion rates and string counts for translation projects managed on the Weblate MCP Server.

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 MCP tool handler function that invokes the statistics service, formats the results, and returns MCP-formatted content or error.
    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, }; } }
  • Registers the tool in the MCP framework using the @Tool decorator, specifying name, description, and input schema.
    @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'), }), })
  • Zod schema defining the input parameter 'projectSlug' as a required string.
    parameters: z.object({ projectSlug: z.string().describe('The slug of the project'), }),
  • Helper service method that retrieves raw project statistics from the Weblate API.
    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; } }
  • Helper method to format raw statistics into a human-readable Markdown string for the tool response.
    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'}`; }

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