Skip to main content
Glama
mmntm

Weblate MCP Server

by mmntm

getUserStatistics

Retrieve contribution statistics for a specific user in Weblate translation projects to track and analyze translation activity.

Instructions

Get contribution statistics for a specific user

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
usernameYesThe username to get statistics for

Implementation Reference

  • The main execution logic of the getUserStatistics tool. Fetches stats from service, formats them, and returns formatted text content or error.
    async getUserStatistics({ username }: { username: string }) {
      try {
        const stats = await this.statisticsService.getUserStatistics(username);
    
        return {
          content: [
            {
              type: 'text',
              text: this.formatUserStatistics(username, stats),
            },
          ],
        };
      } catch (error) {
        this.logger.error(`Failed to get user statistics for ${username}`, error);
        return {
          content: [
            {
              type: 'text',
              text: `Error getting user statistics: ${error.message}`,
            },
          ],
          isError: true,
        };
      }
    }
  • Zod schema and metadata for the getUserStatistics tool, defining input parameter 'username'.
    @Tool({
      name: 'getUserStatistics',
      description: 'Get contribution statistics for a specific user',
      parameters: z.object({
        username: z.string().describe('The username to get statistics for'),
      }),
    })
  • Service helper that calls Weblate API to retrieve raw user statistics data.
    async getUserStatistics(username: string) {
      try {
        const response = await usersStatisticsRetrieve({
          client: this.clientService.getClient(),
          path: { username },
          query: { format: 'json' },
        });
    
        if (response.error) {
          throw new Error(`Failed to get user statistics: ${response.error}`);
        }
    
        return response.data;
      } catch (error) {
        this.logger.error(`Failed to get user statistics for ${username}`, error);
        throw error;
      }
    }
  • Helper function to format the raw statistics into a user-friendly markdown string.
      private formatUserStatistics(username: string, stats: any): string {
        const getStatValue = (key: string, defaultValue = 'N/A') => {
          return stats?.[key] !== undefined ? stats[key] : defaultValue;
        };
    
        return `## 👤 User Statistics: ${stats?.full_name || username}
    
    **User Details:**
    - 👤 Username: ${getStatValue('username')}
    - 📧 Email: ${getStatValue('email')}
    - 📅 Joined: ${stats?.date_joined ? new Date(stats.date_joined).toLocaleDateString() : 'N/A'}
    
    **Contribution Stats:**
    - ✏️ Translations: ${getStatValue('translated')}
    - ✅ Approved: ${getStatValue('approved')}
    - 💡 Suggestions: ${getStatValue('suggestions')}
    - 💬 Comments: ${getStatValue('comments')}
    
    **Activity:**
    - 📈 Total Changes: ${getStatValue('total_changes')}
    - 🗓️ Last Activity: ${stats?.last_login ? new Date(stats.last_login).toLocaleDateString() : '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. It states the action but doesn't mention whether this is a read-only operation, if it requires authentication, what the output format might be, or any rate limits. For a tool with no annotations, this is a significant gap in transparency.

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 unnecessary words. It's front-loaded and wastes no space, making it easy for an agent to parse quickly and understand the core function.

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

Completeness2/5

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

Given the lack of annotations and output schema, the description is incomplete for effective tool use. It doesn't explain what 'contribution statistics' entail, the return format, or any behavioral traits like error handling. For a tool with no structured support, the description should provide more context to compensate.

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 the single parameter 'username' clearly documented in the schema. The description adds no additional semantic context beyond what the schema provides, such as examples or constraints on the username format, so it meets the baseline for adequate but unenriched parameter information.

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 ('contribution statistics for a specific user'), making the purpose unambiguous. However, it doesn't distinguish this tool from similar siblings like 'getTranslationStatistics' or 'getComponentStatistics', which also retrieve statistics but for different entities, leaving room for potential confusion about scope.

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 siblings like 'getChangesByUser' or 'getTranslationStatistics', there's no indication of whether this tool is for aggregated contributions, specific metrics, or how it differs in context, leaving the agent to infer usage from the 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