Skip to main content
Glama
mmntm

Weblate MCP Server

by mmntm

listLanguages

Retrieve available languages for a Weblate translation project to manage multilingual content effectively.

Instructions

List languages available in a specific project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectSlugYesThe slug of the project

Implementation Reference

  • The main handler function for the 'listLanguages' MCP tool. It uses @Tool decorator specifying name, description, input schema with Zod, fetches languages via service, formats as markdown list, handles errors, and returns structured content.
    @Tool({ name: 'listLanguages', description: 'List languages available in a specific project', parameters: z.object({ projectSlug: z.string().describe('The slug of the project'), }), }) async listLanguages({ projectSlug }: { projectSlug: string }) { try { const languages = await this.weblateApiService.listLanguages(projectSlug); return { content: [ { type: 'text', text: `Languages in project "${projectSlug}":\n\n${languages .map( (l) => `- **${l.name}** (${l.code})`, ) .join('\n')}`, }, ], }; } catch (error) { this.logger.error(`Failed to list languages for ${projectSlug}`, error); return { content: [ { type: 'text', text: `Error listing languages for project "${projectSlug}": ${error.message}`, }, ], isError: true, }; }
  • Zod schema defining the input parameters for the listLanguages tool: projectSlug as string.
    parameters: z.object({ projectSlug: z.string().describe('The slug of the project'), }),
  • Registration of tool classes including WeblateLanguagesTool in the AppModule providers. Since they use @Tool decorator, NestJS/MCP auto-registers them.
    WeblateProjectsTool, WeblateComponentsTool, WeblateLanguagesTool, WeblateTranslationsTool, WeblateChangesTool, WeblateStatisticsTool, ],
  • Helper method in WeblateApiService that delegates listLanguages call to the underlying languages service.
    async listLanguages(projectSlug: string): Promise<Language[]> { return this.languagesService.listLanguages(projectSlug); }
  • Core helper service implementing the API call to retrieve languages for a project using Weblate client, with response parsing and error handling.
    async listLanguages(projectSlug: string): Promise<Language[]> { try { const client = this.weblateClientService.getClient(); const response = await projectsLanguagesRetrieve({ client, path: { slug: projectSlug } }); // Handle different response formats const languages = response.data as any; if (Array.isArray(languages)) { return languages; } // If it's a paginated response if (languages && languages.results && Array.isArray(languages.results)) { return languages.results; } // If it's a single language, wrap it in an array if (languages && typeof languages === 'object') { return [languages]; } return []; } catch (error) { this.logger.error( `Failed to list languages for project ${projectSlug}`, error, ); throw new Error(`Failed to list languages: ${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