generate_gpo_package
Create GPO deployment bundles for Windows domain environments by generating MSI installers, configuration files, and setup documentation to deploy agents across networks.
Instructions
Generate a GPO deployment bundle for Windows domain environments.
Creates MSI installer, configuration files, and step-by-step GPO setup documentation.
Args: deployment_id: The deployment to generate package for domain_controller: Name of the domain controller (for share paths) labels: Labels to apply to deployed agents
Returns: Path to GPO package and deployment instructions.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| deployment_id | Yes | ||
| domain_controller | No | DC01 | |
| labels | No |
Implementation Reference
- The 'generate_gpo_package' tool handler generates an MSI installer package for Windows GPO deployment, including necessary configuration and GPO setup documentation.
async def generate_gpo_package( deployment_id: str, domain_controller: str = "DC01", labels: Optional[list[str]] = None, ) -> list[TextContent]: """Generate a GPO deployment bundle for Windows domain environments. Creates MSI installer, configuration files, and step-by-step GPO setup documentation. Args: deployment_id: The deployment to generate package for domain_controller: Name of the domain controller (for share paths) labels: Labels to apply to deployed agents Returns: Path to GPO package and deployment instructions. """ try: from pathlib import Path from datetime import datetime, timezone from ..deployment.agents import InstallerGenerator from ..deployment.agents.installer_gen import InstallerConfig, InstallerType from ..deployment.security import CertificateManager from ..deployment.deployers import DockerDeployer # Get deployment info deployer = DockerDeployer() info = await deployer.get_status(deployment_id) if not info: return [TextContent( type="text", text=json.dumps({ "error": f"Deployment not found: {deployment_id}", "hint": "Use list_deployments tool to see available deployments" }, indent=2) )] # Load certificates cert_manager = CertificateManager() bundle = cert_manager.load_bundle(deployment_id) if not bundle: return [TextContent( type="text", text=json.dumps({ "error": "Certificate bundle not found" }, indent=2) )] # Create output directory output_dir = Path(os.environ.get("LOCALAPPDATA", "~")).expanduser() / "megaraptor-mcp" / "gpo" / deployment_id output_dir.mkdir(parents=True, exist_ok=True) # Generate MSI installer config config = InstallerConfig( server_url=info.server_url.replace("/api/", "") + f":{8000}/", ca_cert=bundle.ca_cert, ca_fingerprint=bundle.ca_fingerprint, labels=labels or ["gpo-deployed"], deployment_id=deployment_id, ) # Generate installer generator = InstallerGenerator(output_dir=output_dir) installer = await generator.generate(config, InstallerType.MSI) # Generate GPO instructions from template try: from jinja2 import Template from ..deployment.templates import get_template_path template_path = get_template_path("gpo_instructions.md.j2") template = Template(template_path.read_text()) instructions = template.render( deployment_id=deployment_id, generated_at=datetime.now(timezone.utc).isoformat(), server_url=info.server_url, server_hostname=info.server_url.split("://")[1].split(":")[0], frontend_port=8000, domain_controller=domain_controller, ca_fingerprint=bundle.ca_fingerprint, ) instructions_file = output_dir / "GPO_Instructions.md" instructions_file.write_text(instructions) except Exception: # Fallback if Jinja2 not available instructions_file = output_dir / "GPO_Instructions.txt" instructions_file.write_text(f"GPO deployment instructions for {deployment_id}") # Copy CA certificate ca_file = output_dir / "ca.crt" ca_file.write_text(bundle.ca_cert) return [TextContent( type="text", text=json.dumps({ "success": True, "output_directory": str(output_dir), "files": [ str(installer.file_path), str(instructions_file), str(ca_file), ], "instructions": f"See {instructions_file.name} for deployment steps", "ca_fingerprint": bundle.ca_fingerprint, }, indent=2) )] except ImportError as e: return [TextContent( type="text", text=json.dumps({ "error": f"Missing dependency: {str(e)}", "hint": "Install required packages with: pip install megaraptor-mcp[deployment]" }, indent=2) )] except Exception: # Generic errors - don't expose internals return [TextContent( type="text", text=json.dumps({ "error": "Operation failed", "hint": "Check deployment configuration and try again" }, indent=2) )]