Skip to main content
Glama

openvsp.modify

Apply scripted parameter edits to an OpenVSP model, adjusting geometry with set commands and returning the generated script path.

Instructions

Apply scripted parameter edits to an OpenVSP model without running VSPAero. Use set_commands to adjust geometry; returns the generated script path.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
requestYes

Implementation Reference

  • MCP handler function for openvsp.modify tool, registered with @app.tool and delegates to execute_openvsp with run_vspaero=False.
    @app.tool( name="openvsp.modify", description=( "Apply scripted parameter edits to an OpenVSP model without running VSPAero. " "Use set_commands to adjust geometry; returns the generated script path."), meta={"version": "0.1.0", "categories": ["geometry"]}, ) def modify(request: OpenVSPRequest) -> OpenVSPResponse: return execute_openvsp(request.model_copy(update={"run_vspaero": False}))
  • Core execution logic for OpenVSP modifications and optional VSPAero run, invoked by the tool handler.
    def execute_openvsp(request: OpenVSPRequest) -> OpenVSPResponse: """Run OpenVSP (and optionally VSPAero) using the provided request.""" with tempfile.TemporaryDirectory(prefix="openvsp_mcp_") as tmpdir: workdir = Path(tmpdir) script_path = _write_script(request, workdir) try: result = subprocess.run( [OPENVSP_BIN, "-script", str(script_path)], check=False, capture_output=True, ) except FileNotFoundError as exc: # pragma: no cover raise RuntimeError("OpenVSP binary not found") from exc if result.returncode not in _OK_EXIT_CODES: message = result.stderr.decode("utf-8", errors="ignore").strip() if not message: message = result.stdout.decode("utf-8", errors="ignore").strip() or "OpenVSP script execution failed" raise RuntimeError(message) vspaero_output: str | None = None if request.run_vspaero: try: aero = subprocess.run( [VSPAERO_BIN, request.geometry_file, request.case_name], check=False, capture_output=True, ) except FileNotFoundError as exc: # pragma: no cover raise RuntimeError("VSPAero binary not found") from exc if aero.returncode != 0: message = aero.stderr.decode("utf-8", errors="ignore").strip() if not message: message = aero.stdout.decode("utf-8", errors="ignore").strip() or "VSPAero execution failed" raise RuntimeError(message) vspaero_output = str(Path(request.case_name).with_suffix(".adb")) return OpenVSPResponse(script_path=str(script_path), result_path=vspaero_output)
  • Pydantic input model (OpenVSPRequest) defining parameters for openvsp.modify tool calls.
    class OpenVSPRequest(BaseModel): """Parameters controlling geometry edits and optional VSPAero run.""" geometry_file: str = Field(..., description="Path to the .vsp3 file") set_commands: list[VSPCommand] = Field(default_factory=list, description="Commands to run") run_vspaero: bool = Field(True, description="Execute VSPAero after editing geometry") case_name: str = Field("case", description="Base name for generated results")
  • Pydantic output model (OpenVSPResponse) for openvsp.modify tool responses.
    class OpenVSPResponse(BaseModel): """Response object capturing generated paths.""" script_path: str = Field(..., description="Absolute path to the temporary script file") result_path: str | None = Field( None, description="Path to the generated VSPAero .adb file (if run_vspaero=True)", )
  • Generates the OpenVSP script file from set_commands and model path, used in execute_openvsp.
    def _write_script(request: OpenVSPRequest, working_dir: Path) -> Path: script_path = working_dir / "automation.vspscript" commands: Iterable[VSPCommand] = request.set_commands or [] script_lines = [ "// Auto-generated by openvsp-mcp", "void main() {", " ClearVSPModel();", f" ReadVSPFile(\"{request.geometry_file}\");", ] for command in commands: script_lines.append(f" {_ensure_statement(command.command)}") script_lines.extend( [ " Update();", f" SetVSP3FileName(\"{request.geometry_file}\");", f" WriteVSPFile(\"{request.geometry_file}\", SET_ALL);", "}", ] ) script_path.write_text("\n".join(script_lines) + "\n", encoding="utf-8") return script_path

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/yevheniikravchuk/openvsp-mcp'

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