mcp-server-cpp-format
v0.3.0MCP server that formats C/C++ files with clang-format
Model Context Protocol (MCP) server that formats C/C++ source files in-place using clang-format. Designed to back the cpp-format Claude Code plugin, but usable as a standalone MCP server in any MCP-compatible client. The server is published on PyPI and intended to be invoked via uvx:
Summary extracted from the README.
mcp-server-cpp-format
Model Context Protocol (MCP) server that formats C/C++ source files in-place using clang-format.
Designed to back the cpp-format Claude Code plugin,
but usable as a standalone MCP server in any MCP-compatible client.
Install
The server is published on PyPI and intended to be invoked via uvx:
uvx mcp-server-cpp-format
Or install into a regular environment:
pip install mcp-server-cpp-format
mcp-server-cpp-format
Requires Python 3.10+ and clang-format available on PATH (or via CLANG_FORMAT_BIN).
Tools
applyClangFormat
Formats C/C++ source files in-place.
Arguments
| Name | Type | Required | Description |
|---|---|---|---|
files |
string[] |
yes | Absolute file paths or absolute glob patterns (/path/**/*.cpp). Directory paths without a glob are rejected. |
style |
string |
no | Explicit style (LLVM, Google, file, file:<path>, ...). Overrides environment defaults. |
Allowed extensions (others are silently skipped):
.c .cc .cpp .cxx .c++ .h .hh .hpp .hxx .h++ .ipp .tpp .inl
Style resolution priority
styleargument when explicitly providedCLANG_FORMAT_CONFIGenv (path to a.clang-format) →--style=file:<path>CLANG_FORMAT_STYLEenv (e.g.LLVM,Google) →--style=<style>- Default →
--style=file(clang-format auto-discovers.clang-formatupward; falls back to LLVM)
Environment variables
| Variable | Effect |
|---|---|
CLANG_FORMAT_BIN |
Absolute path to a clang-format binary. Default: clang-format from PATH. |
CLANG_FORMAT_CONFIG |
Absolute path to a .clang-format file to enforce. |
CLANG_FORMAT_STYLE |
Fallback style name when no .clang-format is provided/found. |
CPP_FORMAT_LOG_LEVEL |
Logging verbosity for the server (default INFO). |
License
MIT