Skip to main content
Glama
mmntm

Weblate MCP Server

by mmntm

getChangesByUser

Retrieve recent translation changes made by a specific user in Weblate projects to track contributions and review modifications.

Instructions

Get recent changes by a specific user

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
userYesUsername to filter by
limitNoNumber of changes to return (default: 20)

Implementation Reference

  • The primary handler for the 'getChangesByUser' tool. This method is decorated with @Tool, defines its schema, fetches changes using the WeblateApiService, formats the results with helper functions, and returns a structured content response or handles errors.
    @Tool({
      name: 'getChangesByUser',
      description: 'Get recent changes by a specific user',
      parameters: z.object({
        user: z.string().describe('Username to filter by'),
        limit: z.number().optional().describe('Number of changes to return (default: 20)').default(20),
      }),
    })
    async getChangesByUser({
      user,
      limit = 20,
    }: {
      user: string;
      limit?: number;
    }) {
      try {
        const result = await this.weblateApiService.getChangesByUser(user, limit);
    
        if (result.results.length === 0) {
          return {
            content: [
              {
                type: 'text',
                text: `No changes found for user "${user}".`,
              },
            ],
          };
        }
    
        const changesList = result.results
          .slice(0, limit)
          .map(change => this.formatChangeResult(change))
          .join('\n\n---\n\n');
    
        return {
          content: [
            {
              type: 'text',
              text: `Recent changes by user "${user}" (${result.count} total):\n\n${changesList}`,
            },
          ],
        };
      } catch (error) {
        this.logger.error(`Failed to get changes by user ${user}`, error);
        return {
          content: [
            {
              type: 'text',
              text: `Error getting changes by user "${user}": ${error.message}`,
            },
          ],
          isError: true,
        };
      }
    }
  • Registration of the WeblateChangesTool class in the AppModule providers array, which enables automatic registration of all @Tool methods including getChangesByUser with the MCP server.
    WeblateChangesTool,
  • The getChangesByUser tool is explicitly listed in the MCP server instructions string provided to the McpModule.
    - getChangesByUser: Get recent changes by a specific user
  • Helper method used by the handler to format each change into a readable string with action, user, time, and target details.
    private formatChangeResult(change: Change): string {
      const timestamp = change.timestamp ? new Date(change.timestamp).toLocaleString() : 'Unknown';
      const actionDescription = this.getActionDescription(change.action || 0);
      const user = change.user || 'Unknown user';
      const target = change.target || 'N/A';
      
      return `**${actionDescription}**\n**User:** ${user}\n**Time:** ${timestamp}\n**Target:** ${target}`;
    }
  • Underlying service helper that implements getChangesByUser by calling listRecentChanges with user filter, ultimately querying the Weblate API.
    async getChangesByUser(
      user: string,
      limit: number = 50
    ): Promise<{ results: Change[]; count: number; next?: string; previous?: string }> {
      try {
        return this.listRecentChanges(limit, user);
      } catch (error) {
        this.logger.error(`Failed to get changes by user ${user}`, error);
        throw new Error(`Failed to get changes by user: ${error.message}`);
      }
    }

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