splunk mcp
A FastMCP-based tool for interacting with Splunk Enterprise/Cloud through natural language. This tool provides a set of capabilities for searching Splunk data, managing KV stores, and accessing Splunk resources
A FastMCP-based tool for interacting with Splunk Enterprise/Cloud through natural language. This tool provides a set of capabilities for searching Splunk data, managing KV stores, and accessing Splunk resources
A FastMCP-based tool for interacting with Splunk Enterprise/Cloud through natural language. This tool provides a set of capabilities for searching Splunk data, managing KV stores, and accessing Splunk resources through an intuitive interface.
The tool operates in three modes:
Access via /sse
endpoint
API Mode
/api/v1
endpoint prefixStart with python splunk_mcp.py api
STDIO Mode
python splunk_mcp.py stdio
The following tools are available via the MCP interface:
When running in SSE mode, the following endpoints are available:
Provides protocol and capability information
/sse/messages: The main SSE stream endpoint
Sends properly formatted SSE events
/sse/health: Health check endpoint for SSE mode
The MCP implementation includes consistent error handling:
All error responses include a detailed message explaining the error.
Clone the repository:
git clone <repository-url>
cd splunk-mcp
Install dependencies using Poetry:
poetry install
Copy the example environment file and configure your settings:
cp .env.example .env
Update the .env
file with your Splunk credentials:
SPLUNK_HOST=your_splunk_host
SPLUNK_PORT=8089
SPLUNK_USERNAME=your_username
SPLUNK_PASSWORD=your_password
SPLUNK_SCHEME=https
VERIFY_SSL=true
FASTMCP_LOG_LEVEL=INFO
Pull the latest image:
docker pull livehybrid/splunk-mcp:latest
Create your .env
file as above or use environment variables directly.
Run using Docker Compose:
docker-compose up -d
Or using Docker directly:
docker run -i
--env-file .env
livehybrid/splunk-mcp
The tool can run in three modes:
SSE mode (default for MCP clients):
# Start in SSE mode (default)
poetry run python splunk_mcp.py
# or explicitly:
poetry run python splunk_mcp.py sse
# Use uvicorn directly:
SERVER_MODE=api poetry run uvicorn splunk_mcp:app --host 0.0.0.0 --port 8000 --reload
STDIO mode:
poetry run python splunk_mcp.py stdio
The project supports both the new docker compose
(V2) and legacy docker-compose
(V1) commands. The examples below use V2 syntax, but both are supported.
SSE Mode (Default):
docker compose up -d mcp
API Mode:
docker compose run --rm mcp python splunk_mcp.py api
STDIO Mode:
docker compose run -i --rm mcp python splunk_mcp.py stdio
The project includes a dedicated test environment in Docker:
Run all tests:
./run_tests.sh --docker
Run specific test components:
# Run only the MCP server
docker compose up -d mcp
# Run only the test container
docker compose up test
# Run both with test results
docker compose up --abort-on-container-exit
Test results will be available in the ./test-results
directory.
Building Images:
# Build both images
docker compose build
# Build specific service
docker compose build mcp
docker compose build test
Viewing Logs:
# View all logs
docker compose logs
# Follow specific service logs
docker compose logs -f mcp
Debugging:
# Run with debug mode
DEBUG=true docker compose up mcp
# Access container shell
docker compose exec mcp /bin/bash
Note: If you're using Docker Compose V1, replace docker compose
with docker-compose
in the above commands.
.env
files.env.example
as a templateConsider using Docker secrets for production
SSL Verification:
VERIFY_SSL=true
recommended for productionConfigure through environment variables
Port Exposure:
Configure the following environment variables:
- SPLUNK_HOST
: Your Splunk host address
- SPLUNK_PORT
: Splunk management port (default: 8089)
- SPLUNK_USERNAME
: Your Splunk username
- SPLUNK_PASSWORD
: Your Splunk password
- SPLUNK_SCHEME
: Connection scheme (default: https)
- VERIFY_SSL
: Enable/disable SSL verification (default: true)
- FASTMCP_LOG_LEVEL
: Logging level (default: INFO)
- SERVER_MODE
: Server mode (sse, api, stdio) when using uvicorn
The tool provides flexible SSL verification options:
VERIFY_SSL=true
Recommended for production environments
Relaxed Mode:
VERIFY_SSL=false
The project includes comprehensive test coverage using pytest and end-to-end testing with a custom MCP client:
Basic test execution:
poetry run pytest
With coverage reporting:
poetry run pytest --cov=splunk_mcp
With verbose output:
poetry run pytest -v
The project includes a custom MCP client test script that connects to the live SSE endpoint and tests all tools:
# Test all tools
python test_endpoints.py
# Test specific tools
python test_endpoints.py health_check list_indexes
# List all available tools
python test_endpoints.py --list
This script acts as an MCP client by:
1. Connecting to the /sse
endpoint to get the messages URL
2. Sending tool invocations to the messages endpoint
3. Processing the SSE events to extract tool results
4. Validating the results against expected formats
This provides real-world testing of the SSE interface as it would be used by an actual MCP client.
The project uses three complementary testing approaches:
tests/test_api.py
):mcp.call_tool()
Note: This file should ideally be renamed to test_mcp.py
to better reflect its purpose
Direct Function Tests (tests/test_endpoints_pytest.py
):
Uses parameterized testing for efficient test coverage
End-to-End MCP Client Tests (test_endpoints.py
):
Tests tools with real parameters against the live server
Configuration Tests (tests/test_config.py
):
The tests support: - Async testing with pytest-asyncio - Coverage reporting with pytest-cov - Mocking with pytest-mock - Parameterized testing - Connection timeout testing
Verify network routing and firewalls
SSL Issues:
VERIFY_SSL=false
Verify hostname matches certificate
Authentication Issues:
Ensure account is not locked
Debugging:
FASTMCP_LOG_LEVEL=DEBUG
for detailed logsReview SSL configuration messages
SSE Connection Issues:
/sse
You can integrate Splunk MCP with Claude Desktop by configuring it to use either SSE or STDIO mode. Add the following configuration to your claude_desktop_config.json
:
{
"splunk": {
"command": "poetry",
"env": {
"SPLUNK_HOST": "your_splunk_host",
"SPLUNK_PORT": "8089",
"SPLUNK_USERNAME": "your_username",
"SPLUNK_PASSWORD": "your_password",
"SPLUNK_SCHEME": "https",
"VERIFY_SSL": "false"
},
"args": ["--directory", "/path/to/splunk-mcp", "run", "splunk_mcp.py", "stdio"]
}
}
{
"splunk": {
"command": "poetry",
"env": {
"SPLUNK_HOST": "your_splunk_host",
"SPLUNK_PORT": "8089",
"SPLUNK_USERNAME": "your_username",
"SPLUNK_PASSWORD": "your_password",
"SPLUNK_SCHEME": "https",
"VERIFY_SSL": "false",
"FASTMCP_PORT": "8001",
"DEBUG": "true"
},
"args": ["--directory", "/path/to/splunk-mcp", "run", "splunk_mcp.py", "sse"]
}
}
Once configured, you can use natural language to interact with Splunk through Claude. Examples:
List available indexes:
What Splunk indexes are available?
Search Splunk data:
Search Splunk for failed login attempts in the last 24 hours
Get system health:
Check the health of the Splunk system
Manage KV stores:
List all KV store collections
The MCP tools will be automatically available to Claude, allowing it to execute these operations through natural language commands.
[Your License Here]