Skip to main content
Glama
translated

Lara Translate MCP Server

by translated

detect_language

Read-only

Identify the language of input text with confidence scores. Supports single strings or batches up to 128 items for efficient processing.

Instructions

Detects the language of the provided text. Returns the detected language, content type, and a list of predictions with confidence scores. Accepts a single string or an array of strings (up to 128 elements).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYesThe text to detect the language of. Can be a single string or an array of strings (up to 128 elements).
hintNoOptional language code hint to guide detection (e.g., 'en-EN').
passlistNoOptional list of language codes to restrict detection results to.

Implementation Reference

  • The main handler function for detect_language. Parses args (text, hint, passlist) via Zod schema and calls lara.detect().
    export async function detectLanguage(args: unknown, lara: Translator) {
      const { text, hint, passlist } = detectLanguageSchema.parse(args);
    
      return lara.detect(text, hint, passlist);
    }
  • Zod schema defining input validation for detect_language: 'text' (string or array up to 128), optional 'hint' (language code), optional 'passlist' (array of language codes).
    export const detectLanguageSchema = z.object({
      text: z
        .union([z.string(), z.array(z.string()).max(128)])
        .describe(
          "The text to detect the language of. Can be a single string or an array of strings (up to 128 elements)."
        ),
      hint: z
        .string()
        .optional()
        .describe(
          "Optional language code hint to guide detection (e.g., 'en-EN')."
        ),
      passlist: z
        .array(z.string())
        .optional()
        .describe(
          "Optional list of language codes to restrict detection results to."
        ),
    });
  • src/mcp/tools.ts:48-49 (registration)
    Registration of detect_language in the handlers map, mapping the tool name string to the detectLanguage function.
    const handlers: Record<string, Handler> = {
      detect_language: detectLanguage,
  • Tool definition registration including name, description, inputSchema, annotations (title, readOnlyHint, destructiveHint, openWorldHint), and _meta for the detect_language tool.
    const toolDefinitions = [
      {
        name: "detect_language",
        description:
          "Detects the language of the provided text. Returns the detected language, content type, and a list of predictions with confidence scores. Accepts a single string or an array of strings (up to 128 elements).",
        inputSchema: z.toJSONSchema(detectLanguageSchema),
        annotations: {
          title: "Detect language",
          readOnlyHint: true,
          destructiveHint: false,
          openWorldHint: true,
        },
        _meta: invocationMeta("Detecting language…", "Language detected"),
      },
Behavior4/5

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

Annotations already indicate read-only (readOnlyHint=true) and non-destructive (destructiveHint=false). The description adds behavioral details: accepts arrays up to 128 elements, returns predictions with confidence scores, and outputs content type. No contradictions.

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?

Two sentences conveying purpose, return values, and input constraints. No redundant information; every word contributes.

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

Completeness4/5

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

Given simple tool, schema covers params, annotations cover safety, description covers return and array limit. Lacks error cases or guidance on optional params (hint, passlist), but still adequate for selection and invocation.

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

Parameters4/5

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

Schema coverage is 100%, so baseline is 3. The description adds value by mentioning the 128-element array limit (schema has maxItems but not in description) and clarifying the return structure (detected language, content type, predictions). Output semantics are not in schema, adding context.

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

Purpose5/5

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

The description clearly states the tool's purpose: 'Detects the language of the provided text.' It distinguishes from sibling tools like translate and list_languages by focusing solely on detection, and specifies the output (detected language, content type, predictions).

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 for language detection but does not explicitly state when to use it versus alternatives like translate (which might also imply language) or list_languages. No exclusions or when-not-to-use guidance provided.

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/translated/lara-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server