Skip to main content
Glama
mmntm

Weblate MCP Server

by mmntm

listComponents

Retrieve components from a Weblate translation project to manage and organize translation units for collaborative localization workflows.

Instructions

List components in a specific project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectSlugYesThe slug of the project

Implementation Reference

  • The MCP tool handler for 'listComponents'. It uses the @Tool decorator to define the tool name, description, and Zod schema for input parameters. The function fetches components via WeblateApiService and formats them into a markdown response, handling errors gracefully.
    @Tool({ name: 'listComponents', description: 'List components in a specific project', parameters: z.object({ projectSlug: z.string().describe('The slug of the project'), }), }) async listComponents({ projectSlug }: { projectSlug: string }) { try { const components = await this.weblateApiService.listComponents(projectSlug); return { content: [ { type: 'text', text: `Components in project "${projectSlug}":\n\n${components .map( (c) => `- **${c.name}** (${c.slug})\n Source Language: ${c.source_language.name} (${c.source_language.code})`, ) .join('\n\n')}`, }, ], }; } catch (error) { this.logger.error(`Failed to list components for ${projectSlug}`, error); return { content: [ { type: 'text', text: `Error listing components for project "${projectSlug}": ${error.message}`, }, ], isError: true, }; } }
  • Registration of the WeblateComponentsTool in the AppModule providers array, which makes it available to the MCP module.
    providers: [ WeblateClientService, WeblateProjectsService, WeblateComponentsService, WeblateLanguagesService, WeblateTranslationsService, WeblateChangesService, WeblateApiService, WeblateStatisticsService, WeblateProjectsTool, WeblateComponentsTool, WeblateLanguagesTool, WeblateTranslationsTool, WeblateChangesTool, WeblateStatisticsTool, ], })
  • Core service implementation that calls the Weblate API to retrieve components for a project, handling various response formats and errors.
    async listComponents(projectSlug: string): Promise<Component[]> { try { const client = this.weblateClientService.getClient(); const response = await projectsComponentsRetrieve({ client, path: { slug: projectSlug } }); // According to the API comment, this should return a list of components // The typing might be incorrect - try to handle both single and array responses const components = response.data as any; if (Array.isArray(components)) { return components; } // If it's a paginated response if (components && components.results && Array.isArray(components.results)) { return components.results; } // If it's a single component, wrap it in an array if (components && typeof components === 'object') { return [components]; } return []; } catch (error) { this.logger.error( `Failed to list components for project ${projectSlug}`, error, ); throw new Error(`Failed to list components: ${error.message}`); } }
  • Proxy method in WeblateApiService that delegates to ComponentsService.listComponents.
    } catch (error) { this.logger.error(`Failed to list components for ${projectSlug}`, error); return { content: [
  • Zod schema defining the input parameter 'projectSlug' for the listComponents tool.
    parameters: z.object({ projectSlug: z.string().describe('The slug of the project'), }),

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