Skip to main content
Glama
openSVM

Zig MCP Server

by openSVM

generate_build_zon

Create a build.zig.zon file for managing project dependencies by specifying names and URLs.

Instructions

Generate a build.zig.zon file for dependency management

Input Schema

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

Implementation Reference

  • src/index.ts:301-328 (registration)
    Tool registration in ListToolsRequestSchema handler — defines the 'generate_build_zon' tool name, description, and inputSchema with projectName and dependencies.
    {
      name: 'generate_build_zon',
      description: 'Generate a build.zig.zon file for dependency management',
      inputSchema: {
        type: 'object',
        properties: {
          projectName: {
            type: 'string',
            description: 'Name of the project',
            default: 'my-project',
          },
          dependencies: {
            type: 'array',
            items: {
              type: 'object',
              properties: {
                name: { type: 'string' },
                url: { type: 'string' },
              },
              required: ['name', 'url'],
            },
            description: 'List of dependencies with their URLs',
            default: [],
          },
        },
        required: [],
      },
    },
  • Tool dispatch in CallToolRequestSchema switch — calls this.generateBuildZon(args || {}) for 'generate_build_zon' case.
    case 'generate_build_zon':
      return {
        content: [
          {
            type: 'text',
            text: this.generateBuildZon(args || {}),
          },
        ],
      };
  • Private method generateBuildZon on ZigServer — extracts projectName/dependencies from args, calls ZigBuildSystemHelper.generateBuildZon(), and wraps result in a markdown response with instructions.
      private generateBuildZon(args: Record<string, any>): string {
        Logger.debug('Generating build.zig.zon file');
    
        const _projectName = args.projectName || 'my-project';
        const dependencies = Array.isArray(args.dependencies) ? args.dependencies : [];
    
        const buildZonContent = ZigBuildSystemHelper.generateBuildZon(dependencies);
    
        return `
    # Generated build.zig.zon
    
    \`\`\`zig
    ${buildZonContent}
    \`\`\`
    
    ## Dependency Management Instructions:
    
    1. **Add a new dependency:**
       - Add the dependency to the .dependencies section
       - Run \`zig build --fetch\` to download and validate
    
    2. **Update dependency hashes:**
       - Zig will provide the correct hash when a mismatch is detected
       - Copy the hash from the error message to build.zig.zon
    
    3. **Use dependencies in build.zig:**
       \`\`\`zig
       const my_dep = b.dependency("my_dep", .{
           .target = target,
           .optimize = optimize,
       });
       exe.linkLibrary(my_dep.artifact("my_dep"));
       \`\`\`
    
    ## Popular Zig Dependencies:
    ${Object.entries(ZigBuildSystemHelper.getExampleDependencies())
      .map(([_key, dep]) => `- **${dep.name}**: ${dep.url}`)
      .join('\n')}
    
    ## Best Practices:
    - Keep dependencies minimal and well-maintained
    - Pin to specific versions or commits for reproducible builds
    - Regularly update dependencies for security fixes
    - Document why each dependency is needed
        `.trim();
      }
  • Static method ZigBuildSystemHelper.generateBuildZon — generates the raw build.zig.zon file content with .name, .version, .dependencies (mapped from ZigModuleDependency[]), and .paths.
      /**
       * Generates a build.zig.zon file for dependency management
       */
      static generateBuildZon(dependencies: ZigModuleDependency[]): string {
        return `.{
        .name = "my-project",
        .version = "0.1.0",
        .minimum_zig_version = "0.15.2",
        
        .dependencies = .{
    ${dependencies
      .map(
        dep => `        .${dep.name} = .{
                .url = "${dep.url || `https://github.com/example/${dep.name}`}",
                .hash = "1220000000000000000000000000000000000000000000000000000000000000",
            },`
      )
      .join('\n')}
        },
        
        .paths = .{
            "build.zig",
            "build.zig.zon",
            "src",
            // "examples",
            // "test",
            // "README.md",
            // "LICENSE",
        },
    }`;
      }
  • ZigModuleDependency interface — defines the type used for dependency entries with name, path, version?, and url? fields.
    export interface ZigModuleDependency {
      name: string;
      path: string;
      version?: string;
      url?: string;
    }
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.

Install Server

Other Tools

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