Get the FREE Ultimate OpenClaw Setup Guide →

TryClangMcpServer

MCP server from udaken/TryClangMcpServer

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio udaken-tryclangmcpserver dotnet run \
  --env ASPNETCORE_URLS="http://+:3000" \
  --env DOTNET_ENVIRONMENT="Development"

How to use

TryClangMcpServer exposes three MCP tools for C/C++ development via the Clang toolchain integrated with ClangSharp. The compile_cpp tool compiles C/C++ source code and returns diagnostics, including errors and warnings. The analyze_cpp tool runs static analysis to surface potential issues, while get_ast generates an Abstract Syntax Tree in JSON format for deeper code understanding. You can interact with the server over stdio (default) or via HTTP by starting the server with HTTP mode enabled. For HTTP mode, you can query the tools list, call specific tools, and request health status. Typical usage includes sending JSON-RPC requests to list tools, followed by a call to a tool with the appropriate parameters such as sourceCode and options. The server handles execution in isolated environments and provides structured responses that report success, diagnostics, and relevant metadata like sourceFile and AST structures.

How to install

Prerequisites:

  • .NET 9.0 or later
  • Supported platforms: Windows x64, Linux x64, macOS x64/ARM64
  • libclang native dependencies for your platform (as required by ClangSharp)

Installation steps:

  1. Clone the repository:
git clone <repository-url>
cd TryClangMcpServer
  1. Restore and build the project:
dotnet restore
dotnet build
  1. Run the server (default stdio mode):
dotnet run
  1. (Optional) Run in HTTP mode for web access:
dotnet run --http
  • Default HTTP port is 3000. You can specify a custom port:
dotnet run --http --port 8080

Notes:

  • Ensure libclang native libraries are available for your platform before starting the server.
  • If you plan to run in production, consider publishing a self-contained executable and configuring environment specifics accordingly.

Additional notes

Tips and common considerations:

  • The server supports both stdio and HTTP transports. Use stdio for MCP client integrations and HTTP for web-based access.
  • Tools supported: compile_cpp, analyze_cpp, get_ast. Each tool accepts sourceCode and optional options; responses include details like diagnostics, issues, and AST structures.
  • Temporary directories are used per invocation with GUID-based names and cleaned up automatically; ensure your environment has adequate permissions for creating temp files.
  • When running in HTTP mode, you can hit /health to check health status and /mcp to list or call tools via JSON-RPC payloads.
  • Ensure proper validation of inputs to avoid potentially dangerous operations, especially when exposing HTTP endpoints publicly.
  • If you run into ClangSharp or libclang-related runtime errors, verify that the correct libclang runtime for your platform is installed and accessible to the process.

Related MCP Servers

Sponsor this space

Reach thousands of developers