Format code with Prettier
format_codeFormats 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
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | Source code to format. | |
| config | No | Prettier options object or JSON string. | |
| plugins | No | Allowlisted npm plugin packages for Prettier, optionally version-pinned. Ignored for Python. | |
| filename | Yes | Virtual filename, used by Prettier to infer the parser. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| plugins | Yes | ||
| filename | Yes | ||
| formatted | Yes |