Model Context Protocol (MCP) server for Kibana Security - manage alerts, rules, exceptions, saved objects, and endpoints via AI assistants.
Option A: Using Environment Variables (Recommended)
First, set your credentials:
export KIBANA_URL="https://your-kibana.example.com:5601"
# Option 1: API Key (recommended)
export KIBANA_API_KEY="your_base64_api_key"
# Option 2: Username/Password
# export KIBANA_USERNAME="your_username"
# export KIBANA_PASSWORD="your_password"Then add to your MCP config:
{
"mcpServers": {
"kibana-mcp": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"--network",
"host",
"-e",
"KIBANA_URL",
"-e",
"KIBANA_API_KEY",
"ghcr.io/jamesagarside/kibana-mcp:latest"
]
}
}
}For username/password, use:
{
"mcpServers": {
"kibana-mcp": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"--network",
"host",
"-e",
"KIBANA_URL",
"-e",
"KIBANA_USERNAME",
"-e",
"KIBANA_PASSWORD",
"ghcr.io/jamesagarside/kibana-mcp:latest"
]
}
}
}Option B: Direct Credentials (Easier for Claude Desktop)
Using API Key:
{
"mcpServers": {
"kibana-mcp": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"--network",
"host",
"-e",
"KIBANA_URL=https://your-kibana.example.com:5601",
"-e",
"KIBANA_API_KEY=your_base64_api_key",
"ghcr.io/jamesagarside/kibana-mcp:latest"
]
}
}
}Using Username/Password:
{
"mcpServers": {
"kibana-mcp": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"--network",
"host",
"-e",
"KIBANA_URL=https://your-kibana.example.com:5601",
"-e",
"KIBANA_USERNAME=your_username",
"-e",
"KIBANA_PASSWORD=your_password",
"ghcr.io/jamesagarside/kibana-mcp:latest"
]
}
}
}Note: Option B is less secure but more convenient for tools like Claude Desktop where environment variables are harder to manage.
If you'd rather not use the public image you can build this MCP server yourself.
git clone https://github.com/jamesagarside/kibana-mcp.git
cd kibana-mcp
make buildThis MCP server supports two transport modes:
- STDIO Mode (default) - Standard MCP transport for use with MCP clients
- SSE Mode - HTTP Server-Sent Events endpoint for web applications
The server runs in STDIO mode by default, suitable for MCP clients like Claude Desktop:
# Using Docker
docker run -i --rm -e KIBANA_URL -e KIBANA_API_KEY ghcr.io/jamesagarside/kibana-mcp:latest
# Using Python
python -m kibana_mcpTo run as an SSE server, set the MCP_TRANSPORT environment variable:
# Set environment variables
export MCP_TRANSPORT="sse"
export MCP_SSE_HOST="127.0.0.1" # Optional, defaults to 127.0.0.1
export MCP_SSE_PORT="8000" # Optional, defaults to 8000
# Run the server
python -m kibana_mcpOr use the convenience script:
# Using the convenience script
./run_sse_server.py
# Or with custom host/port
MCP_SSE_HOST="0.0.0.0" MCP_SSE_PORT="9000" ./run_sse_server.pyThe SSE endpoint will be available at http://127.0.0.1:8000/sse (or your configured host/port).
# Run SSE server in Docker
docker run -p 8000:8000 \
-e MCP_TRANSPORT="sse" \
-e MCP_SSE_HOST="0.0.0.0" \
-e KIBANA_URL \
-e KIBANA_API_KEY \
ghcr.io/jamesagarside/kibana-mcp:latestThen access the SSE endpoint at http://localhost:8000/sse.
To test that the SSE server is working correctly, you can use the provided test scripts:
# Quick test - verifies server starts and is listening
make test-sse
# Or run directly
./test_minimal.py
# Demonstration test showing SSE streaming
./test_sse_working.pyThe minimal test will:
- Start the MCP server in SSE mode
- Verify it's listening on the correct port
- Confirm the SSE endpoint is accessible
- Clean up the server process
get_alerts- Fetch security alertstag_alert- Add tags to alertsadjust_alert_status- Change alert status (open/acknowledged/closed)
find_rules- Search detection rulesget_rule- Retrieve details of a specific ruledelete_rule- Delete a detection ruleupdate_rule_status- Enable or disable a ruleget_prepackaged_rules_status- Check status of Elastic's prepackaged rulesinstall_prepackaged_rules- Install/update Elastic's prepackaged rules
get_rule_exceptions- Get rule exception itemsadd_rule_exception_items- Add exceptions to rulescreate_exception_list- Create new exception listsassociate_shared_exception_list- Link exception lists to rules
find_cases- Search for cases based on various criteriaget_case- Get detailed information about a specific casecreate_case- Create a new caseupdate_case- Update an existing casedelete_cases- Delete one or more casesadd_case_comment- Add a comment or alert to a caseget_case_comments- Get comments and alerts for a specific caseget_case_alerts- Get all alerts attached to a specific caseget_cases_by_alert- Get all cases that contain a specific alertget_case_configuration- Get case configuration settingsget_case_tags- Get all case tags
find_objects- Search for saved objects (dashboards, visualizations, etc.)get_object- Retrieve details of a specific saved objectbulk_get_objects- Get multiple saved objects in a single requestcreate_object- Create a new saved objectupdate_object- Update an existing saved objectdelete_object- Delete a saved objectexport_objects- Export saved objects to NDJSON formatimport_objects- Import saved objects from NDJSON format
isolate_endpoint- Isolate one or more endpoints from the networkunisolate_endpoint- Release one or more endpoints from isolationrun_command_on_endpoint- Run a shell command on one or more endpointsget_response_actions- Get a list of response actions from endpointsget_response_action_details- Get details of a specific response actionget_response_action_status- Get status of response actionskill_process- Terminate a running process on an endpointsuspend_process- Suspend a running process on an endpointscan_endpoint- Scan a file or directory on an endpoint for malwareget_file_info- Get information for a file retrieved by a response actiondownload_file- Download a file from an endpoint
If you prefer not to use the Makefile, you can also run the commands manually:
# Install dependencies
uv sync
# Set environment variables (see above)
# Run locally
uv run kibana-mcpThe project is organized into the following structure:
src/kibana_mcp/
├── tools/
│ ├── alerts/ # Tools for managing alerts
│ ├── rules/ # Tools for managing rules
│ ├── exceptions/ # Tools for managing exception lists
│ ├── endpoint/ # Tools for endpoint management and response actions
│ ├── saved_objects/ # Tools for managing saved objects (dashboards, visualizations, etc.)
│ └── utils/ # Utility functions
├── models/ # Pydantic models
├── server.py # MCP server implementation
├── prompts.py # Custom prompts
└── resources.py # Resource handlers
make testThe recommended way to run tests is using the Makefile:
# Run all tests with coverage
make test
# Run pytest without coverage
make run-pytestIf you need to test specific modules or test files, you can use pytest directly after activating the virtual environment:
# Activate the virtual environment created by the Makefile
source .venv/bin/activate
# Run tests for a specific category
PYTHONPATH=./src pytest -xvs testing/tools/alerts/test_alert_tools.py
PYTHONPATH=./src pytest -xvs testing/tools/rules/test_rule_tools.py
PYTHONPATH=./src pytest -xvs testing/tools/exceptions/test_exception_tools.py
PYTHONPATH=./src pytest -xvs testing/tools/endpoint/test_endpoint_tools.py
PYTHONPATH=./src pytest -xvs testing/tools/saved_objects/test_saved_objects.pyThe Makefile provides commands to help you set up a complete test environment with Elastic Stack using Docker. This environment will be bootstrapped with sample data for testing.
# Install required tools
make install-elastic-package
# Start the complete test environment (Elasticsearch, Kibana, Fleet Server and Agent)
make start-test-env
# Access Kibana at http://localhost:5601
# Username: elastic
# Password: elastic
# When finished, stop the test environment
make stop-test-envOnce your test environment is running, you can test the MCP server with any MCP-compatible LLM client (like Claude Desktop, Cursor, etc.).
After setup, you can verify the connection by:
- Going to Kibana at https://localhost:5601 and login using the username:
elasticand password:changeme - Navigate to Management > Fleet
- Verify the Fleet Server and Agent are connected and healthy
{
"mcpServers": {
"kibana-mcp": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"--network",
"host",
"-e",
"KIBANA_URL=https://localhost:5601",
"-e",
"KIBANA_USERNAME=elastic",
"-e",
"KIBANA_PASSWORD=changeme",
"kibana-mcp"
]
}
}
}The project includes a comprehensive Makefile to help with common development tasks. You can view all available commands with:
make helpThe Makefile includes the following main categories of commands:
# Run the server locally in development mode (sets up local Kibana connection)
make dev
# Build the Docker image
make build# Run all tests (pytest and coverage)
make test
# Run pytest only
make run-pytest
# Run tests with coverage reporting
make run-coverage
# Test SSE server locally
make test-sse# Install the elastic-package tool
make install-elastic-package
# Start the complete test environment
make start-test-env
# Start only the Elastic Stack containers
make start-elastic-stack
# Configure the test environment
make configure-test-env
# Stop the test environment
make stop-test-envThe server uses a completely stateless architecture, making it ideal for cloud deployments like Google Cloud Run and for integrating with automation tools like N8N.
- No Session State: Each request is self-contained, eliminating session loss concerns
- Scale to Zero: Minimize costs when idle (autoscaling.knative.dev/minScale: "0")
- High Concurrency: Support 1000+ concurrent requests
- Efficient Connection Pooling: Optimized for short-lived connections
A simple deployment script is provided:
# Set your GCP project ID and region
export PROJECT_ID="your-project-id"
export REGION="europe-west2"
# Run the deployment script
./deploy-cloud-run.shFor detailed information on the stateless architecture and optimizations for Cloud Run, see CLOUD_RUN_SESSION_FIXES.md.
For integrating with N8N automation workflows, refer to the N8N Integration Guide.
