Skip to main content
Glama
openSVM

Zig MCP Server

by openSVM

Zig MCP 服务器

模型上下文协议 (MCP) 服务器,提供 Zig 语言工具、代码分析和文档访问。该服务器通过 Zig 特有的功能(包括代码优化、计算单元估算、代码生成和最佳实践建议)增强 AI 能力。

特征

工具

1. 代码优化( optimize_code

分析和优化 Zig 代码,支持不同的优化级别:

  • 调试

  • ReleaseSafe

  • ReleaseFast

  • 发布小

// Example usage
{
  "code": "const std = @import(\"std\");\n...",
  "optimizationLevel": "ReleaseFast"
}

2. 计算单元估算( estimate_compute_units

估计 Zig 码的计算复杂度和资源使用情况:

  • 内存使用情况分析

  • 时间复杂度估计

  • 分配模式检测

// Example usage
{
  "code": "const std = @import(\"std\");\n..."
}

3.代码生成( generate_code

根据自然语言描述生成 Zig 代码,支持:

  • 错误处理

  • 测试

  • 性能优化

  • 文档

// Example usage
{
  "prompt": "Create a function that sorts an array of integers",
  "context": "Should handle empty arrays and use comptime when possible"
}

4. 代码建议( get_recommendations

提供代码改进建议和最佳实践:

  • 风格和惯例

  • 设计模式

  • 安全考虑

  • 性能洞察

// Example usage
{
  "code": "const std = @import(\"std\");\n...",
  "prompt": "Improve performance and safety"
}

资源

  1. 语言参考zig://docs/language-reference

    • Zig 语言官方文档

    • 语法和功能指南

    • 最佳实践

  2. 标准库文档zig://docs/std-lib

    • 完整的标准库参考

    • 函数签名和用法

    • 示例和注释

  3. 热门存储库zig://repos/popular

    • GitHub 上的热门 Zig 项目

    • 社区示例和模式

    • 现实世界的实现

Related MCP server: zig-mcp

安装

  1. 克隆存储库:

git clone [repository-url]
cd zig-mcp-server
  1. 安装依赖项:

npm install
  1. 构建服务器:

npm run build
  1. 配置环境变量:

# Create a GitHub token for better API rate limits
# https://github.com/settings/tokens
# Required scope: public_repo
GITHUB_TOKEN=your_token_here
  1. 添加到 MCP 设置:

{
  "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
    }
  }
}

使用示例

1.优化代码

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"
});

