openSVM/zig-mcp-server
A Model Context Protocol (MCP) server that provides Zig language tooling, code analysis, and documentation access. This server enhances AI capabilitie...
Modern Zig AI 10x dev assistant with comprehensive build system support
A powerful Model Context Protocol (MCP) server that provides comprehensive Zig language assistance, including modern build system support, code optimization, and best practices guidance.
generate_build_zig
)Generate modern build.zig files with Zig 0.12+ patterns:
analyze_build_zig
)Analyze existing build files and get modernization recommendations:
generate_build_zon
)Generate build.zig.zon files for modern package management:
optimize_code
)Enhanced with modern Zig patterns and build mode analysis:
// Example usage
{
"code": "const std = @import(\"std\");\n...",
"optimizationLevel": "ReleaseFast"
}
estimate_compute_units
)Estimates computational complexity and resource usage of Zig code:
// Example usage
{
"code": "const std = @import(\"std\");\n..."
}
generate_code
)Generates Zig code from natural language descriptions with support for:
// Example usage
{
"prompt": "Create a function that sorts an array of integers",
"context": "Should handle empty arrays and use comptime when possible"
}
get_recommendations
)Provides code improvement recommendations and best practices:
// Example usage
{
"code": "const std = @import(\"std\");\n...",
"prompt": "Improve performance and safety"
}
Language Reference (zig://docs/language-reference
)
Standard Library Documentation (zig://docs/std-lib
)
Popular Repositories (zig://repos/popular
)
To install Zig MCP Server for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install zig-mcp-server --client claude
git clone [repository-url]
cd zig-mcp-server
npm install
npm run build
# Create a GitHub token for better API rate limits
# https://github.com/settings/tokens
# Required scope: public_repo
GITHUB_TOKEN=your_token_here
{
"mcpServers": {
"zig": {
"command": "node",
"args": ["/path/to/zig-mcp-server/build/index.js"],
"env": {
"GITHUB_TOKEN": "your_token_here",
"NODE_OPTIONS": "--experimental-vm-modules"
},
"restart": true
}
}
}
const result = await useMcpTool("zig", "optimize_code", {
code: `
pub fn fibonacci(n: u64) u64 {
if (n <= 1) return n;
return fibonacci(n - 1) + fibonacci(n - 2);
}
`,
optimizationLevel: "ReleaseFast"
});
const result = await useMcpTool("zig", "estimate_compute_units", {
code: `
pub fn bubbleSort(arr: []i32) void {
var i: usize = 0;
while (i < arr.len) : (i += 1) {
var j: usize = 0;
while (j < arr.len - 1) : (j += 1) {
if (arr[j] > arr[j + 1]) {
const temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
}
}
}
}
`
});
const result = await useMcpTool("zig", "generate_code", {
prompt: "Create a thread-safe counter struct",
context: "Should use atomic operations and handle overflow"
});
const result = await useMcpTool("zig", "get_recommendations", {
code: `
pub fn main() !void {
var list = std.ArrayList(u8).init(allocator);
var i: u32 = 0;
while (true) {
if (i >= 100) break;
try list.append(@intCast(u8, i));
i += 1;
}
}
`,
prompt: "performance"
});
zig-mcp-server/
โโโ src/
โ โโโ index.ts # Main server implementation
โโโ build/ # Compiled JavaScript
โโโ package.json # Dependencies and scripts
โโโ tsconfig.json # TypeScript configuration
# Development build with watch mode
npm run watch
# Production build
npm run build
npm test
git checkout -b feature/amazing-feature
)git commit -m 'Add some amazing feature'
)git push origin feature/amazing-feature
)MIT License - see the LICENSE file for details.