Skip to main content
Glama
mmntm

Weblate MCP Server

by mmntm

listComponents

Retrieve a list of components within a specified project in Weblate MCP Server. Input the project slug to access and manage translation-related components efficiently.

Instructions

List components in a specific project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectSlugYesThe slug of the project

Implementation Reference

  • The @Tool-decorated handler function that implements the listComponents MCP tool logic, including input schema validation via Zod, API call, response formatting, and error handling.
    @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 class in the NestJS AppModule providers array, making it available for MCP tool discovery.
    WeblateProjectsTool, WeblateComponentsTool, WeblateLanguagesTool, WeblateTranslationsTool, WeblateChangesTool, WeblateStatisticsTool,
  • Supporting service method that performs the actual Weblate API call to retrieve the list of components, handling various response formats.
    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}`); } }
  • Facade method in WeblateApiService that delegates the listComponents call to the underlying components service.
    async listComponents(projectSlug: string): Promise<Component[]> { return this.componentsService.listComponents(projectSlug); }
  • src/tools/index.ts:2-2 (registration)
    Export of the components tool module for barrel export in tools directory.
    export * from './components.tool';

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