Skip to main content
Glama
mmntm

Weblate MCP Server

by mmntm

searchStringInProject

Find translations containing specific text in a Weblate project by searching source strings, target translations, or both.

Instructions

Search for translations containing specific text in a project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectSlugYesThe slug of the project to search in
valueYesThe text to search for
searchInNoWhere to search: source text, target translation, or bothboth

Implementation Reference

  • The primary MCP tool handler for 'searchStringInProject'. Includes @Tool decorator with Zod schema for input validation, business logic for calling the service, result formatting (limiting to 10, using formatTranslationResult helper), error handling, and response structuring for MCP.
    @Tool({
      name: 'searchStringInProject',
      description:
        'Search for translations containing specific text in a project',
      parameters: z.object({
        projectSlug: z.string().describe('The slug of the project to search in'),
        value: z.string().describe('The text to search for'),
        searchIn: z
          .enum(['source', 'target', 'both'])
          .optional()
          .describe('Where to search: source text, target translation, or both')
          .default('both'),
      }),
    })
    async searchStringInProject({
      projectSlug,
      value,
      searchIn = 'both',
    }: {
      projectSlug: string;
      value: string;
      searchIn?: 'source' | 'target' | 'both';
    }) {
      try {
        const results = await this.weblateApiService.searchStringInProject(
          projectSlug,
          value,
          searchIn,
        );
    
        if (results.length === 0) {
          return {
            content: [
              {
                type: 'text',
                text: `No translations found containing "${value}" in project "${projectSlug}"`,
              },
            ],
          };
        }
    
        const formattedResults = results
          .slice(0, 10)
          .map(this.formatTranslationResult)
          .join('\n\n');
        const totalText =
          results.length > 10
            ? `\n\n*Showing first 10 of ${results.length} results*`
            : '';
    
        return {
          content: [
            {
              type: 'text',
              text: `Found ${results.length} translations containing "${value}" in project "${projectSlug}":\n\n${formattedResults}${totalText}`,
            },
          ],
        };
      } catch (error) {
        this.logger.error(
          `Failed to search for "${value}" in ${projectSlug}`,
          error,
        );
        return {
          content: [
            {
              type: 'text',
              text: `Error searching for "${value}" in project "${projectSlug}": ${error.message}`,
            },
          ],
          isError: true,
        };
      }
    }
  • Zod schema definition for the tool parameters within the @Tool decorator.
    parameters: z.object({
      projectSlug: z.string().describe('The slug of the project to search in'),
      value: z.string().describe('The text to search for'),
      searchIn: z
        .enum(['source', 'target', 'both'])
        .optional()
        .describe('Where to search: source text, target translation, or both')
        .default('both'),
    }),
  • Registration of WeblateTranslationsTool in the NestJS AppModule providers array, which enables MCP to discover and register the @Tool decorated methods.
    providers: [
      WeblateClientService,
      WeblateProjectsService,
      WeblateComponentsService,
      WeblateLanguagesService,
      WeblateTranslationsService,
      WeblateChangesService,
      WeblateApiService,
      WeblateStatisticsService,
      WeblateProjectsTool,
      WeblateComponentsTool,
      WeblateLanguagesTool,
      WeblateTranslationsTool,
      WeblateChangesTool,
      WeblateStatisticsTool,
    ],
  • Facade helper method in WeblateApiService that proxies the searchStringInProject call to the underlying translations service.
    async searchStringInProject(
      projectSlug: string,
      searchValue: string,
      searchIn: SearchIn = 'both',
    ): Promise<Unit[]> {
      return this.translationsService.searchStringInProject(
        projectSlug,
        searchValue,
        searchIn,
      );
    }
  • Core implementation helper that performs the actual Weblate API search for strings in source and/or target across the project, combines results, deduplicates by unit ID, using the internal searchTranslations method.
    async searchStringInProject(
      projectSlug: string,
      searchValue: string,
      searchIn: SearchIn = 'both',
    ): Promise<Unit[]> {
      try {
        let results: Unit[] = [];
    
        if (searchIn === 'source' || searchIn === 'both') {
          const sourceResults = await this.searchTranslations(
            projectSlug,
            undefined,
            undefined,
            undefined,
            searchValue,
          );
          results = results.concat(sourceResults.results);
        }
    
        if (searchIn === 'target' || searchIn === 'both') {
          const targetResults = await this.searchTranslations(
            projectSlug,
            undefined,
            undefined,
            undefined,
            undefined,
            searchValue,
          );
          results = results.concat(targetResults.results);
        }
    
        // Remove duplicates based on unit ID
        const uniqueResults = results.filter(
          (unit, index, self) => 
            index === self.findIndex(u => u.id === unit.id)
        );
    
        return uniqueResults;
      } catch (error) {
        this.logger.error(
          `Failed to search string in project ${projectSlug}`,
          error,
        );
        throw new Error(
          `Failed to search string in project: ${error.message}`,
        );
      }
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. While it states this is a search operation (implying read-only), it doesn't describe what happens if no matches are found, whether results are paginated, what format the output takes, or any performance considerations like rate limits. For a search 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 a single, efficient sentence that clearly states the tool's purpose without unnecessary words. It's appropriately sized for a straightforward search tool and front-loads the essential information. Every word earns its place.

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?

For a search tool with no annotations and no output schema, the description is insufficient. It doesn't explain what the search returns (e.g., matching translations, counts, or full records), how results are structured, or any limitations (e.g., case sensitivity, partial matches). Given the complexity of searching translations and the lack of structured output documentation, the description should provide more context about the operation's behavior and results.

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 all three parameters well-documented in the schema itself. The description doesn't add any meaningful parameter semantics beyond what's already in the schema (e.g., it doesn't explain what a 'projectSlug' is or provide examples of search patterns). With complete schema coverage, the baseline score of 3 is appropriate.

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 action ('Search for translations containing specific text') and the resource ('in a project'), providing a specific verb+resource combination. However, it doesn't differentiate this tool from sibling tools like 'searchUnitsWithFilters' or 'findTranslationsForKey', which likely offer similar search functionality with different scopes or parameters.

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 no guidance on when to use this tool versus alternatives. With sibling tools like 'searchUnitsWithFilters' and 'findTranslationsForKey' available, there's no indication of when this text-based search is preferred over other search methods, nor any mention of prerequisites or exclusions.

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