Formats files using .editorconfig
rules, acting as a proactive formatting gatekeeper to ensure AI-generated code adheres to project-specific formatting standards from the start.
A Model Context Protocol (MCP) compliant server that formats files using .editorconfig
rules.
This project started from a specific workflow issue I kept running into. I found that while working with AI coding agents, they would often generate code with minor formatting errors, like trailing whitespace or inconsistent newlines. Our linters would then flag these issues, and the agent would spend valuable cycles fixing its own simple mistakes.
This EditorConfig MCP Server is the tool I built to solve that problem for myself. It acts as a proactive formatting gatekeeper, using your project's .editorconfig rules to ensure files are correct from the start. My hope is that it might be useful to others who've encountered a similar frustration in their AI-assisted development process.
npm install -g editorconfig-mcp-server
Then start the server:
editorconfig-mcp-server
npx editorconfig-mcp-server
npm install editorconfig-mcp-server
Then add to your project's scripts in package.json
:
{
"scripts": {
"format-server": "editorconfig-mcp-server"
}
}
git clone https://github.com/yourusername/editorconfig-mcp-server.git
cd editorconfig-mcp-server
npm install
npm start
/v1/
prefixnpm install
# If installed globally
editorconfig-mcp-server
# Using npx
npx editorconfig-mcp-server
# With custom port
PORT=8080 editorconfig-mcp-server
# From source
npm start
The server will start on port 8432 by default.
PORT
- Server port (default: 8432)
PORT=8080 editorconfig-mcp-server
To add this server to Claude Code, run:
claude mcp add editorconfig npx editorconfig-mcp-server
This server is designed to be used with AI coding assistants that support MCP. Configure your AI tool to connect to:
http://localhost:8432
POST /v1/tools/format_file
Format a single file using .editorconfig rules.
Request:
{
"file_path": "src/index.js"
}
Response:
{
"success": true,
"file_path": "src/index.js",
"bytes": 1234
}
POST /v1/tools/format_files
Format multiple files matching a glob pattern.
Request:
{
"pattern": "**/*.js"
}
Response:
{
"success": true,
"pattern": "**/*.js",
"count": 5,
"files": ["src/index.js", "src/utils.js", ...]
}
GET /openapi.json
- OpenAPI 3.0 specificationGET /.well-known/mcp/servers.json
- MCP server manifestGET /health
- Health check endpointAll errors follow a consistent format:
{
"error": "Error type",
"message": "Human-readable message",
"hint": "Helpful suggestion",
"expected_format": {} // Optional, for validation errors
}
The server implements rate limiting:
This project follows Semantic Versioning:
To release a new version:
# For a patch release (1.0.0 -> 1.0.1)
npm version patch
# For a minor release (1.0.0 -> 1.1.0)
npm version minor
# For a major release (1.0.0 -> 2.0.0)
npm version major
This will:
To publish this package to npm:
npm login
npm version
(see above)npm publish
For automated publishing via GitHub:
NPM_TOKEN
To register this server in the MCP registry:
# Install dependencies
npm install
# Run linter
npm run lint
# Fix linting issues
npm run lint:fix
# Start server
npm start
MIT