Skip to main content
Glama

convert_encoding

DestructiveIdempotent

Convert files between character encodings. Supports auto-detection, batch processing, backups, and dry-run previews, refusing unsafe conversions to prevent corruption.

Instructions

Convert files between encodings. Parameters: path (one file) OR paths (a batch — never both), to (required), from (omit to auto-detect), backup (write .bak first), dryRun (report only), allowLowConfidence, bom ("auto" default, "always", "never", "preserve"). Refuses rather than corrupting: a narrowing conversion (utf-8 to cp1251) names the characters the target lacks with line and column, and an untrusted detection names its best guess — confirm it with from, or pass allowLowConfidence=true. A source BOM is stripped before decoding; one contradicting an explicit from is an error. No-op if the file already holds the target bytes. In a batch one bad file does not stop the rest. Run dryRun over a project first. Examples: {"path": "D:\legacy\data.txt", "to": "utf-8", "backup": true} leaves data.txt.bak; {"paths": ["a.pas", "b.pas"], "to": "utf-8", "dryRun": true} previews a migration.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
toYes
bomNo
fromNo
pathNo
pathsNo
backupNo
dryRunNo
allowLowConfidenceNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
dryRunNo
errorsNo
hasBomYes
bomTypeNo
changedYes
messageYes
resultsNo
backupPathNo
errorCountNo
successCountNo
sourceEncodingNo
targetEncodingYes
Behavior5/5

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

Beyond the annotations (destructiveHint=true, idempotentHint=true), the description discloses specific behaviors: backup creation, refusal to corrupt with naming missing characters, BOM stripping and contradiction handling, and partial batch failures. This significantly enriches the agent's understanding of side effects and edge cases.

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 densely packed but every sentence earns its place: purpose, parameter guide, behavioral notes, and examples. It is structured logically from high-level operation to specific details, with no filler or repetition.

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?

Given 8 parameters, a mutation tool, and an output schema, the description covers all necessary contexts: parameter constraints, error handling, idempotency, backup behavior, BOM nuance, and batch execution. The presence of examples further rounds out completeness.

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 the description fully compensates. It explains every parameter individually (path vs paths, to, from, backup, dryRun, allowLowConfidence, bom) and provides concrete JSON examples that illustrate correct usage, making the schema's bare properties meaningful.

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 opening sentence "Convert files between encodings" states a specific verb and resource, clearly distinguishing it from sibling tools like detect_encoding, list_encodings, and manage_bom. No ambiguity exists about what the tool does.

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?

The description provides actionable guidance: "Run dryRun over a project first," "confirm it with from, or pass allowLowConfidence=true," and notes when conversion is unnecessary ("No-op if the file already holds the target bytes"). It even explains batch behavior ("one bad file does not stop the rest") which informs usage decisions.

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/dimitar-grigorov/mcp-file-tools'

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