2. 估算计算单元

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;
                }
            }
        }
    }
  `
});

3. 生成代码

const result = await useMcpTool("zig", "generate_code", {
  prompt: "Create a thread-safe counter struct",
  context: "Should use atomic operations and handle overflow"
});

4.获得推荐

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

贡献

  1. 分叉存储库

  2. 创建你的功能分支( git checkout -b feature/amazing-feature

  3. 提交您的更改( git commit -m 'Add some amazing feature'

  4. 推送到分支( git push origin feature/amazing-feature

  5. 打开拉取请求

执照

MIT 许可证 - 有关详细信息,请参阅LICENSE文件。

Available Tools

7 tools
analyze_build_zigB

Analyze a build.zig file and provide modernization recommendations

ParametersJSON Schema
NameRequiredDescriptionDefault
buildZigContentYesContent of the build.zig file to analyze

TDQS

B3.1/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description should disclose behavioral traits. It states the tool analyzes and provides recommendations, but does not clarify if it is read-only, modifies files, or requires authentication. The behavior is left ambiguous.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single concise sentence that efficiently communicates the core function. No filler or redundancy. It is front-loaded with the verb and resource.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of an output schema and annotations, the description is insufficient. It does not specify the format or scope of recommendations, nor any side effects. The tool's complexity is low, but completeness is lacking.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100% for the single parameter. The tool description adds no extra meaning beyond what the schema already provides. Baseline of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly identifies the tool as analyzing a build.zig file and providing modernization recommendations. It uses a specific verb-resource pair and distinguishes itself from sibling tools like generate_build_zig or optimize_code.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No usage guidelines are provided. The description does not specify when to use this tool over alternatives, nor does it mention prerequisites or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

estimate_compute_unitsB

Estimate computational complexity and resource usage with detailed analysis

ParametersJSON Schema
NameRequiredDescriptionDefault
codeYesZig code to analyze

TDQS

B3.3/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the burden but only states 'with detailed analysis', failing to disclose behavior like side effects, safety, or cost implications.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence, no redundancy, immediately conveys purpose. Highly efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given low complexity (1 param, no output schema), the description is adequate but lacks details about output format or granularity, which would aid full understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% for the single parameter 'code'. The description adds broad context ('computational complexity') but doesn't enhance parameter meaning beyond the schema's description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states a specific action: estimating computational complexity and resource usage. It distinguishes from siblings (e.g., generate, analyze, optimize) by focusing on estimation with detailed analysis.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives. No context about prerequisites or exclusions, leaving the agent to infer usage.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

generate_build_zigB

Generate a modern build.zig file with best practices

ParametersJSON Schema
NameRequiredDescriptionDefault
projectNameNoName of the projectmy-project
projectTypeNoType of project to generateexecutable
zigVersionNoTarget Zig version0.15.2
dependenciesNoList of dependencies to include

TDQS

B3/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, and the description does not disclose behavioral traits such as whether the tool overwrites files, returns content, or requires permissions. The verb 'generate' implies creation but details are missing.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence that states the purpose, but it is too brief for a tool with four parameters and no output schema. It earns its place but lacks necessary detail.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no output schema and no annotations, the description fails to explain return values, side effects, or behavioral aspects. Essential context for an agent to invoke the tool correctly is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema covers 100% of parameters with descriptions, so the description adds no additional meaning beyond what is already in the schema. Baseline score of 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool generates a 'modern build.zig file', which is specific and distinguishes it from siblings like generate_build_zon (for .zon files) and analyze_build_zig (analysis).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives (e.g., generate_build_zon) or any prerequisites, leaving the agent to infer usage context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

generate_build_zonA

Generate a build.zig.zon file for dependency management

ParametersJSON Schema
NameRequiredDescriptionDefault
projectNameNoName of the projectmy-project
dependenciesNoList of dependencies with their URLs

TDQS

A3.5/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, and the description only states what the tool generates. It does not disclose whether it creates or overwrites files, if it requires any permissions, or what side effects occur. The description fails to compensate for the lack of annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, concise sentence that clearly communicates the tool's purpose. No unnecessary words or repetition.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the low complexity (2 parameters, no nested objects, no output schema), the description adequately states the purpose but lacks behavioral context such as whether a file is created or overwritten, or the return value.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both parameters (projectName, dependencies). The description adds no extra meaning beyond the schema; baseline score of 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action (Generate) and the resource (build.zig.zon file for dependency management). It distinguishes itself from sibling tools like generate_build_zig, which generates a different file type (build.zig).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for dependency management but does not explicitly state when to use this tool vs alternatives like generate_build_zig. No when-not conditions or alternative tool names are provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

generate_codeB

Generate modern Zig code from natural language descriptions

ParametersJSON Schema
NameRequiredDescriptionDefault
promptYesNatural language description of desired code
contextNoAdditional context or requirements

TDQS

B3.1/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries full burden, but it only states the generative action. It fails to disclose side effects, idempotency, error behavior, or safety implications, which is essential for a code generation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, concise sentence with no filler. It is front-loaded with the key action and resource. However, it could be restructured to include brief usage context without losing conciseness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a code generation tool with no output schema, the description is insufficient. It does not explain the return format, code quality, or limitations, leaving the agent without critical information for safe invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema covers both parameters with descriptions, achieving 100% coverage. The tool description does not add any extra meaning beyond what the schema states, so it meets the baseline but provides no additional semantic value.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly identifies the tool's primary function: generating modern Zig code from natural language. The verb 'Generate' and resource 'Zig code' are specific, and the source 'natural language descriptions' distinguishes it from sibling tools that analyze, estimate, or optimize code.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided about when to use this tool versus alternatives. It does not mention prerequisites, limitations, or typical use cases, leaving the agent to infer context from sibling names alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_recommendationsB

Get comprehensive, multi-dimensional code analysis with 10+ specialized analyzers covering style, safety, performance, concurrency, metaprogramming, testing, build systems, interop, metrics, and modern Zig patterns

ParametersJSON Schema
NameRequiredDescriptionDefault
codeYesZig code to analyze
promptNoNatural language query for specific recommendations (performance, safety, maintainability, concurrency, architecture, etc.)

TDQS

B3.3/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description must convey behavioral traits. It lists analyzers but does not disclose whether the tool is read-only, has side effects, requires authentication, or has usage limits. This leaves ambiguity for the agent.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence that is informative and front-loaded with the main purpose. While it lists many analyzers, it remains relatively concise and avoids unnecessary verbosity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of the tool with many analyzers and no output schema, the description should explain the output format or expected results. It only describes input but not output, leaving the agent uncertain about what to expect.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Input schema has 100% coverage with descriptions for both parameters. The description adds context about the analyzers but does not enhance parameter semantics beyond the schema. Baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool provides comprehensive, multi-dimensional code analysis with 10+ specialized analyzers, covering a wide range of aspects. It distinguishes from sibling tools like optimize_code or generate_code, which focus on different tasks.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for getting code recommendations but does not explicitly contrast with siblings or specify when not to use. It mentions a natural language query parameter, hinting at flexible queries, but lacks direct guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

optimize_codeB

Optimize Zig code for better performance with modern patterns

ParametersJSON Schema
NameRequiredDescriptionDefault
codeYesZig code to optimize
optimizationLevelNoOptimization level to targetReleaseSafe

TDQS

B3.1/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description must disclose behavioral traits, but it only mentions the purpose. It doesn't state whether the tool returns optimized code, modifies input, has side effects, or requires valid code. Critical gaps for a transformation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence. However, it lacks front-loading of critical information and structure, but is appropriately sized for the tool's simplicity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no output schema and no annotations, the description should explain what the tool returns (e.g., optimized code, error messages) and any constraints. It fails to provide sufficient context for an agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the baseline is 3. The description adds no extra meaning beyond what the schema already provides for the two parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's action ('Optimize') and resource ('Zig code') with a specific goal ('better performance with modern patterns'). It effectively distinguishes from siblings like 'generate_code' or 'analyze_build_zig'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives (e.g., when to optimize vs generate code). The description lacks context for selecting it over siblings.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 5 tool updatesv1.0.1
    • Addedanalyze_build_zig
    • Addedgenerate_build_zig
    • Addedgenerate_build_zon
    • Changedget_recommendations1 field changed
      • changedInput schema / properties / prompt / description
        Previous value: -"Natural language query for specific recommendations"New value: +"Natural language query for specific recommendations (performance, safety, maintainability, concurrency, architecture, etc.)"
    • Changedoptimize_code1 field changed
      • addedInput schema / properties / optimizationLevel / default
        Added value: +"ReleaseSafe"
  2. 4 tool updatesv1.0.0
    • First observedestimate_compute_units
    • First observedgenerate_code
    • First observedget_recommendations
    • First observedoptimize_code

TDQS

A3.5/5.0
Disambiguation4/5

Most tools are clearly distinct, but estimate_compute_units may overlap with the performance analysis included in get_recommendations, introducing slight ambiguity.

Naming Consistency5/5

All tool names follow a consistent verb_noun pattern in snake_case (e.g., analyze_build_zig, generate_code), making them predictable and easy to understand.

Tool Count5/5

With 7 tools covering code generation, build management, analysis, and optimization, the server is well-scoped for its purpose without being too few or excessive.

Completeness4/5

The tool set covers core Zig development tasks, but lacks explicit tools for test generation or documentation, which are minor gaps given the comprehensive get_recommendations tool.

Maintenance

ActivityNo data
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    C
    maintenance
    Enables AI-powered Zig programming assistance through code generation, debugging, and documentation explanation. Uses local LLM models to provide idiomatic Zig code creation and analysis capabilities.
    20
    10
    Do What The F*ck You Want To Public
  • F
    license
    Not graded
    quality
    C
    maintenance
    MCP server for Zig that connects AI coding assistants to ZLS (Zig Language Server) via LSP. Provides 16 tools for code intelligence (hover, go-to-definition, references, completions, diagnostics, rename, format) and build/test operations.
    6
    -
  • A
    license
    Not graded
    quality
    C
    maintenance
    Provides up-to-date Zig standard library and builtin function documentation via MCP tools, using local Zig installation or remote ziglang.org sources.
    108
    170
    MIT
  • A
    license
    A
    quality
    D
    maintenance
    Provides Zig language intelligence for Claude Code by wrapping ZLS (Zig Language Server) and exposing 8 tools for diagnostics, formatting, hover info, go-to-definition, references, completions, document symbols, and building.
    8
    19
    2
    MIT

Latest Blog Posts

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/openSVM/zig-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server