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'),
    }),
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states it's a list operation (implying read-only), but doesn't mention pagination, sorting, filtering options, rate limits, authentication requirements, or what the output looks like. For a tool with zero annotation coverage, this leaves significant behavioral gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise (5 words) and front-loaded with all necessary information. There's zero wasted language, and every word earns its place by specifying the action, resource, and scope.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and output schema, the description is insufficiently complete. It doesn't explain what 'components' are in this context, what data is returned, or any behavioral constraints. For a tool that presumably returns a list of items, more context about the output format and limitations would be helpful.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, with the single parameter 'projectSlug' fully documented in the schema. The description adds no additional parameter information beyond what's already in the structured schema, so it meets the baseline of 3 for adequate but not additive parameter semantics.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('List') and resource ('components'), and specifies the scope ('in a specific project'). It distinguishes from some siblings like 'listProjects' or 'listLanguages' by focusing on components, but doesn't explicitly differentiate from similar tools like 'getComponentStatistics' or 'getComponentChanges' that also involve components.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides minimal guidance by specifying 'in a specific project', but offers no explicit when-to-use rules, alternatives, or exclusions. It doesn't help the agent choose between this and sibling tools like 'getComponentStatistics' or 'searchUnitsWithFilters' that might also retrieve component-related data.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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