zig-mcp
Provides Zig language support through ZLS integration, offering code intelligence features such as hover information, definition lookup, reference finding, and formatting, along with tools for running Zig build, test, and check commands.
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 / checkRequirements
Related MCP server: Token Saver MCP
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@zigOr as a one-liner from the terminal:
claude plugin marketplace add nzrsky/zig-mcp && claude plugin install zig-mcp@zigThe 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=ReleaseFastBinary 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/projectOr 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 versionTools
All of these answer from ZLS's semantic model — the part a shell and a text search cannot reach.
Tool | What it knows that grep does not |
| The one true declaration, followed through imports and aliases. Takes |
| Real usages, scope-aware; skips same-named identifiers, comments and strings. |
| The type after comptime evaluation and inference — invisible in the source text |
| Errors for one file without building the project, re-synced against disk first |
| Declarations by name, not every line mentioning it |
| A file's outline: declarations, kinds, nesting |
| What can legally follow at a position, with types |
| The real signature, comptime and generic parameters included |
| Which files a rename touches, scope-aware |
| Quick fixes ZLS offers for a range |
| Every inferred type in a file at once — nothing of this is in the source text |
| The declaration of a value's type, not of the value |
| Code by shape: empty |
| Private declarations nothing refers to — exact, because a non- |
What is deliberately absent
There is no zig_build, zig_test, zig_format, zig_version, zig_check
or zig_manage. They used to exist and wrapped zig build, zig test,
zig fmt, zig version, zig ast-check and zvm — and a wrapper loses to
the shell it wraps: no pipes, no redirection, no working
directory of its own. Session transcripts settle it: 526 zig build
invocations through the shell, zero calls to the tool. Run those with your
shell.
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, and re-synced (didChange) whenever their contents change on disk -- no need to manage document state manually.
Development
# build
zig build
# run tests (162 unit tests, including a fake-ZLS harness)
zig build test
# quality gates: lint, coverage, dead code, mutants
make lint cov deadcode mutants
# run manually
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"capabilities":{}}}' | \
zig-out/bin/zig-mcp --workspace . 2>/dev/nullLicense
MIT
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/nzrsky/zig-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server