Skip to main content
Glama

detect_encoding

Read-only

Detect a file's encoding with a confidence score and BOM detection to resolve garbled text. Use before reading to apply the correct encoding.

Instructions

Auto-detect file encoding with confidence score (0-100) and BOM detection. ALWAYS use this first when encountering garbled text or � characters. Use before read_text_file to determine the correct encoding. Parameters: path (required), mode (sample=fast default, chunked=thorough, full=entire file). When the answer is in doubt the result also ranks candidates, all of them usable; retry the read with one and ask the user if two are plausible. A file the detector cannot place is refused rather than guessed at, with the same ranking in the error.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
modeNo
pathYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
has_bomYes
encodingYes
candidatesNo
confidenceYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv4.5.0
    • removedOutput schema / properties / candidates / items / properties / supported
      Removed value: -{
      -  "type": "boolean"
      -}
    • changedOutput schema / properties / candidates / items / required
      Previous value: -[
      -  "encoding",
      -  "confidence",
      -  "supported"
      -]New value: +[
      +  "encoding",
      +  "confidence"
      +]
  2. Changed1 schema field changedv4.2.0
    • addedOutput schema / properties / candidates
      Added value: +{
      +  "items": {
      +    "additionalProperties": false,
      +    "properties": {
      +      "confidence": {
      +        "type": "integer"
      +      },
      +      "encoding": {
      +        "type": "string"
      +      },
      +      "supported": {
      +        "type": "boolean"
      +      }
      +    },
      +    "required": [
      +      "encoding",
      +      "confidence",
      +      "supported"
      +    ],
      +    "type": "object"
      +  },
      +  "type": [
      +    "null",
      +    "array"
      +  ]
      +}
  3. First observedv0.1.0

TDQS

A4.9/5.0
Behavior5/5

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

Annotations only give the safety profile (readOnlyHint, openWorldHint, idempotentHint); the description adds substantive behavior beyond that: confidence scoring, BOM detection, candidate ranking on ambiguous files, and refusal-with-ranking for undetectable files instead of guessing. This is exactly the kind of non-obvious behavior an agent needs.

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

Conciseness4/5

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

Front-loaded with purpose, then usage, then parameters, then edge-case behavior — a logical order with no filler. Slightly sprawling: the inline 'Parameters:' enumeration interrupts the prose and the final sentence about refused files is dense, but nothing is expendable.

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

Completeness5/5

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

An output schema exists, so return values needn't be explained, yet the description still covers result shape (confidence, ranked candidates) and error behavior. For a read-only detector callable from many contexts, this is complete.

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

Parameters5/5

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

Schema description coverage is 0% and mode has no enum, so the description carries the whole burden — and it does: path marked required, and all three mode values explained semantically (sample=fast default, chunked=thorough, full=entire file). No gap remains.

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?

Starts with a specific verb+resource ('Auto-detect file encoding') and immediately names the two distinguishing outputs (confidence score 0-100, BOM detection). An agent can tell this apart from siblings like get_file_info or read_text_file without opening the schema.

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

Usage Guidelines5/5

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

Explicit trigger ('ALWAYS use this first when encountering garbled text or characters') plus explicit sequencing against a named sibling ('Use before read_text_file to determine the correct encoding'). Also covers the ambiguous-result path: retry the read with a ranked candidate, ask the user if two are plausible.

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