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,
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions 'comprehensive statistics' but doesn't specify what 'comprehensive' entails, such as whether it includes historical data, real-time updates, or aggregated metrics. It also fails to disclose potential limitations like rate limits, authentication requirements, or data freshness, which are critical for a read operation in a project management context.

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 front-loads the core purpose ('Get comprehensive statistics for a project') and includes specific details ('completion rates and string counts'). There is no redundant or unnecessary information, making it highly concise and well-structured for quick understanding.

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?

Given the tool's moderate complexity (a read operation with one parameter) and no output schema, the description is minimally complete. It specifies what statistics are retrieved but lacks details on output format, such as whether it returns JSON with specific fields or aggregated summaries. With no annotations to supplement, it should ideally include more behavioral context to be fully helpful for an AI agent.

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?

The input schema has 100% description coverage, with 'projectSlug' clearly documented as 'The slug of the project'. The description adds no additional parameter semantics beyond this, such as format examples or constraints. Since the schema already provides adequate parameter information, the baseline score of 3 is appropriate, as the description doesn't compensate but doesn't detract either.

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 verb ('Get') and resource ('comprehensive statistics for a project'), specifying what statistics are included ('completion rates and string counts'). It distinguishes from some siblings like 'getProjectDashboard' or 'getProjectChanges' by focusing on statistical metrics rather than dashboard views or change logs. However, it doesn't explicitly differentiate from 'getComponentStatistics' or 'getLanguageStatistics', which might provide similar statistics for different scopes.

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. It doesn't mention prerequisites, such as needing an existing project, or compare it to siblings like 'getProjectDashboard' (which might include statistics) or 'getComponentStatistics' (for component-level stats). Without this context, users must infer usage from the tool name alone.

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