Skip to main content
Glama
Prettier MCP Formatter

Prettier MCP Formatter

Format code with Prettier

format_code

Formats source code with Prettier for web languages and Black for Python, with optional Prettier config and allowlisted plugins.

Instructions

Format source code. Python files (.py/.pyi, or parser=python) use bundled Black; other files use Prettier. Optionally supply a config object (or JSON string) and a list of allowlisted Prettier plugin packages. Plugins do not apply to Python files.

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": {
      "filename": "<filename>",
      "code": "<code>"
    },
    "name": "format_code"
  }
}

Input Schema

NameRequiredDescriptionDefault
codeYesSource code to format.
configNoPrettier options object or JSON string.
pluginsNoAllowlisted npm plugin packages for Prettier, optionally version-pinned. Ignored for Python.
filenameYesVirtual filename, used by Prettier to infer the parser.

Output Schema

NameRequiredDescriptionDefault
pluginsYes
filenameYes
formattedYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A4/5.0
Behavior3/5

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

With no annotations, the description carries the full disclosure burden and does contribute real behavior: which engine runs per file type, that plugins are allowlisted, and that plugins are ignored for Python. It does not state that formatting is non-destructive/virtual (no file is written), nor what happens on syntax errors or unsupported extensions, which are the remaining behavioral questions an agent would have.

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?

Three short sentences, front-loaded with the core action and engine routing, then the optional inputs. No filler, and each clause (engine split, config formats, plugin restriction) carries distinct information.

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?

For a stateless formatting tool with an output schema covering return values, the description is nearly complete: engine selection, config, and plugin scope are all addressed. The only gap is error handling behavior (invalid syntax, unknown extension, unallowlisted plugin), which an agent would otherwise have to discover empirically.

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 3, but the description adds genuine meaning beyond the schema: it reveals that config may be an object or JSON string and, importantly, that config with parser=python switches the engine to Black. It also clarifies the practical consequence of plugins being ignored for Python files, which the schema only hints at.

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?

"Format source code" gives a specific verb and resource, and the description immediately explains the engine split (Black for .py/.pyi or parser=python, Prettier otherwise). This is concrete enough that an agent knows exactly what the tool does and cannot confuse it with cache_info or supported_extensions.

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?

Usage is only implied: the description tells the agent which formatter will run for a given file, but never states when to reach for this tool versus not using it, nor any exclusions (e.g. linting, non-source files). The engine-routing rule is a helpful conditional, but it governs behavior once called rather than guiding tool selection.

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

Deploy Server

Other Tools