Skip to main content
Glama
mmntm

Weblate MCP Server

by mmntm

searchUnitsWithFilters

Search translation units in Weblate using filter syntax to find specific strings by state, component, content, or suggestions.

Instructions

Search translation units using Weblate's powerful filtering syntax. Supports filters like: state:<translated (untranslated), state:>=translated (translated), component:NAME, source:TEXT, target:TEXT, has:suggestion, etc.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectSlugYesThe slug of the project
componentSlugYesThe slug of the component
languageCodeYesThe language code (e.g., sk, cs, fr)
searchQueryYesWeblate search query using their filter syntax. Examples: "state:<translated" (untranslated), "state:>=translated" (translated), "source:hello", "has:suggestion", "component:common AND state:<translated"
limitNoMaximum number of results to return (default: 50, max: 200)

Implementation Reference

  • The main handler function for the 'searchUnitsWithFilters' tool. It calls the WeblateApiService to perform the search and formats the results using a helper method.
    async searchUnitsWithFilters({
      projectSlug,
      componentSlug,
      languageCode,
      searchQuery,
      limit = 50,
    }: {
      projectSlug: string;
      componentSlug: string;
      languageCode: string;
      searchQuery: string;
      limit?: number;
    }) {
      try {
        const results = await this.weblateApiService.searchUnitsWithQuery(
          projectSlug,
          componentSlug,
          languageCode,
          searchQuery,
          Math.min(limit, 200), // Cap at 200 to prevent overwhelming responses
        );
    
        if (results.length === 0) {
          return {
            content: [
              {
                type: 'text',
                text: `No units found matching query "${searchQuery}" in ${projectSlug}/${componentSlug}/${languageCode}`,
              },
            ],
          };
        }
    
        const resultText = this.formatFilteredResults(results, projectSlug, componentSlug, languageCode, searchQuery);
        
        return {
          content: [
            {
              type: 'text',
              text: resultText,
            },
          ],
        };
      } catch (error) {
        this.logger.error('Failed to search units with filters', error);
        return {
          content: [
            {
              type: 'text',
              text: `Error searching units: ${error.message}`,
            },
          ],
          isError: true,
        };
      }
    }
  • Tool registration decorator including the name, description, and Zod input schema definition.
    @Tool({
      name: 'searchUnitsWithFilters',
      description: 'Search translation units using Weblate\'s powerful filtering syntax. Supports filters like: state:<translated (untranslated), state:>=translated (translated), component:NAME, source:TEXT, target:TEXT, has:suggestion, etc.',
      parameters: z.object({
        projectSlug: z.string().describe('The slug of the project'),
        componentSlug: z.string().describe('The slug of the component'),
        languageCode: z.string().describe('The language code (e.g., sk, cs, fr)'),
        searchQuery: z.string().describe('Weblate search query using their filter syntax. Examples: "state:<translated" (untranslated), "state:>=translated" (translated), "source:hello", "has:suggestion", "component:common AND state:<translated"'),
        limit: z.number().optional().default(50).describe('Maximum number of results to return (default: 50, max: 200)'),
      }),
    })
  • Zod schema for input parameters of the tool.
    parameters: z.object({
      projectSlug: z.string().describe('The slug of the project'),
      componentSlug: z.string().describe('The slug of the component'),
      languageCode: z.string().describe('The language code (e.g., sk, cs, fr)'),
      searchQuery: z.string().describe('Weblate search query using their filter syntax. Examples: "state:<translated" (untranslated), "state:>=translated" (translated), "source:hello", "has:suggestion", "component:common AND state:<translated"'),
      limit: z.number().optional().default(50).describe('Maximum number of results to return (default: 50, max: 200)'),
    }),
  • Helper method called by the handler to format the search results into a readable string.
      private formatFilteredResults(results: Unit[], projectSlug: string, componentSlug: string, languageCode: string, searchQuery: string): string {
        if (results.length === 0) {
          return `No units found in ${projectSlug}/${componentSlug}/${languageCode} matching query: ${searchQuery}`;
        }
    
        const formattedResults = results
          .slice(0, 50) // Limit to 50 for readability
          .map(unit => {
            const sourceText = unit.source && Array.isArray(unit.source) 
              ? unit.source.join('') 
              : (unit.source || '(empty)');
            const targetText = unit.target && Array.isArray(unit.target) 
              ? unit.target.join('') 
              : (unit.target || '(empty)');
    
            // Determine status based on state
            let status = '❓ Unknown';
            if (unit.state === 0) status = '❌ Untranslated';
            else if (unit.state === 10) status = '🔄 Needs Editing';
            else if (unit.state === 20) status = '✅ Translated';
            else if (unit.state === 30) status = '✅ Approved';
            else if (unit.state === 100) status = '🔒 Read-only';
    
            return `**Key:** ${unit.context || '(no context)'}
    **Source:** ${sourceText}
    **Target:** ${targetText}
    **Status:** ${status}
    **Location:** ${unit.location || '(none)'}
    **Note:** ${unit.note || '(none)'}
    **ID:** ${unit.id}`;
          })
          .join('\n\n');
    
        const totalText = results.length > 50
          ? `\n\n*Showing first 50 of ${results.length} units*`
          : '';
    
        return `Found ${results.length} units in ${projectSlug}/${componentSlug}/${languageCode} matching query "${searchQuery}":\n\n${formattedResults}${totalText}`;
      }
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 mentions 'powerful filtering syntax' and gives examples, but lacks critical details such as pagination behavior, rate limits, authentication requirements, error handling, or what the search results look like. This is insufficient for a search tool with multiple parameters.

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 efficiently structured in two sentences: the first states the purpose, and the second provides specific filter examples. Every sentence earns its place by adding practical value without redundancy, making it front-loaded and easy to parse.

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 complexity of a search tool with 5 parameters, no annotations, and no output schema, the description is incomplete. It lacks information on behavioral traits (e.g., result format, limitations), and while it hints at usage, it doesn't fully compensate for the missing structured data, leaving gaps for an AI agent.

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?

Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds value by providing concrete examples of the 'searchQuery' parameter (e.g., 'state:<translated'), which helps clarify the filter syntax, but doesn't add significant meaning beyond what the schema provides for other parameters.

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 tool searches translation units using Weblate's filtering syntax, which is a specific verb+resource combination. It distinguishes itself from siblings like 'searchStringInProject' by emphasizing the powerful filtering capabilities, though it doesn't explicitly contrast with all search-related siblings.

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

Usage Guidelines3/5

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

The description implies usage through filter examples like 'state:<translated' and 'has:suggestion', suggesting when to use it for filtered searches. However, it doesn't provide explicit guidance on when to choose this tool over alternatives like 'searchStringInProject' or 'findTranslationsForKey', leaving some ambiguity.

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