ZW

zig-wasm/zig-mcp

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

177 stars 8 forks 质量 69 趋势 0MIT

模型上下文协议(MCP)服务器,提供Zig编程语言标准库和内置函数的最新文档

概览

模型上下文协议(MCP)服务器,提供Zig编程语言标准库和内置函数的最新文档。 它采用了与 Zig 官方自动文档(ziglang.org)相同的方法,通过 WASM 模块直接读取 STD 库的源文件。但它没有返回 HTML,而是输出 Markdown,这大大减少了令牌使用。 默认情况下,服务器会使用你本地安装的Zig编译器来提供文档,确保你总能获得与实际Zig版本一致的文档。如果需要,它还能从 ziglang.org 获取文档。 如果你想明确指示LLM使用Zig文档工具,可以在提示中添加“使用 zigdocs”。否则,LLM会自动根据你问题的上下文决定何时使用MCP工具。 - - 列出所有可用的 Zig 内置函数。内置函数由编译器提供,前缀为 '@'。

概述(AI 翻译)

模型上下文协议(MCP)服务器,提供Zig编程语言标准库和内置函数的最新文档。

它采用了与 Zig 官方自动文档(ziglang.org)相同的方法,通过 WASM 模块直接读取 STD 库的源文件。但它没有返回 HTML,而是输出 Markdown,这大大减少了令牌使用。

默认情况下,服务器会使用你本地安装的Zig编译器来提供文档,确保你总能获得与实际Zig版本一致的文档。如果需要,它还能从 ziglang.org 获取文档。

[!提示] 如果你想明确指示LLM使用Zig文档工具,可以>在提示中添加use zigdocs。否则,LLM会根据你问题的上下文自动决定何时使用MCP工具。

工具

  • list_builtin_functions - 列出所有可用的 Zig 内置函数。内置函数由编译器提供,前缀为 ‘@’。参数上的 comptime 关键字表示该参数必须在编译时已知。利用该关键词发现可用函数,然后使用 ‘get_builtin_function’ 获取详细文档。

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

Zig Docs MCP

Model Context Protocol (MCP) server that provides up-to-date documentation for the Zig programming language standard library and builtin functions.

It uses the same approach as Zig’s official autodoc (ziglang.org) by reading STD lib source files directly through a WASM module. However instead of returning HTML, it outputs Markdown which significantly reduces token usage.

By default, the server uses your locally installed Zig compiler to serve documentation, ensuring you always get docs that match your actual Zig version. It can also fetch documentation from ziglang.org if needed.

[!TIP] Add use zigdocs to your prompt if you want to explicitly instruct the LLM to use Zig docs tools. Otherwise, LLM will automatically decide when to utilize MCP tools based on the context of your questions.

Tools

  • list_builtin_functions - Lists all available Zig builtin functions. Builtin functions are provided by the compiler and are prefixed with ‘@’. The comptime keyword on a parameter means that the parameter must be known at compile time. Use this to discover what functions are available, then use ‘get_builtin_function’ to get detailed documentation.
  • get_builtin_function - Search for Zig builtin functions by name and get their documentation, signatures, and usage information. Returns all matching functions ranked by relevance.
  • search_std_lib - Search the Zig standard library for declarations by name. Returns a list of matching items with their fully qualified names. Use this to discover available types, functions, and constants in the standard library.
  • get_std_lib_item - Get detailed documentation for a specific standard library item by its fully qualified name (e.g., “std.ArrayList.init”). Returns comprehensive documentation including function signatures, parameters, errors, examples, and source code. Set get_source_file: true to retrieve the entire source file where the item is implemented.

Commands

The CLI provides flexible options for version control and update management:

# Start MCP server
zig-mcp --doc-source local

# Use specific Zig version from ziglang.org instead of local Zig
zig-mcp --doc-source remote --version 0.14.1

# Enable automatic daily updates
zig-mcp --doc-source remote --update-policy daily

# Update documentation without starting MCP server (only for remote)
zig-mcp update --version 0.15.1

# Start local web server to view documentation
zig-mcp view --version 0.15.1

Version options --version:

  • master (default) - Latest development version from Zig’s master branch
  • 0.14.1, 0.14.0, etc. - Specific Zig release versions

Update policies --update-policy:

在 GitHub 查看完整 README

安装

npx -y zig-mcp@latest
新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "zig-docs": { "command": "npx", "args": ["-y", "zig-mcp@latest"] } } }