splunk-mcp-readonly
Provides read-only integration with Splunk Enterprise and Splunk Cloud, enabling searches via SPL, SPL validation, index discovery, saved search and alert listing, server health and info, and Enterprise Security notable event retrieval through MCP tools.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@splunk-mcp-readonly search the main index for failed logins in the last 24 hours"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
splunk-mcp-readonly
A standalone, read-only Model Context Protocol server that lets an LLM assistant (Claude Desktop, Claude Code, or any MCP client) query Splunk Enterprise and Splunk Cloud with nothing but a token. It exposes search, index, saved search, health and Enterprise Security notable tools behind a guard that refuses anything that could write, delete, export or execute, and writes an audit line for every call.
It is read-only by design: an assistant that can explore your data is useful, an assistant that can run | delete or | outputlookup on a typo or a prompt injection is an incident. Safety is enforced twice, by the server and by the Splunk role behind the token.
When to use this, and when to use Splunk's own server
Splunk ships an official Splunk MCP Server as a Splunk app: 25 tools including fired alerts, throttles, KV store, knowledge objects and SPL generation through Splunk AI Assistant, with a configurable allow-list of SPL commands. If you can install apps on the Splunk instance and want that breadth, use it.
This project exists for the other cases:
You cannot install anything on the Splunk you are querying. Consultants, auditors and analysts often get a token and nothing else. This server runs on your side (laptop, jump host, container) and only needs the management port.
You want the smallest possible surface. Seven tools, read-only, about 800 lines of Python you can review in an hour before pointing an LLM at production data.
You need the controls written down. Index allow-list, forced row caps, default time window, command blocklist and a JSON Lines audit log of every call the model makes, so the SOC can answer "what did the assistant run last Tuesday".
You are evaluating. It is a reference implementation of guardrails for LLM-driven SPL; the guard module is self-contained and reusable.
Related MCP server: sn-mcp
Tools
Tool | Purpose | Limits |
| Run a read-only SPL search | ` |
| Validate SPL against the guard without running it | No Splunk call |
| Indexes with event count, size and retention | All indexes visible to the role |
| Saved searches and alerts with SPL and cron |
|
| Version, server name, product type, OS, CPU | - |
| splunkd health status per feature | - |
| Recent Enterprise Security notables | Needs Splunk ES; |
Resource: splunk://indexes. Prompts: triage_notable(rule_name) and coverage_question().
Safety model
Command blocklist. Any pipeline stage, including inside subsearches, that starts with
delete, outputlookup, outputcsv, outputtext, collect, mcollect, meventcollect, sendemail, sendalert, script, runshellscript, run, dbxquery, dbxoutput, crawl, input, savedsearch, loadjobis refused, case-insensitively and regardless of spacing.mapis refused, and| restwithmethod=post|delete|putis refused (plain GET is allowed). Pipes inside quoted strings, such asrex "a|b", are not mistaken for commands.Forced
head. Every search ends with| head Nunless it already ends withheadortailof N or fewer rows.Default time range.
-24htonowunless the caller says otherwise.Index allow-list. With
SPLUNK_ALLOWED_INDEXES=main,wineventlog, everyindex=andindex IN (...)reference must be on the list, and a search without an explicit index is refused.Audit log. With
SPLUNK_MCP_AUDIT_LOG=/var/log/splunk-mcp/audit.jsonl, every tool call appends one JSON line: timestamp, tool, the arguments the model passed, the SPL actually run, row count or error, and duration. Credentials never reach the log. Ship the file to Splunk itself if you want the assistant's activity next to everything else.No secrets in output. Credentials are never logged or returned, including in error messages.
Least-privilege token (the real control). The guard is defence in depth. Create a dedicated role with only the capabilities
search,list_indexesandrest_properties_get, and noedit_*capabilities. Restrict it to the indexes you want to expose. Then, in Splunk Web, go to Settings -> Tokens, create a token for a user holding that role, and set a reasonable expiry.
Install and configure
Environment variables:
Variable | Default | Meaning |
| required | Management URL, e.g. |
| - | Bearer token (preferred) |
| - | Basic auth, used when no token is set |
|
| Verify the TLS certificate |
|
| Default start of the time range |
|
| Row cap per search (hard cap 1000) |
|
| HTTP timeout in seconds |
| unset | Comma list; searches may only reference these |
| unset | Path of a JSON Lines file; one line per tool call when set |
Run it directly from GitHub with uv:
uvx --from git+https://github.com/lfjuarez/splunk-mcp-readonly splunk-mcpOr with pipx, or from source:
pipx install git+https://github.com/lfjuarez/splunk-mcp-readonly
git clone https://github.com/lfjuarez/splunk-mcp-readonly
cd splunk-mcp-readonly
uv venv .venv && uv pip install -e ".[dev]"
.venv/bin/pytest -qClaude Desktop
Add to claude_desktop_config.json (see examples/claude_desktop_config.json):
{
"mcpServers": {
"splunk": {
"command": "uvx",
"args": ["--from", "git+https://github.com/lfjuarez/splunk-mcp-readonly", "splunk-mcp"],
"env": {
"SPLUNK_URL": "https://splunk.example.com:8089",
"SPLUNK_TOKEN": "<token>",
"SPLUNK_VERIFY_TLS": "true"
}
}
}
}Claude Code
claude mcp add splunk \
-e SPLUNK_URL=https://splunk.example.com:8089 \
-e SPLUNK_TOKEN=your-read-only-token \
-- uvx --from git+https://github.com/lfjuarez/splunk-mcp-readonly splunk-mcpMore options, including a project .mcp.json, in examples/claude-code.md.
Example session
User: Which hosts had failed logons followed by a success in the last 6 hours?
Assistant calls
explain_spl:index=wineventlog (EventCode=4625 OR EventCode=4624) | sort 0 _time | streamstats current=f last(EventCode) as prev by host, user | where EventCode=4624 AND prev=4625 | stats count as recoveries, values(user) as users by host | sort - recoveriesResult:
{"ok": true, "normalised": "search index=wineventlog ..."}Assistant calls
searchwith the same SPL,earliest="-6h",max_rows=20. Result: 3 rows, e.g.{"host": "WS-114", "recoveries": "7", "users": ["svc_backup", "jdoe"]}.Assistant: Three hosts show a failed logon immediately followed by a success. WS-114 stands out with 7 occurrences across two accounts, including a service account. Want me to pull the source IPs for those events?
Enterprise Security notables
The notables tool runs the ES `notable` macro and shows rule name, severity, urgency, status, owner, src, dest, user and risk score. Without Splunk Enterprise Security the macro does not exist and the tool returns an error message instead of data. The triage_notable prompt turns a rule name into a short investigation checklist that uses the other tools.
Limitations
One-shot searches only: the request blocks until Splunk finishes, bounded by
SPLUNK_TIMEOUT_S. There is no job polling yet, so very long searches time out.At most 1000 rows per search.
No write operations, ever: no saved search creation, no lookups updates, no alert management.
The guard is a text-level check, not a full SPL parser. Use a least-privilege role as the authoritative control.
Roadmap
Job polling for long-running searches
Splunk Cloud ACS support (index and token administration is out of scope; read-only discovery)
Metrics index tools (
mstats,mcataloghelpers)
Author
Leandro F. Juárez, built from field work on SIEM platforms. LinkedIn. MIT licensed.
Available Tools
7 toolsexplain_splA
Check an SPL query against the safety rules without running it.
Use this to validate a search before search. Nothing is sent to Splunk.
Args: spl: The SPL query to validate.
Returns {"ok": bool, "normalised": str | None, "reason": str | None}.
Inputs: spl (required). Returns: object
healthA
Return the splunkd health status and the status of each health feature.
Returns {"status": ..., "features": [{"name", "status", "reasons"}]}.
Inputs: no named parameters. Returns: object
list_indexesA
List the Splunk indexes with event count, size in MB and retention in days.
Use it to discover which indexes exist before writing a search. Takes no parameters.
Returns {"indexes": [...], "count": n}.
Inputs: no named parameters. Returns: object
list_saved_searchesA
List saved searches and alerts (name, SPL, cron schedule, app, owner).
Args: filter: Optional substring to match against the saved search name. limit: Maximum number of saved searches (default 50).
Returns {"saved_searches": [...], "count": n}.
Inputs: limit, filter. Returns: object
notablesA
List recent Enterprise Security notable events (requires Splunk ES).
Uses the ES notable macro, so it returns an error on a Splunk without Enterprise Security.
Args: hours: How many hours back to look (default 24). limit: Maximum notables to return (default 50, server cap applies).
Returns {"notables": [...], "count": n} with rule_name, severity, urgency, status,
owner, src, dest, user and risk_score.
Inputs: hours, limit. Returns: object
searchA
Run a read-only SPL search and return the result rows.
The search is validated first: commands that write, delete, export or execute (delete,
outputlookup, collect, sendemail, script, map, ...) are refused. A leading search is
added when missing and | head N is appended so results are always bounded.
Args:
spl: The SPL query, e.g. index=wineventlog EventCode=4625 | stats count by src_ip.
earliest: Start of the time range, Splunk syntax (default -24h).
latest: End of the time range (default now).
max_rows: Maximum rows to return (default 100, capped by the server, hard limit 1000).
Returns a dict with results (list of rows), count, spl (the SPL actually run),
and truncated when the row limit was reached. On failure returns {"error": ...}.
Inputs: spl (required), latest, earliest, max_rows. Returns: object
server_infoA
Return the Splunk version, server name, product type, OS and CPU architecture.
Inputs: no named parameters. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 7 tools
Each tool has a distinct role: search runs a query, explain_spl only validates one, list_indexes/list_saved_searches target different collections, and notables is ES-specific. The only mild overlap is server_info vs health, both being 'status' tools, though their descriptions separate version/OS metadata from splunkd health features.
There is a readable but mixed convention: list_indexes and list_saved_searches use verb_noun, explain_spl is verb_noun too, but search is a bare verb and health, notables, and server_info are bare nouns. No uniform pattern, though nothing is confusing or cryptic.
Seven tools is well-scoped for a read-only Splunk interface, with each tool earning its place across search, validation, discovery, and status. Nothing feels redundant or missing at the count level.
The surface covers the core read-only lifecycle: discover indexes, inspect saved searches, validate and run SPL, and check server/ES state. Minor gaps exist (e.g. no direct sourcetype/field discovery or saved-search detail/run endpoint), but agents can work around these with SPL queries such as metadata or fieldsummary.
Related MCP Connectors
Ask your AI assistant about your logs, traces, security events, robot runs and video. Read-only.
Query your org's data in natural language — read-only MCP access to SQL, NoSQL, files & warehouses.
Lets AI agents analyze API metrics, request logs, and traces, and manage apps and alerts.
Ask your Quickbase apps in plain language. Read-only by default; writes need human approval.
Related MCP Servers
- AlicenseBqualityBmaintenanceEnables AI agents to interact seamlessly with Splunk environments through 20+ tools for search, analytics, data discovery, administration, and health monitoring. Features AI-powered troubleshooting workflows and supports multiple Splunk instances with production-ready security.57282 PyPI27Apache 2.0
- FlicenseAqualityDmaintenanceEnables LLMs to securely query and optionally write to ServiceNow instances with strict allowlist/denylist safety controls.9-
- AlicenseNot gradedqualityDmaintenanceEnables LLM clients to safely inspect database schemas and run only approved read-only queries and stored procedures, with auditing.MIT
- AlicenseNot gradedqualityBmaintenanceEnforces security policies between AI assistants and Splunk by inspecting every search, mapping users to roles, and requiring human approval for write actions.1Apache 2.0