zig-mcp
MCP server for Zig that connects AI coding assistants to ZLS (Zig Language Server) via LSP — 16 tools for code intelligence, build, and test.
zig-mcp
MCP server for Zig that connects AI coding assistants to ZLS via the Language Server Protocol.
Works with Claude Code, Cursor, Windsurf, and any MCP-compatible client.
AI assistant <--(MCP stdio)--> zig-mcp <--(LSP pipes)--> ZLS
|
zig build / test / check
Requirements
Install
Claude Code plugin (recommended)
Install directly from the Claude Code interface — no manual build needed:
# 1. Add the marketplace
/plugin marketplace add nzrsky/zig-mcp
# 2. Install the plugin
/plugin install zig-mcp@zig
Or as a one-liner from the terminal:
claude plugin marketplace add nzrsky/zig-mcp && claude plugin install zig-mcp@zig
The binary is built automatically on first use. Just make sure zig and zls are in your PATH.
Manual build
git clone https://github.com/nzrsky/zig-mcp.git
cd zig-mcp
zig build -Doptimize=ReleaseFast
Binary is at zig-out/bin/zig-mcp.
Setup (manual install only)
If you installed via the plugin system, skip this section — everything is configured automatically.
Claude Code
# add globally
claude mcp add zig-mcp -- /absolute/path/to/zig-mcp --workspace /path/to/your/zig/project
# add for current project only
claude mcp add --scope project zig-mcp -- /absolute/path/to/zig-mcp --workspace /path/to/your/zig/project
Or edit ~/.claude/mcp_servers.json:
{
"mcpServers": {
"zig-mcp": {
"command": "/absolute/path/to/zig-mcp",
"args": ["--workspace", "/path/to/your/zig/project"]
}
}
}
If you omit
--workspace, zig-mcp uses the current working directory.
Cursor
Add to .cursor/mcp.json in your project:
{
"mcpServers": {
"zig-mcp": {
"command": "/absolute/path/to/zig-mcp",
"args": ["--workspace", "/path/to/your/zig/project"]
}
}
}
Windsurf
Add to ~/.codeium/windsurf/mcp_config.json:
{
"mcpServers": {
"zig-mcp": {
"command": "/absolute/path/to/zig-mcp",
"args": ["--workspace", "/path/to/your/zig/project"]
}
}
}
Options
--workspace, -w <path> Project root directory (default: cwd)
--zls-path <path> Path to ZLS binary (default: auto-detect from PATH)
--help, -h Show help
--version Show version
Tools
Code intelligence (via ZLS)
| Tool | What it does |
|---|---|
zig_hover | Type info and docs for a symbol |
zig_definition | Go to definition |
zig_references | Find all references |
zig_completion | Completion suggestions |
zig_diagnostics | Errors and warnings for a file |
zig_format | Format a file |
zig_rename | Rename a symbol across the workspace |
zig_document_symbols | List all symbols in a file |
zig_workspace_symbols | Search symbols across the project |
zig_code_action | Quick fixes and refactors for a range |
zig_signature_help | Function signature at cursor |
Build & run
| Tool | What it does |
|---|---|
zig_build | Run zig build with optional args |
zig_test | Run tests (whole project or single file, with optional filter) |
zig_check | Run zig ast-check on a file |
zig_version | Show Zig and ZLS versions |
zig_manage | Manage Zig versions via zvm |
How it works
zig-mcp spawns ZLS as a child process and talks to it over stdin/stdout using the LSP protocol (Content-Length framing). On the other side, it speaks MCP (newline-delimited JSON-RPC) to the AI assistant.
Three threads:
- main -- reads MCP requests, dispatches tool calls, writes responses
- reader -- reads LSP responses from ZLS, correlates by request ID
- stderr -- forwards ZLS stderr to the server log
If ZLS crashes, zig-mcp automatically restarts it and re-opens all tracked documents.
Files are opened in ZLS lazily on first access -- no need to manage document state manually.
Development
# build
zig build
# run tests (~75 unit tests)
zig build test
# run manually
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"capabilities":{}}}' | \
zig-out/bin/zig-mcp --workspace . 2>/dev/null
License
MIT
Máy chủ liên quan
Scout Monitoring MCP
nhà tài trợPut performance and error data directly in the hands of your AI assistant.
Alpha Vantage MCP Server
nhà tài trợAccess financial market data: realtime & historical stock, ETF, options, forex, crypto, commodities, fundamentals, technical indicators, & more
ChuckNorris
A specialized MCP gateway for LLM enhancement prompts and jailbreaks with dynamic schema adaptation. Provides prompts for different LLMs using an enum-based approach.
Tuteliq
AI-powered safety tools for detecting grooming, bullying, threats, and harmful interactions in conversations. The server integrates Tuteliq’s behavioral risk detection API via the Model Context Protocol (MCP), enabling AI assistants to analyze interaction patterns rather than relying on keyword moderation. Use cases include platform safety, chat moderation, child protection, and compliance with regulations such as the EU Digital Services Act (DSA), COPPA, and KOSA.
Windows API
An MCP server for interacting with the native Windows API, enabling control over system functions and resources.
MCP Base Server
A base template for creating new MCP servers, designed for easy containerized deployment with Docker.
Claude Prompts MCP Server
A universal MCP server that loads prompts from an external JSON configuration file.
Enhanced AutoGen MCP Server
Integrates with Microsoft's AutoGen framework to enable sophisticated multi-agent conversations via the Model Context Protocol.
Security Audit Tool
Audits npm package dependencies for security vulnerabilities with real-time checks against a remote npm registry.
Arcontextify
Convert ARC-56 smart contract specifications to MCP servers.
4o-image
Generate and edit images using text prompts with the 4o-image API.
Cloudflare MCP Server Example
An example of deploying a remote MCP server on Cloudflare Workers without authentication.