mcp-server-cpp-format

v0.3.0
mcp-server-cpp-format Checked 2 days ago Published 4 months ago

MCP 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

  1. style argument when explicitly provided
  2. CLANG_FORMAT_CONFIG env (path to a .clang-format) → --style=file:<path>
  3. CLANG_FORMAT_STYLE env (e.g. LLVM, Google) → --style=<style>
  4. Default → --style=file (clang-format auto-discovers .clang-format upward; 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