Skip to main content
Glama
itshare4u

Agent Knowledge MCP

elasticsearch_status

Check Elasticsearch and Kibana container status with detailed configuration information to monitor system health.

Instructions

Check status of Elasticsearch and Kibana containers with detailed configuration information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler function for the 'elasticsearch_status' tool. It creates an ElasticsearchSetup instance, calls get_container_status(), and formats a comprehensive status report for Elasticsearch and Kibana Docker containers including existence, running status, URLs, configuration, and overall system readiness.
    @app.tool(
        description="Check status of Elasticsearch and Kibana containers with detailed configuration information",
        tags={"admin", "elasticsearch", "status", "docker", "monitoring"}
    )
    async def elasticsearch_status() -> str:
        """Check comprehensive status of Elasticsearch and Kibana Docker containers."""
        try:
            # Get config path and setup manager
            config_path = Path(__file__).parent / "config.json"
            setup_manager = ElasticsearchSetup(config_path)
    
            # Get detailed container status
            status = setup_manager.get_container_status()
    
            if "error" in status:
                return f"āŒ **Container Status Check Failed!**\n\n🚨 **Error:** {status['error']}\n\nšŸ’” **Troubleshooting:**\n   • Check if Docker is running\n   • Verify Docker daemon is accessible\n   • Ensure proper Docker permissions\n   • Try restarting Docker service"
    
            # Build comprehensive status message
            message = "šŸ“Š **Elasticsearch & Kibana Container Status Report**\n\n"
    
            # Elasticsearch detailed status
            es_status = status["elasticsearch"]
            message += f"šŸ” **Elasticsearch Container** (`{es_status['container_name']}`):\n"
            message += f"   šŸ“¦ Container Exists: {'āœ… Yes' if es_status['exists'] else 'āŒ No'}\n"
            message += f"   šŸš€ Container Running: {'āœ… Yes' if es_status['running'] else 'āŒ No'}\n"
    
            if es_status['running']:
                message += f"   🌐 Access URL: http://localhost:9200\n"
                message += f"   šŸ’š Status: Ready for connections\n"
            elif es_status['exists']:
                message += f"   āš ļø Status: Container exists but not running\n"
                message += f"   šŸ’” Action: Start container or use setup_elasticsearch\n"
            else:
                message += f"   šŸ”§ Status: Container not found\n"
                message += f"   šŸ’” Action: Run setup_elasticsearch to create\n"
    
            message += f"\n"
    
            # Kibana detailed status
            kibana_status = status["kibana"]
            message += f"šŸ“Š **Kibana Container** (`{kibana_status['container_name']}`):\n"
            message += f"   šŸ“¦ Container Exists: {'āœ… Yes' if kibana_status['exists'] else 'āŒ No'}\n"
            message += f"   šŸš€ Container Running: {'āœ… Yes' if kibana_status['running'] else 'āŒ No'}\n"
    
            if kibana_status['running']:
                message += f"   🌐 Access URL: http://localhost:5601\n"
                message += f"   šŸ’š Status: Dashboard available\n"
            elif kibana_status['exists']:
                message += f"   āš ļø Status: Container exists but not running\n"
                message += f"   šŸ’” Action: Start container or use setup_elasticsearch\n"
            else:
                message += f"   šŸ”§ Status: Container not found\n"
                message += f"   šŸ’” Action: Run setup_elasticsearch with include_kibana=true\n"
    
            # Current configuration summary
            config = load_config()
            message += f"\nāš™ļø **Current Configuration Settings:**\n"
            message += f"   šŸ  Host: {config['elasticsearch']['host']}\n"
            message += f"   šŸ”Œ Port: {config['elasticsearch']['port']}\n"
            message += f"   šŸ“ Full URL: http://{config['elasticsearch']['host']}:{config['elasticsearch']['port']}\n"
    
            # Overall system status assessment
            es_ready = es_status['running']
            kibana_ready = kibana_status['running']
    
            message += f"\nšŸŽÆ **Overall System Status:**\n"
            if es_ready and kibana_ready:
                message += f"   āœ… **Fully Operational** - Both Elasticsearch and Kibana running\n"
                message += f"   šŸš€ **Next Steps:** Start indexing documents and using search\n"
            elif es_ready and not kibana_ready:
                message += f"   🟔 **Partially Ready** - Elasticsearch running, Kibana stopped\n"
                message += f"   šŸ’” **Suggestion:** Elasticsearch is functional, Kibana optional for visualization\n"
            elif not es_ready and kibana_ready:
                message += f"   šŸ”“ **Incomplete Setup** - Kibana running but Elasticsearch stopped\n"
                message += f"   āš ļø **Action Required:** Start Elasticsearch for system to function\n"
            else:
                message += f"   šŸ”“ **System Down** - Both services stopped\n"
                message += f"   šŸ› ļø **Action Required:** Run setup_elasticsearch to start services\n"
    
            return message
    
        except ImportError as e:
            return f"āŒ Module Error: Missing Elasticsearch setup dependency\nšŸ” Details: {str(e)}\nšŸ’” Ensure ElasticsearchSetup module is properly installed"
        except FileNotFoundError as e:
            return f"āŒ Configuration Error: Required config file not found\nšŸ” Details: {str(e)}\nšŸ’” Check that config.json exists in the source directory"
        except Exception as e:
            return _format_admin_error(e, "check Elasticsearch status", "Docker container status monitoring")
  • Helper method in ElasticsearchSetup class that returns the status dictionary for both Elasticsearch and Kibana containers (exists, running, container_name), used directly by the elasticsearch_status handler.
    def get_container_status(self) -> Dict[str, Any]:
        """Get status of Elasticsearch and Kibana containers."""
        try:
            client = self._get_docker_client()
            
            status = {
                "elasticsearch": {
                    "exists": self._container_exists(self.container_name),
                    "running": self._is_container_running(self.container_name),
                    "container_name": self.container_name
                },
                "kibana": {
                    "exists": self._container_exists(self.kibana_container_name),
                    "running": self._is_container_running(self.kibana_container_name),
                    "container_name": self.kibana_container_name
                }
            }
            
            return status
            
        except Exception as e:
            return {"error": str(e)}
  • The @app.tool decorator registers the elasticsearch_status function on the admin FastMCP app, which is later mounted to the main server.
    @app.tool(
        description="Check status of Elasticsearch and Kibana containers with detailed configuration information",
        tags={"admin", "elasticsearch", "status", "docker", "monitoring"}
    )
  • The ElasticsearchSetup class provides container management utilities including get_container_status, used by the tool handler.
    class ElasticsearchSetup:
        """Manage Elasticsearch Docker container setup."""
        
        def __init__(self, config_path: Path):
            self.config_path = config_path
            self.docker_client = None
            self.container_name = "elasticsearch-mcp"
            self.kibana_container_name = "kibana-mcp"
            
        def _get_docker_client(self):
            """Get Docker client."""
            if self.docker_client is None:
                try:
                    self.docker_client = docker.from_env()
                    # Test connection
                    self.docker_client.ping()
                except DockerException as e:
                    raise ConnectionError(f"Cannot connect to Docker. Is Docker running? Error: {e}")
            return self.docker_client
        
        def _is_elasticsearch_running(self, host: str, port: int) -> bool:
            """Check if Elasticsearch is running at the given host:port."""
            try:
                response = requests.get(f"http://{host}:{port}", timeout=5)
                return response.status_code == 200
            except:
                return False
        
        def _wait_for_elasticsearch(self, host: str, port: int, timeout: int = 60) -> bool:
            """Wait for Elasticsearch to be ready."""
            print(f"Waiting for Elasticsearch at {host}:{port}...")
            start_time = time.time()
            
            while time.time() - start_time < timeout:
                if self._is_elasticsearch_running(host, port):
                    print("āœ… Elasticsearch is ready!")
                    return True
                time.sleep(2)
                print("ā³ Still waiting...")
            
            print("āŒ Timeout waiting for Elasticsearch")
            return False
        
        def _container_exists(self, container_name: str) -> bool:
            """Check if container exists."""
            try:
                client = self._get_docker_client()
                client.containers.get(container_name)
                return True
            except NotFound:
                return False
        
        def _is_container_running(self, container_name: str) -> bool:
            """Check if container is running."""
            try:
                client = self._get_docker_client()
                container = client.containers.get(container_name)
                return container.status == 'running'
            except NotFound:
                return False
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 and provides detailed configuration information, but doesn't clarify if this is a read-only operation, what permissions are needed, whether it affects system state, or how it handles errors. For a status-checking tool with zero annotation coverage, this leaves significant behavioral gaps.

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 clearly conveys the tool's purpose without unnecessary words. It is front-loaded with the core action and resources, making it easy to parse. Every part of the sentence earns its place by specifying what is checked and what information is provided.

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 the tool's complexity (simple status check with 0 parameters), the description is adequate but incomplete. It lacks behavioral details (e.g., read-only nature, error handling) and usage context, which are important since no annotations are provided. However, the presence of an output schema means the description doesn't need to explain return values, keeping it from being lower.

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 tool has 0 parameters, and the input schema has 100% description coverage (though empty). The description doesn't need to add parameter details, and it appropriately doesn't mention any. Since there are no parameters, the baseline is high, but it doesn't reach 5 as it could have noted the lack of parameters explicitly, though this isn't required.

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: 'Check status of Elasticsearch and Kibana containers with detailed configuration information.' It specifies the verb ('check status'), resources ('Elasticsearch and Kibana containers'), and scope ('detailed configuration information'). However, it doesn't explicitly differentiate from sibling tools like 'server_status' or 'get_config', which might have overlapping functionality, so it doesn't reach the highest score.

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. It doesn't mention prerequisites, timing, or comparisons to sibling tools such as 'server_status' or 'get_config', leaving the agent to infer usage context. This lack of explicit direction reduces its effectiveness in tool selection.

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/itshare4u/AgentKnowledgeMCP'

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