Skip to main content
Glama
wagonbomb

Megaraptor MCP

by wagonbomb

generate_ansible_playbook

Generate Ansible playbooks to deploy agents across Windows, Linux, and macOS platforms for endpoint management and forensic investigation workflows.

Instructions

Generate Ansible playbook for agent deployment.

Creates a complete Ansible role with tasks for all selected platforms.

Args: deployment_id: The deployment to generate playbook for include_windows: Include Windows deployment tasks include_linux: Include Linux deployment tasks include_macos: Include macOS deployment tasks labels: Labels to apply to deployed agents

Returns: Path to generated playbook directory and usage instructions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
deployment_idYes
include_windowsNo
include_linuxNo
include_macosNo
labelsNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The `generate_ansible_playbook` tool function in `src/megaraptor_mcp/tools/deployment.py`. It uses `AnsiblePlaybookGenerator` to create an Ansible role for Velociraptor agent deployment.
    async def generate_ansible_playbook(
        deployment_id: str,
        include_windows: bool = True,
        include_linux: bool = True,
        include_macos: bool = True,
        labels: Optional[list[str]] = None,
    ) -> list[TextContent]:
        """Generate Ansible playbook for agent deployment.
    
        Creates a complete Ansible role with tasks for all selected platforms.
    
        Args:
            deployment_id: The deployment to generate playbook for
            include_windows: Include Windows deployment tasks
            include_linux: Include Linux deployment tasks
            include_macos: Include macOS deployment tasks
            labels: Labels to apply to deployed agents
    
        Returns:
            Path to generated playbook directory and usage instructions.
        """
        try:
            from ..deployment.agents import AnsiblePlaybookGenerator
            from ..deployment.agents.ansible_gen import AnsibleConfig
            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 Ansible config
            config = AnsibleConfig(
                server_url=info.server_url.replace("/api/", "") + ":8000/",
                ca_cert=bundle.ca_cert,
                ca_fingerprint=bundle.ca_fingerprint,
                client_labels=labels or ["ansible-deployed"],
                deployment_id=deployment_id,
            )
    
            # Generate playbook
            generator = AnsiblePlaybookGenerator()
            result = generator.generate(
                config,
                include_windows=include_windows,
                include_linux=include_linux,
                include_macos=include_macos,
            )
    
            return [TextContent(
                type="text",
                text=json.dumps({
                    **result.to_dict(),
                    "usage": [
                        "1. cd " + str(result.output_dir),
                        "2. cp inventory.yml.example inventory.yml",
                        "3. Edit inventory.yml with your hosts",
                        "4. ansible-playbook -i inventory.yml deploy_agents.yml",
                    ],
                }, 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)
            )]
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions that the tool 'Creates' a role and returns a path to the generated directory, implying file system side effects. However, it omits critical details like whether it overwrites existing files, idempotency guarantees, or validation requirements for the deployment_id.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The docstring format with distinct Args and Returns sections is well-structured and appropriate for the complexity. The text is front-loaded with the core purpose and efficiently organized without redundant prose, though the Args section repeats information implicit in parameter names.

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 that an output schema exists, the description appropriately summarizes the return value (path and instructions) without exhaustive detail. However, for a tool that generates filesystem artifacts based on a deployment_id, it lacks operational context such as error conditions, required pre-existing state, or platform-specific behavioral differences.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema has 0% description coverage, so the description compensates by providing an Args section that documents all 5 parameters with basic semantics (e.g., 'Include Windows deployment tasks'). While the descriptions are concise rather than comprehensive, they successfully convey the purpose of each parameter where the schema fails to do so.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool generates an Ansible playbook for agent deployment and creates a complete Ansible role. It specifies the resource type (Ansible playbook/role) which distinguishes it from siblings like generate_agent_installer or deploy_agents_ssh, though it could more explicitly clarify the IaC vs. direct deployment distinction.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description lacks explicit guidance on when to use this tool versus alternatives like deploy_agents_ssh, deploy_agents_winrm, or generate_agent_installer. It does not mention prerequisites (e.g., whether the deployment_id must exist beforehand) or when Ansible automation is preferred over direct deployment methods.

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/wagonbomb/megaraptor-mcp'

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