Skip to main content
Glama
mmntm

Weblate MCP Server

by mmntm

getComponentStatistics

Retrieve detailed statistics for a translation component to monitor translation progress, identify untranslated strings, and track completion rates in Weblate projects.

Instructions

Get detailed statistics for a specific component

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectSlugYesThe slug of the project
componentSlugYesThe slug of the component

Implementation Reference

  • Primary handler decorated with @Tool decorator. Defines input schema, fetches statistics from service, formats response as markdown text, and handles errors.
    @Tool({
      name: 'getComponentStatistics',
      description: 'Get detailed statistics for a specific component',
      parameters: z.object({
        projectSlug: z.string().describe('The slug of the project'),
        componentSlug: z.string().describe('The slug of the component'),
      }),
    })
    async getComponentStatistics({
      projectSlug,
      componentSlug,
    }: {
      projectSlug: string;
      componentSlug: string;
    }) {
      try {
        const stats = await this.statisticsService.getComponentStatistics(projectSlug, componentSlug);
    
        return {
          content: [
            {
              type: 'text',
              text: this.formatComponentStatistics(projectSlug, componentSlug, stats),
            },
          ],
        };
      } catch (error) {
        this.logger.error(`Failed to get component statistics for ${projectSlug}/${componentSlug}`, error);
        return {
          content: [
            {
              type: 'text',
              text: `Error getting component statistics: ${error.message}`,
            },
          ],
          isError: true,
        };
      }
    }
  • Zod schema for input parameters: projectSlug and componentSlug.
    parameters: z.object({
      projectSlug: z.string().describe('The slug of the project'),
      componentSlug: z.string().describe('The slug of the component'),
    }),
  • The WeblateStatisticsTool is registered as a provider in the AppModule, enabling its tools to be available via MCP.
      WeblateChangesTool,
      WeblateStatisticsTool,
    ],
  • Service method that retrieves raw component statistics from Weblate API using componentsStatisticsRetrieve.
    async getComponentStatistics(projectSlug: string, componentSlug: string) {
      try {
        const response = await componentsStatisticsRetrieve({
          client: this.clientService.getClient(),
          path: { 
            project__slug: projectSlug,
            slug: componentSlug 
          },
          query: { format: 'json' },
        });
    
        if (response.error) {
          throw new Error(`Failed to get component statistics: ${response.error}`);
        }
    
        return response.data;
      } catch (error) {
        this.logger.error(`Failed to get component statistics for ${projectSlug}/${componentSlug}`, error);
        throw error;
      }
    }
  • Utility method to format the raw statistics data into a readable markdown string for the tool response.
      private formatComponentStatistics(projectSlug: string, componentSlug: 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 `## 📊 Component Statistics: ${stats?.name || componentSlug}
    
    **Project:** ${projectSlug}
    **Component:** ${componentSlug}
    
    **Translation Progress:**
    - 🎯 Translated: ${formatPercent(getStatValue('translated_percent'))}
    - ✅ Approved: ${formatPercent(getStatValue('approved_percent'))}
    - 🔍 Needs Review: ${formatPercent(getStatValue('readonly_percent'))}
    - ❌ Untranslated: ${formatPercent(getStatValue('nottranslated_percent'))}
    
    **String Counts:**
    - 📝 Total: ${getStatValue('total')}
    - ✅ Translated: ${getStatValue('translated')}
    - 🎯 Approved: ${getStatValue('approved')}
    - ❌ Untranslated: ${getStatValue('nottranslated')}
    
    **Component Details:**
    - 🌐 URL: ${stats?.web_url || 'N/A'}
    - 📁 Source Language: ${stats?.source_language?.name || 'N/A'} (${stats?.source_language?.code || 'N/A'})`;
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. While 'Get' implies a read-only operation, the description doesn't disclose important behavioral traits like whether this requires authentication, has rate limits, returns paginated results, or what format the statistics come in. For a statistics retrieval tool with zero annotation coverage, this is a significant gap.

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 gets straight to the point with no wasted words. It's appropriately sized for a simple retrieval tool and front-loads the essential information about what the tool does.

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 that this is a read-only statistics retrieval tool with 2 required parameters and 100% schema coverage, the description is minimally adequate. However, with no annotations and no output schema, the description should ideally provide more context about what kind of statistics are returned and in what format. The current description leaves the agent guessing about the nature of the output.

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 schema description coverage is 100%, with both parameters clearly documented in the schema itself. The description adds no additional parameter semantics beyond what's already in the schema (projectSlug and componentSlug). When schema coverage is this complete, the baseline score is 3 even without parameter information in the description.

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 detailed statistics') and the target resource ('for a specific component'), which provides a specific verb+resource combination. However, it doesn't differentiate this tool from similar sibling tools like 'getComponentLanguageProgress', 'getLanguageStatistics', 'getProjectStatistics', or 'getTranslationStatistics', all of which appear to retrieve statistical data about different entities.

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. With multiple sibling tools that retrieve statistics (e.g., getComponentLanguageProgress, getLanguageStatistics, getProjectStatistics, getTranslationStatistics), there's no indication of what makes this tool distinct or when it should be preferred over those other options.

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