Skip to main content
Glama
mmntm

Weblate MCP Server

by mmntm

getLanguageStatistics

Retrieve translation statistics for a specific language code across all Weblate projects to monitor progress and identify areas needing attention.

Instructions

Get statistics for a specific language across all projects

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
languageCodeYesThe language code (e.g., en, es, fr)

Implementation Reference

  • The @Tool-decorated handler function implementing the core logic for the getLanguageStatistics tool. It fetches statistics from the service, formats them, and returns a structured response or error.
    @Tool({
      name: 'getLanguageStatistics',
      description: 'Get statistics for a specific language across all projects',
      parameters: z.object({
        languageCode: z.string().describe('The language code (e.g., en, es, fr)'),
      }),
    })
    async getLanguageStatistics({ languageCode }: { languageCode: string }) {
      try {
        const stats = await this.statisticsService.getLanguageStatistics(languageCode);
    
        return {
          content: [
            {
              type: 'text',
              text: this.formatLanguageStatistics(languageCode, stats),
            },
          ],
        };
      } catch (error) {
        this.logger.error(`Failed to get language statistics for ${languageCode}`, error);
        return {
          content: [
            {
              type: 'text',
              text: `Error getting language statistics: ${error.message}`,
            },
          ],
          isError: true,
        };
      }
    }
  • Zod schema defining the input parameter 'languageCode' for the tool.
    parameters: z.object({
      languageCode: z.string().describe('The language code (e.g., en, es, fr)'),
    }),
  • The WeblateStatisticsTool class (containing the getLanguageStatistics handler) is registered as a provider in the root AppModule, making its tools available via MCP.
      WeblateProjectsTool,
      WeblateComponentsTool,
      WeblateLanguagesTool,
      WeblateTranslationsTool,
      WeblateChangesTool,
      WeblateStatisticsTool,
    ],
  • Helper service method that calls the Weblate API to retrieve raw language statistics data, invoked by the tool handler.
    async getLanguageStatistics(languageCode: string) {
      try {
        const response = await languagesStatisticsRetrieve({
          client: this.clientService.getClient(),
          path: { code: languageCode },
          query: { format: 'json' },
        });
    
        if (response.error) {
          throw new Error(`Failed to get language statistics: ${response.error}`);
        }
    
        return response.data;
      } catch (error) {
        this.logger.error(`Failed to get language statistics for ${languageCode}`, error);
        throw error;
      }
    }
  • Private helper method to format the raw statistics into a human-readable markdown string for the tool response.
      private formatLanguageStatistics(languageCode: 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 `## 🌐 Language Statistics: ${stats?.name || languageCode}
    
    **Language Details:**
    - 📛 Name: ${getStatValue('name')}
    - 🔤 Code: ${getStatValue('code')}
    - 📍 Direction: ${getStatValue('direction', 'ltr')}
    
    **Overall Progress:**
    - 🎯 Translated: ${formatPercent(getStatValue('translated_percent'))}
    - ✅ Approved: ${formatPercent(getStatValue('approved_percent'))}
    - ❌ Untranslated: ${formatPercent(getStatValue('nottranslated_percent'))}
    
    **String Counts:**
    - 📝 Total: ${getStatValue('total')}
    - ✅ Translated: ${getStatValue('translated')}
    - 🎯 Approved: ${getStatValue('approved')}
    - ❌ Untranslated: ${getStatValue('nottranslated')}`;
      }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. While 'Get statistics' implies a read-only operation, it doesn't specify whether this requires authentication, has rate limits, returns aggregated data, or what format the statistics take. For a tool with zero annotation coverage, this leaves significant behavioral gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without any unnecessary words. It's appropriately sized for a simple tool with one parameter and gets straight to the point.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a single-parameter read operation with no output schema, the description is minimally adequate but lacks important context. It doesn't explain what kind of statistics are returned (e.g., translation progress, string counts, user activity) or how the 'across all projects' aggregation works, which would be helpful given the complexity implied by statistics gathering.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100% (the single parameter 'languageCode' is fully documented in the schema), so the baseline is 3. The description adds no additional parameter information beyond what the schema already provides about the languageCode parameter.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Get statistics') and resource ('for a specific language across all projects'), providing a specific verb+resource combination. However, it doesn't explicitly differentiate from sibling tools like 'getTranslationStatistics' or 'getComponentLanguageProgress', which might have overlapping functionality.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'getTranslationStatistics' or 'getProjectStatistics'. It doesn't mention prerequisites, exclusions, or specific scenarios where this tool is preferred over other statistics-related tools in the sibling list.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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