Skip to main content
Glama
washyu
by washyu

check_ansible_service

Verify the deployment status of Ansible-managed services on homelab infrastructure by checking service status across specified hosts.

Instructions

Check the status of an Ansible-managed service deployment

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
service_nameYesName of the service to check
hostnameYesHostname or IP address of the device
usernameNoSSH username (use 'mcp_admin' for passwordless access after setup)mcp_admin
passwordNoSSH password (not needed for mcp_admin after setup)
portNoSSH port (default: 22)

Implementation Reference

  • Main MCP tool handler function that creates a ServiceInstaller instance and calls check_ansible_service method with provided arguments, returning the result as formatted JSON.
    async def handle_check_ansible_service(arguments: dict[str, Any]) -> dict[str, Any]:
        """Handle check_ansible_service tool."""
        installer = ServiceInstaller()
        ansible_result = await installer.check_ansible_service(**arguments)
        return {"content": [{"type": "text", "text": json.dumps(ansible_result, indent=2)}]}
  • Actual implementation of check_ansible_service that checks if an Ansible-managed service deployment exists by verifying the Ansible directory, playbook file, checking if Ansible is installed, and returning detailed status information.
    async def check_ansible_service(
        self,
        service_name: str,
        hostname: str,
        username: str = "mcp_admin",
        password: str | None = None,
    ) -> dict[str, Any]:
        """Check the status of an Ansible-managed service."""
        ansible_dir = f"/opt/ansible/{service_name}"
    
        # Check if Ansible directory exists
        dir_check = await ssh_execute_command(
            hostname=hostname,
            username=username,
            password=password,
            command=f"test -d {ansible_dir}",
        )
    
        dir_data = json.loads(dir_check)
        if dir_data.get("exit_code") != 0:
            return {
                "status": "not_found",
                "service": service_name,
                "error": f"Ansible deployment not found: {ansible_dir}",
            }
    
        # Check playbook exists
        playbook_path = f"{ansible_dir}/playbooks/{service_name}.yml"
        playbook_check = await ssh_execute_command(
            hostname=hostname,
            username=username,
            password=password,
            command=f"test -f {playbook_path}",
        )
    
        playbook_data = json.loads(playbook_check)
        if playbook_data.get("exit_code") != 0:
            return {
                "status": "error",
                "service": service_name,
                "error": f"Playbook not found: {playbook_path}",
            }
    
        # Get file information
        info_result = await ssh_execute_command(
            hostname=hostname,
            username=username,
            password=password,
            command=f"ls -la {ansible_dir}/playbooks/{service_name}.yml {ansible_dir}/inventory/hosts",
        )
    
        info_data = json.loads(info_result)
    
        # Check if Ansible is installed
        ansible_check = await ssh_execute_command(
            hostname=hostname,
            username=username,
            password=password,
            command="ansible-playbook --version",
        )
    
        ansible_data = json.loads(ansible_check)
        ansible_installed = ansible_data.get("exit_code") == 0
    
        return {
            "status": "deployed",
            "service": service_name,
            "ansible_dir": ansible_dir,
            "playbook_path": playbook_path,
            "ansible_installed": ansible_installed,
            "ansible_version": ansible_data.get("output", "").split("\n")[0] if ansible_installed else None,
            "files_info": info_data.get("output", ""),
        }
  • Tool schema definition for check_ansible_service including description and inputSchema with required parameters (service_name, hostname) and optional parameters (username, password, port) with defaults.
    "check_ansible_service": {
        "description": "Check the status of an Ansible-managed service deployment",
        "inputSchema": {
            "type": "object",
            "properties": {
                "service_name": {
                    "type": "string",
                    "description": "Name of the service to check",
                },
                "hostname": {
                    "type": "string",
                    "description": "Hostname or IP address of the device",
                },
                "username": {
                    "type": "string",
                    "description": "SSH username (use 'mcp_admin' for passwordless access after setup)",
                    "default": "mcp_admin",
                },
                "password": {
                    "type": "string",
                    "description": "SSH password (not needed for mcp_admin after setup)",
                },
                "port": {
                    "type": "integer",
                    "description": "SSH port (default: 22)",
                    "default": 22,
                },
            },
            "required": ["service_name", "hostname"],
        },
    },
  • Tool registration mapping check_ansible_service to its handler function in the tools dictionary.
    "check_ansible_service": handle_check_ansible_service,
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool checks status but doesn't explain what 'status' entails (e.g., running/stopped, deployment success/failure), how it performs the check (e.g., via SSH, Ansible modules), or any side effects, rate limits, or error handling. This is inadequate for a tool with authentication parameters and no output schema.

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

Conciseness5/5

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

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It's front-loaded with the core action and resource, making it easy to parse quickly. Every word earns its place in conveying essential information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (5 parameters including authentication, no annotations, no output schema), the description is insufficient. It doesn't explain what the tool returns, how it interacts with Ansible, or behavioral aspects like error conditions. For a tool that likely involves SSH access and service monitoring, more context is needed to guide effective use.

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

Parameters3/5

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

Schema description coverage is 100%, providing clear documentation for all 5 parameters. The description doesn't add any additional meaning beyond the schema, such as explaining relationships between parameters or usage examples. With high schema coverage, a baseline score of 3 is appropriate as the schema handles parameter semantics adequately.

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's purpose as 'Check the status of an Ansible-managed service deployment', which includes a specific verb ('Check') and resource ('Ansible-managed service deployment'). It distinguishes from siblings like 'get_service_status' or 'get_service_info' by specifying Ansible-managed services, though it doesn't explicitly contrast with them.

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 provides no guidance on when to use this tool versus alternatives. With siblings like 'get_service_status' and 'get_service_info', there's no indication of how this tool differs in context or applicability, leaving the agent to infer usage based on the name and description alone.

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/washyu/mcp_python_server'

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