Prettier MCP Formatter
Exposes a format_code tool that formats source code using Prettier, with support for auto-installing allowlisted Prettier plugins from a configurable npm registry and caching them, plus a plugin-cache cleaning tool for admins.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Prettier MCP Formatter Format this JavaScript snippet with Prettier"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Prettier MCP Formatter
1. Requirements
Local: Node.js 20.19+ or 24.x, plus Python 3 with
blackonPATH.Docker: Docker Engine with Compose. The image bundles Black; no Python setup is needed on the host.
Public container image (after GitHub mirror and first successful publish):
ghcr.io/shadow7412/code-formatter:latest.Pull the image with
docker pull ghcr.io/shadow7412/code-formatter:latestonce the GitHub package is public; no registry login is required.ChatGPT web: full custom MCP support requires Business, Enterprise, or Edu. Personal/Plus/Pro accounts only get read/fetch custom MCP servers, which cannot call
format_code. Use Codex desktop/CLI with a bearer token instead.Secure MCP Tunnel: a
tunnel_idand a runtime API key with Tunnels Read + Use. A personal Platform organization works; associate the tunnel with the target ChatGPT workspace.
Related MCP server: biome-mcp
2. Local setup
python3 -m venv .venv
. .venv/bin/activate
python -m pip install black
npm ci
npm run build
npm test
npm start # stdio MCP transportKeep the virtual environment activated when running the server, or set BLACK_BIN to the
absolute path of your Black executable.
Override config with environment variables or a local .env.
Generate a bearer token for HTTP mode:
openssl rand -hex 323. Configuration
Variable | Default | Use |
|
| Install missing allowlisted plugins. |
| empty | Comma-separated npm package specs. Leave versions off so bumps resolve without a redeploy. Empty blocks installs. |
|
| Persistent cache directory. |
|
| Install timeout in milliseconds. |
|
| Black executable used for Python files. No shell is used. |
|
| Black subprocess timeout in milliseconds. |
|
| Administrator-controlled registry. |
|
| Memory cap for npm. |
|
| CPU-time cap for npm. |
| unset | Enables the |
|
|
|
|
| HTTP bind address. |
|
| HTTP listen port. |
|
| MCP endpoint path. |
| unset | Bearer token, minimum 16 characters. |
|
| Disables bearer auth. Use only with a private tunnel. |
MCP_HTTP_TOKEN and MCP_HTTP_ALLOW_UNAUTHENTICATED=true are mutually exclusive.
4. Run with Docker
The published image includes Black on PATH. Do not add BLACK_BIN to the Compose examples
unless you are deliberately replacing the bundled executable.
Bearer-token mode
Create .env:
MCP_HTTP_TOKEN=<openssl rand -hex 32>
PRETTIER_PLUGIN_ALLOWLIST=@prettier/plugin-xml,prettier-plugin-organize-imports,@trivago/prettier-plugin-sort-importsSave as docker-compose.yml:
services:
formatter:
image: ghcr.io/shadow7412/code-formatter:latest
restart: unless-stopped
ports:
- "127.0.0.1:3072:3072"
user: "10001:10001"
read_only: true
cap_drop: [ALL]
security_opt: [no-new-privileges:true]
tmpfs:
- /tmp:size=64m,uid=10001,gid=10001,mode=1700
mem_limit: 2g
volumes:
- ./plugin-cache:/var/cache/prettier-plugins
environment:
MCP_TRANSPORT: http
MCP_HTTP_HOST: 0.0.0.0
MCP_HTTP_PORT: "3072"
MCP_HTTP_PATH: /mcp
MCP_HTTP_TOKEN: ${MCP_HTTP_TOKEN:?set a long random token in .env}
PRETTIER_PLUGIN_AUTO_INSTALL: "true"
PRETTIER_PLUGIN_ALLOWLIST: ${PRETTIER_PLUGIN_ALLOWLIST:-}
PRETTIER_PLUGIN_CACHE: /var/cache/prettier-plugins
PRETTIER_PLUGIN_INSTALL_TIMEOUT: "30000"
PRETTIER_ADMIN_TOKEN: ${PRETTIER_ADMIN_TOKEN:-}Create the cache directory with the UID the container runs as, then start:
mkdir -p plugin-cache
sudo chown 10001:10001 plugin-cache
docker compose up -dFor a remote client, put a TLS reverse proxy in front of 127.0.0.1:3072 and send:
Authorization: Bearer <MCP_HTTP_TOKEN>Do not expose the no-auth endpoint through a public proxy.
No-auth mode through Secure MCP Tunnel
Get the two CONTROL_PLANE_* values first:
Open https://platform.openai.com/settings/organization/tunnels and create a tunnel, or select an existing one. The tunnel must be associated with the ChatGPT workspace you'll use. Copy its ID (
tunnel_...) intoCONTROL_PLANE_TUNNEL_ID. Wait 25–30 seconds after creating it before use.Open https://platform.openai.com/settings/organization/api-keys and create a Restricted runtime API key with Tunnels Read + Use. Copy it into
CONTROL_PLANE_API_KEY. Do not use an All key or an admin key for the long-lived daemon.The account that creates the key needs Tunnels Read + Use on that tunnel. Check https://platform.openai.com/settings/organization/people/roles if the tunnel client gets a 403 while polling.
Create a root-only .env:
CONTROL_PLANE_API_KEY=sk-...
CONTROL_PLANE_TUNNEL_ID=tunnel_0123456789abcdef0123456789abcdefSave as docker-compose.yml:
services:
formatter:
image: ghcr.io/shadow7412/code-formatter:latest
restart: unless-stopped
ports:
- "127.0.0.1:3072:3072"
user: "10001:10001"
read_only: true
cap_drop: [ALL]
security_opt: [no-new-privileges:true]
tmpfs:
- /tmp:size=64m,uid=10001,gid=10001,mode=1700
mem_limit: 2g
volumes:
- ./plugin-cache:/var/cache/prettier-plugins
environment:
MCP_TRANSPORT: http
MCP_HTTP_HOST: 0.0.0.0
MCP_HTTP_PORT: "3072"
MCP_HTTP_PATH: /mcp
MCP_HTTP_ALLOW_UNAUTHENTICATED: "true"
PRETTIER_PLUGIN_AUTO_INSTALL: "true"
PRETTIER_PLUGIN_ALLOWLIST: "@prettier/plugin-xml,prettier-plugin-organize-imports,@trivago/prettier-plugin-sort-imports"
PRETTIER_PLUGIN_CACHE: /var/cache/prettier-plugins
PRETTIER_PLUGIN_INSTALL_TIMEOUT: "30000"
tunnel-client:
image: ghcr.io/openai/tunnel-client:v0.0.21
restart: unless-stopped
depends_on:
- formatter
environment:
CONTROL_PLANE_API_KEY: ${CONTROL_PLANE_API_KEY:?set in .env}
CONTROL_PLANE_TUNNEL_ID: ${CONTROL_PLANE_TUNNEL_ID:?set in .env}
MCP_SERVER_URL: http://formatter:3072/mcp
MCP_OAUTH_DISCOVERY: disabled
LOG_LEVEL: info
LOG_FORMAT: json
HEALTH_LISTEN_ADDR: ":8080"
ports:
- "127.0.0.1:8080:8080"Create the cache directory with the UID the container runs as, then start both services:
mkdir -p plugin-cache
sudo chown 10001:10001 plugin-cache
docker compose up -dCheck the tunnel is polling:
curl -fsS http://127.0.0.1:8080/readyz
docker compose logs -f tunnel-clientDo not expose port 8080 publicly; the formatter's no-auth port must stay on
loopback.
5. Connect clients
ChatGPT desktop / Codex CLI / IDE extension
Add to ~/.codex/config.toml:
[mcp_servers.prettier_formatter]
url = "http://127.0.0.1:3072/mcp"
bearer_token_env_var = "MCP_HTTP_TOKEN"
default_tools_approval_mode = "prompt"
tool_timeout_sec = 120Export MCP_HTTP_TOKEN before launching the client.
ChatGPT web
Select Add custom MCP server.
Under Connection, select Tunnel.
Choose the tunnel.
Set authentication to none.
Select Create as a plugin, then install it.
In a chat, type
@and select the plugin.
ChatGPT web cannot send a static bearer token. Use a tunnel for this setup.
6. Verify
curl -fsS http://127.0.0.1:3072/healthz
black --version
npx @modelcontextprotocol/inspector@latestIn MCP Inspector, select Streamable HTTP and connect to
http://127.0.0.1:3072/mcp.
Available Tools
3 toolscache_infoInspect plugin cacheA
List cached Prettier plugins and the cache directory in use.
Inputs: no named parameters. Returns: plugins, cacheDir
format_codeFormat code with PrettierA
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.
Inputs: code (required), filename (required), config, plugins. Returns: plugins, filename, formatted
supported_extensionsList supported file extensionsA
Report the file extensions this server can format. Includes Python (.py/.pyi) when Black is available. Pass allowlisted plugin package names to include extensions those Prettier plugins provide.
Inputs: plugins. Returns: plugins, languages, extensions, formatters, +1 more
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
The three tools have clearly distinct purposes: formatting code, reporting supported extensions, and inspecting plugin cache state. There is no meaningful overlap that would cause an agent to misselect among them.
All names use snake_case, but the pattern is mixed: format_code is verb_noun while supported_extensions and cache_info are noun phrases. The names are readable and accurate, but they do not follow one predictable convention.
Three tools is well-scoped for a formatter server: one core formatting action plus two focused informational helpers. Each tool supports a real part of the formatting workflow, especially plugin-aware usage.
The surface covers the main formatting operation, extension discovery, and plugin cache inspection, which is solid for the stated purpose. Minor gaps exist around check-only/dry-run formatting or config introspection, but agents can work around them.
Maintenance
Related MCP Connectors
Format/lint JS, Python, HubL for automation platforms. Tools: format_code, format_json, ask_codefmt
Free pre-action policy checks and data cleaning for autonomous AI agents.
Research-backed lint + generation for agent context files (CLAUDE.md, AGENTS.md) + prompt enhancer.
Gives AI agents direct access to your Sanity projects and guidance for working with them
Related MCP Servers
- FlicenseAqualityDmaintenanceEnables AI agents to autonomously navigate a codebase by listing directories, reading files, searching code, and running whitelisted commands.5-
- AlicenseBqualityDmaintenanceEnables LLMs to run Biome formatting, linting, and assist checks on TypeScript/web projects with token-efficient, structured output, plus searchable cached Biome documentation.5Apache 2.0

promptlintofficial
AlicenseNot gradedqualityBmaintenanceEnables AI coding agents to automatically lint and auto-fix their generated prompts before running them, helping improve prompt quality, security, and cost efficiency.1MIT- AlicenseNot gradedqualityBmaintenanceEnables coding agents to query a workspace's design system before writing UI and validate generated code against the same system afterward, using configurable token and component sources.13 npm1MIT