Skip to main content
Glama

JavaScript / TypeScript beautify or minify

js_beautify
Read-onlyIdempotent

Format JavaScript, TypeScript or JSX with js-beautify, or minify JavaScript/TypeScript by removing comments and whitespace (no renaming, no rewriting; line breaks are kept where automatic semicolon insertion needs them). The output is re-lexed and compared token by token with the input.

Returns: Text: the formatted or minified code. structuredContent { code, mode, inputBytes, outputBytes, savedPercent, warnings[] }. Example input: {"code":"function add(a,b){return a+b}","mode":"beautify","language":"javascript","indent":2,"brace_style":"collapse","keep_license":true} On error, includes hint: Pass the whole file as code. An unterminated string, comment or regex is reported with its line and column.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "code": "<code>"
    },
    "name": "js_beautify"
  }
}

Input Schema

NameRequiredDescriptionDefault
codeYesSource code to format or minify.
modeNobeautify = pretty-print, minify = strip comments and whitespace.beautify
indentNoSpaces per indent level when beautifying (0 = tabs).
languageNoLanguage of the code. TypeScript gets generic and optional-marker fix-ups; JSX cannot be minified.javascript
brace_styleNoBrace placement when beautifying: collapse = K&R (same line), expand = Allman (own line).collapse
keep_licenseNoWhen minifying, keep /*! ... */ and @license comments.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.6/5.0
Behavior5/5

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

Goes well beyond the readOnly/idempotent annotations: it promises the output is re-lexed and token-compared against the input (a correctness guarantee), documents the minify invariants, and specifies the error hint plus line/column reporting for unterminated strings/comments/regex. This is exactly the kind of context the annotations cannot carry.

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-loads the purpose, then returns, then example, then error behavior — a sensible ordering with little waste. The example JSON is long relative to the rest, but it earns its space given three enum parameters.

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?

There is no output schema, and the description compensates by enumerating both the text return and the structuredContent fields (code, mode, inputBytes, outputBytes, savedPercent, warnings). With 100% schema coverage and 1 required parameter, an agent has everything needed to call this correctly.

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 the baseline is a 3, but the worked example input shows a realistic combination of code/mode/language/indent/brace_style/keep_license in one shot, which is more useful than prose. It still does not explain interactions such as indent having no effect in minify mode.

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 ('Format JavaScript, TypeScript or JSX with js-beautify, or minify JavaScript/TypeScript') and pins down the exact transformation semantics. The language scoping cleanly separates it from the css_beautify/html_beautify/xml_beautify siblings without needing to name them.

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?

Makes the beautify-vs-minify choice explicit in the first sentence, and constrains what 'minify' means (no renaming, no rewriting, ASI-safe line breaks). It stops short of naming the alternative tool for non-JS inputs, so the agent must infer the sibling routing from the tool name alone.

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