Skip to main content
Glama
NellyW8

EDA Tools MCP Server

by NellyW8

run_openlane

Execute complete ASIC design flow from RTL to GDSII using OpenLane for chip implementation.

Instructions

Run complete ASIC design flow using OpenLane (RTL to GDSII). This process can take up to 10 minutes.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
verilog_codeYesThe Verilog RTL code for ASIC implementation
design_nameYesName of the design (will be used for module and files)
clock_portNoName of the clock portclk
clock_periodNoClock period in nanoseconds
open_in_klayoutNoAutomatically open result in KLayout

Implementation Reference

  • The core handler function `runOpenlane` in the `EDAServer` class. It creates a temporary OpenLane project directory, writes the provided Verilog code and configuration (including clock port and period), generates a wrapper bash script to run OpenLane via Docker, executes it with timeout handling, locates the generated GDS file, and optionally launches KLayout to view it. Returns JSON with project details, paths, stdout/stderr (truncated), and status.
      async runOpenlane(
        verilogCode: string, 
        designName: string, 
        clockPort = "clk", 
        clockPeriod = 10.0,
        openInKlayout = true
      ): Promise<string> {
        try {
          const projectId = Math.random().toString(36).substring(2, 15);
          const projectName = `${designName}_${projectId}`;
          const projectDir = join(this.openlaneDir, projectName);
          
          // Store project info
          this.projects.set(projectId, { dir: projectDir, type: "openlane" });
    
          // Create project directory
          await fs.mkdir(projectDir, { recursive: true });
    
          // Write Verilog file
          const verilogFile = join(projectDir, `${designName}.v`);
          await fs.writeFile(verilogFile, verilogCode);
    
          // Create OpenLane config
          const configContent = {
            DESIGN_NAME: designName,
            VERILOG_FILES: [`${designName}.v`],
            CLOCK_PORT: clockPort,
            CLOCK_PERIOD: clockPeriod,
            // Additional OpenLane settings for better results
            FP_SIZING: "absolute",
            DIE_AREA: "0 0 100 100",
            FP_PDN_MULTILAYER: false,
            QUIT_ON_TIMING_VIOLATIONS: false,
            QUIT_ON_MAGIC_DRC: false,
            QUIT_ON_LVS_ERROR: false,
            RUN_KLAYOUT_XOR: false,
            RUN_KLAYOUT_DRC: false
          };
    
          const configFile = join(projectDir, "config.json");
          await fs.writeFile(configFile, JSON.stringify(configContent, null, 2));
    
          // Find Python command
          let pythonCmd = "python3";
          const pythonCandidates = [
            "python3",
            "python"
          ];
          
          for (const candidate of pythonCandidates) {
            if (await commandExists(candidate)) {
              pythonCmd = candidate;
              break;
            }
          }
    
          // Run the OpenLane command using Docker MCP approach
          console.error(`Starting OpenLane flow for ${designName}...`);
          console.error(`Working directory: ${projectDir}`);
          console.error(`This may take up to 10 minutes...`);
    
          const openlaneCmd = `${pythonCmd} -m openlane --dockerized config.json`;
          console.error(`Executing: ${openlaneCmd}`);
    
          // Create a wrapper script to handle TTY issues
          const wrapperScript = `#!/bin/bash
    set -e
    
    # Disable TTY requirements
    export DEBIAN_FRONTEND=noninteractive
    export CI=true
    export TERM=dumb
    
    # Change to project directory
    cd "${projectDir}"
    
    # Run OpenLane with script command to simulate TTY
    script -q /dev/null ${pythonCmd} -m openlane --dockerized config.json
    `;
    
          const wrapperPath = join(projectDir, 'run_openlane.sh');
          await fs.writeFile(wrapperPath, wrapperScript);
          await execAsyncWithTimeout(`chmod +x "${wrapperPath}"`, {});
    
          // Run the OpenLane command using the wrapper script
          console.error(`Starting OpenLane flow for ${designName}...`);
          console.error(`Working directory: ${projectDir}`);
          console.error(`This may take up to 10 minutes...`);
          console.error(`Using wrapper script to handle TTY`);
    
          const { stdout, stderr } = await execAsyncWithTimeout(`"${wrapperPath}"`, {
            cwd: projectDir,
            env: {
              ...process.env,
              PATH: process.env.PATH + ":/usr/local/bin:/opt/homebrew/bin"
            },
            maxBuffer: 10 * 1024 * 1024, // 10MB buffer instead of default 1MB
            timeout: 600000
          }, 600000); // 10 minutes timeout
    
          // Find the latest run directory
          const runsDir = join(projectDir, "runs");
          let latestRun = "";
          let gdsFile = "";
          
          try {
            const runs = await fs.readdir(runsDir);
            if (runs.length > 0) {
              // Sort runs by name (they include timestamps) and get the latest
              latestRun = runs.sort().reverse()[0];
              const finalDir = join(runsDir, latestRun, "final", "gds");
              
              // Find GDS file
              try {
                const gdsFiles = await fs.readdir(finalDir);
                const gdsFilesList = gdsFiles.filter(f => f.endsWith('.gds'));
                if (gdsFilesList.length > 0) {
                  gdsFile = join(finalDir, gdsFilesList[0]);
                }
              } catch {
                // GDS directory might not exist
              }
            }
          } catch {
            // Runs directory might not exist
          }
    
          let klayoutResult = "";
          
          // Open in KLayout if requested and GDS file exists
          if (openInKlayout && gdsFile) {
            try {
              // Check if KLayout is available
              if (await commandExists('klayout')) {
                // Launch KLayout with the GDS file
                const klayoutCmd = `open -a KLayout "${gdsFile}" &`;
                await execAsyncWithTimeout(klayoutCmd, {}, 10000);
                klayoutResult = `KLayout launched with GDS file: ${basename(gdsFile)}`;
              } else {
                klayoutResult = "KLayout not found. Install KLayout to view GDS files.";
              }
            } catch (error: any) {
              klayoutResult = `KLayout launch failed: ${error.message}`;
            }
          }
    
          return JSON.stringify({
            project_id: projectId,
            success: true,
            design_name: designName,
            project_dir: projectDir,
            latest_run: latestRun,
            gds_file: gdsFile ? basename(gdsFile) : "Not generated",
            gds_path: gdsFile,
            klayout_status: klayoutResult,
            command_used: openlaneCmd,
            stdout: stdout.length > 2000 ? stdout.substring(0, 2000) + "...(truncated)" : stdout,
            stderr: stderr.length > 2000 ? stderr.substring(0, 2000) + "...(truncated)" : stderr,
            note: "OpenLane flow completed. Check the runs directory for detailed results."
          }, null, 2);
    
        } catch (error: any) {
          // Simple error reporting
          const errorMessage = error.message || String(error);
          console.error(`OpenLane error: ${errorMessage}`);
          
          return JSON.stringify({
            success: false,
            error: errorMessage,
            note: "OpenLane flow failed. Make sure Docker is running and try: docker pull efabless/openlane:latest"
          }, null, 2);
        }
      }
  • The input schema definition for the `run_openlane` tool, specifying required parameters (verilog_code, design_name) and optional ones (clock_port, clock_period, open_in_klayout). Used for validation in MCP tool calls.
    inputSchema: {
      type: "object",
      properties: {
        verilog_code: { 
          type: "string", 
          description: "The Verilog RTL code for ASIC implementation" 
        },
        design_name: { 
          type: "string", 
          description: "Name of the design (will be used for module and files)" 
        },
        clock_port: { 
          type: "string", 
          description: "Name of the clock port", 
          default: "clk" 
        },
        clock_period: { 
          type: "number", 
          description: "Clock period in nanoseconds", 
          default: 10.0 
        },
        open_in_klayout: {
          type: "boolean",
          description: "Automatically open result in KLayout",
          default: true
        },
      },
      required: ["verilog_code", "design_name"],
    },
  • src/index.ts:786-818 (registration)
    Registration of the `run_openlane` tool in the MCP server's `ListToolsRequestSchema` handler. Includes name, description, and references the inputSchema. This makes the tool discoverable by MCP clients.
    {
      name: "run_openlane",
      description: "Run complete ASIC design flow using OpenLane (RTL to GDSII). This process can take up to 10 minutes.",
      inputSchema: {
        type: "object",
        properties: {
          verilog_code: { 
            type: "string", 
            description: "The Verilog RTL code for ASIC implementation" 
          },
          design_name: { 
            type: "string", 
            description: "Name of the design (will be used for module and files)" 
          },
          clock_port: { 
            type: "string", 
            description: "Name of the clock port", 
            default: "clk" 
          },
          clock_period: { 
            type: "number", 
            description: "Clock period in nanoseconds", 
            default: 10.0 
          },
          open_in_klayout: {
            type: "boolean",
            description: "Automatically open result in KLayout",
            default: true
          },
        },
        required: ["verilog_code", "design_name"],
      },
    },
  • The switch case dispatcher in `CallToolRequestSchema` handler that validates parameters and invokes `edaServer.runOpenlane()` with extracted arguments (verilogCode, designName, etc.). Returns the result as MCP content.
    case "run_openlane": {
      const verilogCode = validateRequiredString(args, "verilog_code", name);
      const designName = validateRequiredString(args, "design_name", name);
      const clockPort = getStringProperty(args, "clock_port", "clk");
      const clockPeriod = getNumberProperty(args, "clock_period", 10.0);
      const openInKlayout = args && args.open_in_klayout !== false; // Default true
      
      return {
        content: [{
          type: "text",
          text: await edaServer.runOpenlane(verilogCode, designName, clockPort, clockPeriod, openInKlayout),
        }],
      };
    }

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/NellyW8/mcp-EDA'

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