getComponentChanges
Retrieve recent changes for a translation component in Weblate by specifying project and component slugs to track modifications.
Instructions
Get recent changes for a specific component
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectSlug | Yes | The slug of the project | |
| componentSlug | Yes | The slug of the component |
Implementation Reference
- src/tools/changes.tool.ts:129-189 (handler)The primary handler for the 'getComponentChanges' tool, decorated with @Tool decorator. Includes schema definition, execution logic to fetch changes from service, format results using helper methods, and error handling.@Tool({ name: 'getComponentChanges', description: 'Get recent changes 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 getComponentChanges({ projectSlug, componentSlug, }: { projectSlug: string; componentSlug: string; }) { try { const result = await this.weblateApiService.getComponentChanges( projectSlug, componentSlug, ); if (result.results.length === 0) { return { content: [ { type: 'text', text: `No changes found for component "${componentSlug}" in project "${projectSlug}".`, }, ], }; } const changesList = result.results .slice(0, 20) .map(change => this.formatChangeResult(change)) .join('\n\n---\n\n'); return { content: [ { type: 'text', text: `Recent changes in component "${componentSlug}" (${result.count} total):\n\n${changesList}`, }, ], }; } catch (error) { this.logger.error( `Failed to get changes for component ${componentSlug} in project ${projectSlug}`, error, ); return { content: [ { type: 'text', text: `Error getting changes for component "${componentSlug}": ${error.message}`, }, ], isError: true, }; } }
- Helper service method that implements the core logic for retrieving component changes by calling the Weblate API's componentsChangesRetrieve endpoint.async getComponentChanges( projectSlug: string, componentSlug: string ): Promise<{ results: Change[]; count: number; next?: string; previous?: string }> { try { const client = this.weblateClientService.getClient(); const response = await componentsChangesRetrieve({ client, path: { project__slug: projectSlug, slug: componentSlug }, }); const changeList = response.data as any; // Handle different response formats if (Array.isArray(changeList)) { return { results: changeList, count: changeList.length, }; } if (changeList && changeList.results) { return { results: changeList.results || [], count: changeList.count || 0, next: changeList.next || undefined, previous: changeList.previous || undefined, }; } return { results: [], count: 0 }; } catch (error) { this.logger.error( `Failed to get changes for component ${componentSlug} in project ${projectSlug}`, error, ); throw new Error(`Failed to get component changes: ${error.message}`); } }
- Proxy method in WeblateApiService that delegates getComponentChanges to the underlying changes service.async getComponentChanges(projectSlug: string, componentSlug: string) { return this.changesService.getComponentChanges(projectSlug, componentSlug);
- src/tools/changes.tool.ts:247-254 (helper)Private helper method used by the handler to format individual change results into a readable string.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}`; }
- src/app.module.ts:78-78 (registration)The WeblateChangesTool class (containing the getComponentChanges handler) is registered as a provider in the AppModule, enabling automatic tool registration via MCP-Nest.WeblateChangesTool,