openvsp.run_vspaero
Execute aerodynamic analysis on aircraft geometry using VSPAero after applying OpenVSP modifications. Provide geometry commands and case name to run computational fluid dynamics simulations.
Instructions
Run OpenVSP edits followed by VSPAero. Provide geometry commands and case_name.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| request | Yes |
Implementation Reference
- src/openvsp_mcp/tool.py:39-46 (handler)Handler function for the 'openvsp.run_vspaero' tool, decorated with @app.tool for MCP registration. Delegates to core execute_openvsp with VSPAero enabled.@app.tool( name="openvsp.run_vspaero", description=( "Run OpenVSP edits followed by VSPAero. Provide geometry commands and case_name."), meta={"version": "0.1.0", "categories": ["geometry", "aero"]}, ) def run_vspaero(request: OpenVSPRequest) -> OpenVSPResponse: return execute_openvsp(request.model_copy(update={"run_vspaero": True}))
- src/openvsp_mcp/models.py:18-25 (schema)Pydantic schema for tool input: OpenVSPRequest, including run_vspaero flag specific to this tool's purpose.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")
- src/openvsp_mcp/core.py:29-70 (helper)Core helper implementing OpenVSP script execution and conditional 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)
- src/openvsp_mcp/core.py:79-103 (helper)Generates the temporary OpenVSP script (.vspscript) from the request's set_commands and geometry_file.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
- src/openvsp_mcp/__main__.py:73-74 (registration)Entry point registers tools by calling build_tool on the FastMCP app instance, which defines openvsp.run_vspaero.app = FastMCP(SERVICE_NAME, SERVICE_DESCRIPTION) build_tool(app)