Skip to main content
Glama
mmntm

Weblate MCP Server

by mmntm

getTranslationForKey

Retrieve translation text for a specific key in a Weblate project component and language.

Instructions

Get translation value for a specific key in a project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectSlugYesThe slug of the project
componentSlugYesThe slug of the component
languageCodeYesThe language code (e.g., en, es, fr)
keyYesThe translation key to look up

Implementation Reference

  • The handler function that implements the core logic of the getTranslationForKey tool. It calls the WeblateApiService to retrieve the translation and handles formatting and error responses.
    async getTranslationForKey({
      projectSlug,
      componentSlug,
      languageCode,
      key,
    }: {
      projectSlug: string;
      componentSlug: string;
      languageCode: string;
      key: string;
    }) {
      try {
        const translation = await this.weblateApiService.getTranslationByKey(
          projectSlug,
          componentSlug,
          languageCode,
          key,
        );
    
        if (!translation) {
          return {
            content: [
              {
                type: 'text',
                text: `Translation not found for key "${key}" in ${projectSlug}/${componentSlug}/${languageCode}`,
              },
            ],
          };
        }
    
        return {
          content: [
            {
              type: 'text',
              text: this.formatTranslationResult(translation),
            },
          ],
        };
      } catch (error) {
        this.logger.error(`Failed to get translation for key ${key}`, error);
        return {
          content: [
            {
              type: 'text',
              text: `Error getting translation for key "${key}": ${error.message}`,
            },
          ],
          isError: true,
        };
      }
    }
  • Zod schema defining the input parameters for the getTranslationForKey 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., en, es, fr)'),
      key: z.string().describe('The translation key to look up'),
    }),
  • The @Tool decorator that registers the getTranslationForKey tool with MCP, including name, description, and parameter schema.
    @Tool({
      name: 'getTranslationForKey',
      description: 'Get translation value for a specific key in a project',
      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., en, es, fr)'),
        key: z.string().describe('The translation key to look up'),
      }),
    })
  • Helper method used by the handler to format the translation result for display.
      private formatTranslationResult(translation: Unit): string {
        const status = translation.approved
          ? '✅ Approved'
          : translation.translated
            ? '📝 Translated'
            : '❌ Untranslated';
    
        const sourceText = translation.source && Array.isArray(translation.source) 
          ? translation.source.join('') 
          : (translation.source || '(empty)');
        
        const targetText = translation.target && Array.isArray(translation.target) 
          ? translation.target.join('') 
          : (translation.target || '(empty)');
    
        return `**Key:** ${translation.context}
    **Source:** ${sourceText}
    **Target:** ${targetText}
    **Status:** ${status}
    **Context:** ${translation.context || '(none)'}
    **Note:** ${translation.note || '(none)'}
    **ID:** ${translation.id}`;
      }
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. It states the tool 'gets' a translation value, implying a read-only operation, but does not cover aspects like error handling (e.g., what happens if the key is not found), performance considerations, or authentication needs. This leaves significant gaps in understanding how the tool behaves beyond its basic function.

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 directly states the tool's purpose without unnecessary words or fluff. It is front-loaded with the core action and resource, making it easy to parse quickly, which is ideal for conciseness in tool descriptions.

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

Completeness3/5

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

Given the tool's complexity (4 required parameters, no output schema, and no annotations), the description is minimally adequate but incomplete. It covers the basic purpose but lacks details on behavioral traits, error handling, and output format, which are crucial for a tool with multiple inputs and no structured output schema. This leaves the agent with gaps in understanding the full context of use.

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 input schema has 100% description coverage, with clear parameter definitions (e.g., 'projectSlug', 'languageCode'). The description does not add any additional meaning or context beyond what the schema provides, such as explaining relationships between parameters or usage examples. With high schema coverage, a baseline score of 3 is appropriate as the schema handles most of the documentation burden.

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 ('Get translation value') and the target resource ('for a specific key in a project'), which is specific and actionable. However, it does not explicitly differentiate from sibling tools like 'findTranslationsForKey' or 'searchStringInProject', which might have overlapping functionality, leaving some ambiguity about when to choose this tool over others.

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 siblings like 'findTranslationsForKey' and 'searchStringInProject' that might serve similar purposes, the lack of context or exclusions leaves the agent without clear usage instructions, relying solely on the tool name and description for inference.

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