Skip to main content
Glama

Detectar tipo de archivo por sus bytes

file-type-detect
Read-onlyIdempotent

Detecta el tipo de archivo por sus primeros bytes (números mágicos): imágenes, PDF, comprimidos, Office, audio, video, fuentes, ejecutables y más, con heurísticas para texto, HTML, SVG y JSON. Cuándo: hay que convertir bytes o texto a esta codificación, o desde ella, con exactitud y sin adivinar. No para: buscar un tipo MIME por extensión de archivo o al revés (mime-lookup). Efectos secundarios: ninguno (solo lectura, sin red, sin estado guardado). Determinista: la misma entrada da la misma salida. Límites: entrada JSON de hasta 64 KB, 1 s por llamada, resultado de hasta 1 MB.

EN: Detects a file type from its first bytes (magic numbers): images, PDF, archives, Office/OOXML, audio, video, fonts, executables, SQLite, WebAssembly, plus text, HTML, XML/SVG and JSON heuristics; returns MIME type, extension and confidence. Does not trust file names. When: bytes or text have to be converted to or from this encoding exactly, without guessing. [EN completo / full EN: inputSchema.description]

Input Schema

NameRequiredDescriptionDefault
dataYesFile bytes (whole file or at least its first 4 KB) (string; required).
input_encodingNoHow `data` is encoded (optional; one of: base64, hex; default "base64").base64

Output Schema

NameRequiredDescriptionDefault
mimeNo
sizeNo
charsetNo
extensionNo
confidenceNo
descriptionNo
bytes_examinedNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • addedInput schema / properties / data / examples
      Added value: +[
      +  "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=="
      +]
  2. Added

TDQS

A4/5.0
Behavior4/5

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

Annotations already declare readOnlyHint, idempotentHint, openWorldHint=false and destructiveHint=false, so the safety profile is covered. The description still adds value beyond them: concrete limits (64 KB JSON input, 1 s per call, 1 MB result) and the note that file names are not trusted, which is a real behavioral trait. It does not contradict the annotations.

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

Conciseness3/5

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

The core detection statement is front-loaded and useful, but the definition is bloated by full bilingual duplication and a 'When' sentence that appears copied from an encoding tool and actively misleads. Those sentences do not earn their place in a detection tool's description.

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?

An output schema exists, so return values need not be explained, and the description still mentions MIME type, extension and confidence. Limits and determinism are covered. The only gap is the muddled positive usage condition, which slightly weakens completeness for an agent deciding when to call it.

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?

Schema description coverage is 100% and both parameters (data, input_encoding with a base64/hex enum) are documented in the schema, including the 'first 4 KB is enough' hint. The description adds no parameter-level detail beyond that, so the baseline of 3 applies.

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?

States a specific verb and resource ('Detecta el tipo de archivo por sus primeros bytes') and enumerates the detectable families (images, PDF, archives, Office, audio, video, fonts, executables, SQLite, WebAssembly) plus text/HTML/SVG/JSON heuristics. It also names the sibling it is not (mime-lookup), so an agent can distinguish it 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 Guidelines4/5

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

The 'No para' clause explicitly routes extension-based MIME lookups to mime-lookup, which is strong exclusion guidance. However, the 'Cuándo' clause is confusing: it talks about converting bytes or text 'to or from this encoding', which is conversion language that does not match a detection tool, leaving the positive trigger condition muddled.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources