mcp-server-splunk 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mcp_server_splunk-0.1.0/.env.example +19 -0
- mcp_server_splunk-0.1.0/.gitignore +53 -0
- mcp_server_splunk-0.1.0/CLAUDE.md +129 -0
- mcp_server_splunk-0.1.0/LICENSE +15 -0
- mcp_server_splunk-0.1.0/PKG-INFO +185 -0
- mcp_server_splunk-0.1.0/README.md +159 -0
- mcp_server_splunk-0.1.0/pyproject.toml +50 -0
- mcp_server_splunk-0.1.0/requirements.txt +2 -0
- mcp_server_splunk-0.1.0/splunk_mcp_server.py +4797 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Splunk Connection Configuration
|
|
2
|
+
|
|
3
|
+
# Splunk server hostname or IP
|
|
4
|
+
SPLUNK_HOST=localhost
|
|
5
|
+
|
|
6
|
+
# Splunk management port (default: 8089)
|
|
7
|
+
SPLUNK_PORT=8089
|
|
8
|
+
|
|
9
|
+
# Connection scheme (http or https)
|
|
10
|
+
SPLUNK_SCHEME=https
|
|
11
|
+
|
|
12
|
+
# Authentication Method 1: Token-based (recommended)
|
|
13
|
+
# SPLUNK_TOKEN=your-splunk-token-here
|
|
14
|
+
|
|
15
|
+
# Authentication Method 2: Username/Password (if not using token)
|
|
16
|
+
# SPLUNK_USERNAME=your-username
|
|
17
|
+
# SPLUNK_PASSWORD=your-password
|
|
18
|
+
|
|
19
|
+
# Note: If SPLUNK_TOKEN is set, it will be used. Otherwise, username/password will be used.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
.Python
|
|
7
|
+
build/
|
|
8
|
+
develop-eggs/
|
|
9
|
+
dist/
|
|
10
|
+
downloads/
|
|
11
|
+
eggs/
|
|
12
|
+
.eggs/
|
|
13
|
+
lib/
|
|
14
|
+
lib64/
|
|
15
|
+
parts/
|
|
16
|
+
sdist/
|
|
17
|
+
var/
|
|
18
|
+
wheels/
|
|
19
|
+
*.egg-info/
|
|
20
|
+
.installed.cfg
|
|
21
|
+
*.egg
|
|
22
|
+
|
|
23
|
+
# Virtual environments
|
|
24
|
+
venv/
|
|
25
|
+
env/
|
|
26
|
+
ENV/
|
|
27
|
+
.venv
|
|
28
|
+
|
|
29
|
+
# Environment variables
|
|
30
|
+
.env
|
|
31
|
+
.env.local
|
|
32
|
+
|
|
33
|
+
# IDE
|
|
34
|
+
.vscode/
|
|
35
|
+
.idea/
|
|
36
|
+
*.swp
|
|
37
|
+
*.swo
|
|
38
|
+
*~
|
|
39
|
+
|
|
40
|
+
# OS
|
|
41
|
+
.DS_Store
|
|
42
|
+
Thumbs.db
|
|
43
|
+
|
|
44
|
+
# MCP
|
|
45
|
+
.mcp/
|
|
46
|
+
.mcp.json
|
|
47
|
+
|
|
48
|
+
# Claude Code
|
|
49
|
+
.claude/
|
|
50
|
+
|
|
51
|
+
# Test output
|
|
52
|
+
test_*.json
|
|
53
|
+
test_*.csv
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## Project Overview
|
|
6
|
+
|
|
7
|
+
This is a Model Context Protocol (MCP) server that provides 50+ tools for interacting with Splunk. It enables LLM applications like Claude to search, retrieve, and manage data in Splunk instances through a comprehensive REST API wrapper.
|
|
8
|
+
|
|
9
|
+
## Development Commands
|
|
10
|
+
|
|
11
|
+
### Setup and Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# Install dependencies
|
|
15
|
+
pip install -r requirements.txt
|
|
16
|
+
# or with uv (recommended)
|
|
17
|
+
uv pip install -r requirements.txt
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Running the MCP Server
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
# Development mode with MCP Inspector
|
|
24
|
+
uv run mcp dev splunk_mcp_server.py
|
|
25
|
+
|
|
26
|
+
# Direct execution
|
|
27
|
+
python splunk_mcp_server.py
|
|
28
|
+
|
|
29
|
+
# Install in Claude Desktop
|
|
30
|
+
uv run mcp install splunk_mcp_server.py
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Configuration
|
|
34
|
+
|
|
35
|
+
The server requires environment variables for Splunk connection. Copy `.env.example` to `.env` and configure:
|
|
36
|
+
- `SPLUNK_HOST`: Splunk server hostname (default: localhost)
|
|
37
|
+
- `SPLUNK_PORT`: Management port (default: 8089)
|
|
38
|
+
- `SPLUNK_SCHEME`: Connection scheme (http/https, default: https)
|
|
39
|
+
- `SPLUNK_TOKEN`: Authentication token (preferred)
|
|
40
|
+
- `SPLUNK_USERNAME` and `SPLUNK_PASSWORD`: Username/password authentication (fallback)
|
|
41
|
+
|
|
42
|
+
## Architecture
|
|
43
|
+
|
|
44
|
+
### Core Components
|
|
45
|
+
|
|
46
|
+
**Connection Management** (`get_splunk_service()` at line 39)
|
|
47
|
+
- Singleton pattern for Splunk service connections
|
|
48
|
+
- Supports both token-based and username/password authentication
|
|
49
|
+
- Token authentication takes precedence if both are configured
|
|
50
|
+
- Uses `splunklib.client` from the Splunk Python SDK
|
|
51
|
+
|
|
52
|
+
**MCP Server Framework**
|
|
53
|
+
- Built on FastMCP (`mcp.server.fastmcp`)
|
|
54
|
+
- All tools use the `@mcp.tool()` decorator
|
|
55
|
+
- Tools return dictionaries with `success`, `error`, and result data fields
|
|
56
|
+
- Consistent error handling pattern across all tools
|
|
57
|
+
|
|
58
|
+
### Tool Categories
|
|
59
|
+
|
|
60
|
+
The 50+ tools are organized into these functional groups:
|
|
61
|
+
|
|
62
|
+
1. **Search & Query** (lines 73-287): Execute SPL queries, run saved searches, retrieve results
|
|
63
|
+
2. **Index Management** (lines 150-183, 499-543): List indexes, get index details, retrieve statistics
|
|
64
|
+
3. **Alert Management** (lines 682-923): CRUD operations for alerts, view alert history
|
|
65
|
+
4. **Dashboard Operations** (lines 930-1079): Create/read/delete dashboards, manage XML content
|
|
66
|
+
5. **Knowledge Objects** (lines 1086-1280): Lookups, field extractions, data models
|
|
67
|
+
6. **Data Input Management** (lines 1287-1452): Monitor file inputs, network inputs, scripts
|
|
68
|
+
7. **User & Access Management** (lines 1459-1614): Users, roles, capabilities, permissions
|
|
69
|
+
8. **KV Store Operations** (lines 1621-1851): NoSQL-style storage with CRUD operations
|
|
70
|
+
9. **Data Model Tools** (lines 1858-2057): Accelerated data model searches using tstats
|
|
71
|
+
10. **Job Management** (lines 2064-2176): Monitor and control search jobs
|
|
72
|
+
11. **Search Macros** (lines 2183-2427): Reusable search components
|
|
73
|
+
12. **Server Administration** (lines 2434-2783): Server messages, settings, restart checks
|
|
74
|
+
|
|
75
|
+
### Key Design Patterns
|
|
76
|
+
|
|
77
|
+
**Namespace Management**
|
|
78
|
+
- Many operations set `service.namespace['app']` to control app context
|
|
79
|
+
- Default app is typically "search" but can be specified per operation
|
|
80
|
+
- Owner defaults to "-" (all users) or "nobody" (global scope)
|
|
81
|
+
|
|
82
|
+
**Job Lifecycle**
|
|
83
|
+
- Search operations create jobs via `service.jobs.create()`
|
|
84
|
+
- Jobs are polled with `while not job.is_done(): pass`
|
|
85
|
+
- Results are retrieved with `job.results(count=max_count)`
|
|
86
|
+
- Jobs are cancelled with `job.cancel()` to free resources
|
|
87
|
+
|
|
88
|
+
**Error Handling**
|
|
89
|
+
- All tools return `{"success": bool, ...}` dictionaries
|
|
90
|
+
- KeyError exceptions indicate resource not found
|
|
91
|
+
- Generic exceptions are caught and returned in `error` field
|
|
92
|
+
- No exceptions propagate to the MCP layer
|
|
93
|
+
|
|
94
|
+
**Data Serialization**
|
|
95
|
+
- REST API responses are parsed from JSON when needed
|
|
96
|
+
- Some endpoints return JSON-encoded strings that require double parsing
|
|
97
|
+
- CSV data for lookups is manually constructed from dictionaries
|
|
98
|
+
- Dashboard XML is passed directly without CDATA wrappers
|
|
99
|
+
|
|
100
|
+
## Special Considerations
|
|
101
|
+
|
|
102
|
+
### Query Auto-Prefixing
|
|
103
|
+
The `search_splunk()` tool automatically prefixes queries with `search` if they don't start with recognized commands (`search`, `|`, `from`, `tstats`, `inputlookup`). This is at line 95.
|
|
104
|
+
|
|
105
|
+
### Dashboard XML Format
|
|
106
|
+
When creating dashboards via `create_dashboard()`, pass plain XML without CDATA wrappers. The XML must include a `<label>` tag. The tool uses `eai:data` parameter for the XML content (line 1037).
|
|
107
|
+
|
|
108
|
+
### KV Store Operations
|
|
109
|
+
KV Store collections use MongoDB-style query syntax. The SDK provides a `.data` property on collections for CRUD operations:
|
|
110
|
+
- `collection.data.query(**params)` for queries
|
|
111
|
+
- `collection.data.insert(data)` for inserts
|
|
112
|
+
- `collection.data.update(key, data)` for updates
|
|
113
|
+
- Direct REST API call for deletes (line 1832)
|
|
114
|
+
|
|
115
|
+
### Lookup Table Updates
|
|
116
|
+
The `update_lookup_data()` tool replaces ALL existing data in the lookup table. It converts the list of dictionaries to CSV format manually (lines 1204-1212) before posting to the REST API.
|
|
117
|
+
|
|
118
|
+
### Large Response Mitigation
|
|
119
|
+
Some tools like `get_data_model()` accept a `summary_only` parameter (default: True) to avoid returning massive JSON payloads. Always use summary mode unless full details are explicitly needed.
|
|
120
|
+
|
|
121
|
+
## Dependencies
|
|
122
|
+
|
|
123
|
+
- **mcp[cli]**: FastMCP framework for building MCP servers
|
|
124
|
+
- **splunk-sdk**: Official Splunk Python SDK for REST API interaction
|
|
125
|
+
- **python-dotenv**: Environment variable management from .env files
|
|
126
|
+
|
|
127
|
+
## Python Version
|
|
128
|
+
|
|
129
|
+
Requires Python 3.10+ as specified in pyproject.toml.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
you may not use this file except in compliance with the License.
|
|
7
|
+
You may obtain a copy of the License at
|
|
8
|
+
|
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
See the License for the specific language governing permissions and
|
|
15
|
+
limitations under the License.
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mcp-server-splunk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A Model Context Protocol server for Splunk - search, manage, and analyze Splunk data via LLMs
|
|
5
|
+
Project-URL: Homepage, https://github.com/pahar0/mcp-server-splunk
|
|
6
|
+
Project-URL: Repository, https://github.com/pahar0/mcp-server-splunk
|
|
7
|
+
Project-URL: Issues, https://github.com/pahar0/mcp-server-splunk/issues
|
|
8
|
+
Author-email: pahar0 <pahar0@users.noreply.github.com>
|
|
9
|
+
License: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: ai,llm,mcp,model-context-protocol,splunk
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Requires-Python: >=3.10
|
|
20
|
+
Requires-Dist: mcp>=1.0.0
|
|
21
|
+
Requires-Dist: splunk-sdk>=2.0.0
|
|
22
|
+
Provides-Extra: dev
|
|
23
|
+
Requires-Dist: pytest>=7.0.0; extra == 'dev'
|
|
24
|
+
Requires-Dist: ruff>=0.1.0; extra == 'dev'
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
|
|
27
|
+
# Splunk MCP Server
|
|
28
|
+
|
|
29
|
+
A [Model Context Protocol](https://modelcontextprotocol.io/) server for Splunk. Enables AI assistants like Claude to search, manage, and analyze data in Splunk instances.
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
### Claude Desktop
|
|
34
|
+
|
|
35
|
+
Add to your Claude Desktop config:
|
|
36
|
+
|
|
37
|
+
**macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
38
|
+
**Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
39
|
+
|
|
40
|
+
```json
|
|
41
|
+
{
|
|
42
|
+
"mcpServers": {
|
|
43
|
+
"splunk": {
|
|
44
|
+
"command": "uvx",
|
|
45
|
+
"args": ["mcp-server-splunk"],
|
|
46
|
+
"env": {
|
|
47
|
+
"SPLUNK_HOST": "your-splunk-host",
|
|
48
|
+
"SPLUNK_TOKEN": "your-token"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Claude Code (CLI)
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
claude mcp add splunk -- uvx mcp-server-splunk \
|
|
59
|
+
-e SPLUNK_HOST=your-splunk-host \
|
|
60
|
+
-e SPLUNK_TOKEN=your-token
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### OpenAI Codex
|
|
64
|
+
|
|
65
|
+
Add to `~/.codex/config.toml`:
|
|
66
|
+
|
|
67
|
+
```toml
|
|
68
|
+
[mcp_servers.splunk]
|
|
69
|
+
command = "uvx"
|
|
70
|
+
args = ["mcp-server-splunk"]
|
|
71
|
+
|
|
72
|
+
[mcp_servers.splunk.env]
|
|
73
|
+
SPLUNK_HOST = "your-splunk-host"
|
|
74
|
+
SPLUNK_TOKEN = "your-token"
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### OpenCode
|
|
78
|
+
|
|
79
|
+
Add to your OpenCode config:
|
|
80
|
+
|
|
81
|
+
```yaml
|
|
82
|
+
mcp:
|
|
83
|
+
splunk:
|
|
84
|
+
type: local
|
|
85
|
+
command: uvx mcp-server-splunk
|
|
86
|
+
env:
|
|
87
|
+
SPLUNK_HOST: your-splunk-host
|
|
88
|
+
SPLUNK_TOKEN: your-token
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Configuration
|
|
92
|
+
|
|
93
|
+
| Variable | Required | Default | Description |
|
|
94
|
+
|----------|----------|---------|-------------|
|
|
95
|
+
| `SPLUNK_HOST` | Yes | localhost | Splunk server hostname |
|
|
96
|
+
| `SPLUNK_PORT` | No | 8089 | Splunk management port |
|
|
97
|
+
| `SPLUNK_SCHEME` | No | https | Connection scheme (http/https) |
|
|
98
|
+
| `SPLUNK_TOKEN` | * | - | Authentication token (recommended) |
|
|
99
|
+
| `SPLUNK_USERNAME` | * | - | Username (if not using token) |
|
|
100
|
+
| `SPLUNK_PASSWORD` | * | - | Password (if not using token) |
|
|
101
|
+
|
|
102
|
+
*Provide either `SPLUNK_TOKEN` or both `SPLUNK_USERNAME` and `SPLUNK_PASSWORD`.
|
|
103
|
+
|
|
104
|
+
### Getting a Splunk Token
|
|
105
|
+
|
|
106
|
+
1. Log into Splunk Web
|
|
107
|
+
2. Go to **Settings > Tokens**
|
|
108
|
+
3. Click **New Token**
|
|
109
|
+
4. Copy the token value
|
|
110
|
+
|
|
111
|
+
## Tools
|
|
112
|
+
|
|
113
|
+
### Search & Query
|
|
114
|
+
- `search_splunk` - Execute SPL queries
|
|
115
|
+
- `search_async` - Non-blocking searches
|
|
116
|
+
- `search_realtime` - Real-time streaming
|
|
117
|
+
- `export_search_results` - Export to file
|
|
118
|
+
- `run_saved_search` - Execute saved searches
|
|
119
|
+
|
|
120
|
+
### Index Management
|
|
121
|
+
- `list_indexes` / `get_index_info`
|
|
122
|
+
- `create_index` / `update_index` / `delete_index`
|
|
123
|
+
- `send_event` - Ingest events
|
|
124
|
+
|
|
125
|
+
### Alerts
|
|
126
|
+
- `list_alerts` / `create_alert` / `update_alert` / `delete_alert`
|
|
127
|
+
- `get_alert_history`
|
|
128
|
+
|
|
129
|
+
### Saved Searches
|
|
130
|
+
- `list_saved_searches` / `create_saved_search` / `update_saved_search` / `delete_saved_search`
|
|
131
|
+
|
|
132
|
+
### Dashboards
|
|
133
|
+
- `list_dashboards` / `get_dashboard` / `create_dashboard` / `delete_dashboard`
|
|
134
|
+
|
|
135
|
+
### Knowledge Objects
|
|
136
|
+
- `list_lookups` / `get_lookup_data` / `update_lookup_data`
|
|
137
|
+
- `list_macros` / `create_macro` / `update_macro` / `delete_macro`
|
|
138
|
+
- `list_field_extractions`
|
|
139
|
+
|
|
140
|
+
### KV Store
|
|
141
|
+
- `list_kvstore_collections` / `create_kvstore_collection` / `delete_kvstore_collection`
|
|
142
|
+
- `query_kvstore_collection` / `insert_kvstore_data` / `update_kvstore_data` / `delete_kvstore_data`
|
|
143
|
+
|
|
144
|
+
### Data Inputs
|
|
145
|
+
- `list_inputs` / `get_input_info`
|
|
146
|
+
- `create_monitor_input` / `delete_input`
|
|
147
|
+
|
|
148
|
+
### Users & Roles
|
|
149
|
+
- `list_users` / `get_user_info` / `create_user` / `update_user` / `delete_user`
|
|
150
|
+
- `list_roles` / `get_role_info` / `create_role` / `update_role` / `delete_role`
|
|
151
|
+
|
|
152
|
+
### Apps
|
|
153
|
+
- `list_apps` / `create_app` / `update_app` / `delete_app`
|
|
154
|
+
|
|
155
|
+
### Server
|
|
156
|
+
- `get_server_info` / `get_server_settings`
|
|
157
|
+
- `check_restart_required` / `restart_splunk` / `refresh_splunk`
|
|
158
|
+
- `list_jobs` / `get_job_results` / `cancel_job`
|
|
159
|
+
|
|
160
|
+
## Example Prompts
|
|
161
|
+
|
|
162
|
+
- "Search for errors in the last hour"
|
|
163
|
+
- "List all indexes and their sizes"
|
|
164
|
+
- "Create an alert for failed logins"
|
|
165
|
+
- "Show dashboards in the security app"
|
|
166
|
+
|
|
167
|
+
## Development
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
# Clone and install
|
|
171
|
+
git clone https://github.com/pahar0/mcp-server-splunk.git
|
|
172
|
+
cd mcp-server-splunk
|
|
173
|
+
uv sync
|
|
174
|
+
|
|
175
|
+
# Run locally
|
|
176
|
+
export SPLUNK_HOST=localhost SPLUNK_TOKEN=your-token
|
|
177
|
+
uv run mcp-server-splunk
|
|
178
|
+
|
|
179
|
+
# Debug with MCP Inspector
|
|
180
|
+
npx @modelcontextprotocol/inspector uv run mcp-server-splunk
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## License
|
|
184
|
+
|
|
185
|
+
Apache 2.0
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# Splunk MCP Server
|
|
2
|
+
|
|
3
|
+
A [Model Context Protocol](https://modelcontextprotocol.io/) server for Splunk. Enables AI assistants like Claude to search, manage, and analyze data in Splunk instances.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
### Claude Desktop
|
|
8
|
+
|
|
9
|
+
Add to your Claude Desktop config:
|
|
10
|
+
|
|
11
|
+
**macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
12
|
+
**Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
13
|
+
|
|
14
|
+
```json
|
|
15
|
+
{
|
|
16
|
+
"mcpServers": {
|
|
17
|
+
"splunk": {
|
|
18
|
+
"command": "uvx",
|
|
19
|
+
"args": ["mcp-server-splunk"],
|
|
20
|
+
"env": {
|
|
21
|
+
"SPLUNK_HOST": "your-splunk-host",
|
|
22
|
+
"SPLUNK_TOKEN": "your-token"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Claude Code (CLI)
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
claude mcp add splunk -- uvx mcp-server-splunk \
|
|
33
|
+
-e SPLUNK_HOST=your-splunk-host \
|
|
34
|
+
-e SPLUNK_TOKEN=your-token
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### OpenAI Codex
|
|
38
|
+
|
|
39
|
+
Add to `~/.codex/config.toml`:
|
|
40
|
+
|
|
41
|
+
```toml
|
|
42
|
+
[mcp_servers.splunk]
|
|
43
|
+
command = "uvx"
|
|
44
|
+
args = ["mcp-server-splunk"]
|
|
45
|
+
|
|
46
|
+
[mcp_servers.splunk.env]
|
|
47
|
+
SPLUNK_HOST = "your-splunk-host"
|
|
48
|
+
SPLUNK_TOKEN = "your-token"
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### OpenCode
|
|
52
|
+
|
|
53
|
+
Add to your OpenCode config:
|
|
54
|
+
|
|
55
|
+
```yaml
|
|
56
|
+
mcp:
|
|
57
|
+
splunk:
|
|
58
|
+
type: local
|
|
59
|
+
command: uvx mcp-server-splunk
|
|
60
|
+
env:
|
|
61
|
+
SPLUNK_HOST: your-splunk-host
|
|
62
|
+
SPLUNK_TOKEN: your-token
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Configuration
|
|
66
|
+
|
|
67
|
+
| Variable | Required | Default | Description |
|
|
68
|
+
|----------|----------|---------|-------------|
|
|
69
|
+
| `SPLUNK_HOST` | Yes | localhost | Splunk server hostname |
|
|
70
|
+
| `SPLUNK_PORT` | No | 8089 | Splunk management port |
|
|
71
|
+
| `SPLUNK_SCHEME` | No | https | Connection scheme (http/https) |
|
|
72
|
+
| `SPLUNK_TOKEN` | * | - | Authentication token (recommended) |
|
|
73
|
+
| `SPLUNK_USERNAME` | * | - | Username (if not using token) |
|
|
74
|
+
| `SPLUNK_PASSWORD` | * | - | Password (if not using token) |
|
|
75
|
+
|
|
76
|
+
*Provide either `SPLUNK_TOKEN` or both `SPLUNK_USERNAME` and `SPLUNK_PASSWORD`.
|
|
77
|
+
|
|
78
|
+
### Getting a Splunk Token
|
|
79
|
+
|
|
80
|
+
1. Log into Splunk Web
|
|
81
|
+
2. Go to **Settings > Tokens**
|
|
82
|
+
3. Click **New Token**
|
|
83
|
+
4. Copy the token value
|
|
84
|
+
|
|
85
|
+
## Tools
|
|
86
|
+
|
|
87
|
+
### Search & Query
|
|
88
|
+
- `search_splunk` - Execute SPL queries
|
|
89
|
+
- `search_async` - Non-blocking searches
|
|
90
|
+
- `search_realtime` - Real-time streaming
|
|
91
|
+
- `export_search_results` - Export to file
|
|
92
|
+
- `run_saved_search` - Execute saved searches
|
|
93
|
+
|
|
94
|
+
### Index Management
|
|
95
|
+
- `list_indexes` / `get_index_info`
|
|
96
|
+
- `create_index` / `update_index` / `delete_index`
|
|
97
|
+
- `send_event` - Ingest events
|
|
98
|
+
|
|
99
|
+
### Alerts
|
|
100
|
+
- `list_alerts` / `create_alert` / `update_alert` / `delete_alert`
|
|
101
|
+
- `get_alert_history`
|
|
102
|
+
|
|
103
|
+
### Saved Searches
|
|
104
|
+
- `list_saved_searches` / `create_saved_search` / `update_saved_search` / `delete_saved_search`
|
|
105
|
+
|
|
106
|
+
### Dashboards
|
|
107
|
+
- `list_dashboards` / `get_dashboard` / `create_dashboard` / `delete_dashboard`
|
|
108
|
+
|
|
109
|
+
### Knowledge Objects
|
|
110
|
+
- `list_lookups` / `get_lookup_data` / `update_lookup_data`
|
|
111
|
+
- `list_macros` / `create_macro` / `update_macro` / `delete_macro`
|
|
112
|
+
- `list_field_extractions`
|
|
113
|
+
|
|
114
|
+
### KV Store
|
|
115
|
+
- `list_kvstore_collections` / `create_kvstore_collection` / `delete_kvstore_collection`
|
|
116
|
+
- `query_kvstore_collection` / `insert_kvstore_data` / `update_kvstore_data` / `delete_kvstore_data`
|
|
117
|
+
|
|
118
|
+
### Data Inputs
|
|
119
|
+
- `list_inputs` / `get_input_info`
|
|
120
|
+
- `create_monitor_input` / `delete_input`
|
|
121
|
+
|
|
122
|
+
### Users & Roles
|
|
123
|
+
- `list_users` / `get_user_info` / `create_user` / `update_user` / `delete_user`
|
|
124
|
+
- `list_roles` / `get_role_info` / `create_role` / `update_role` / `delete_role`
|
|
125
|
+
|
|
126
|
+
### Apps
|
|
127
|
+
- `list_apps` / `create_app` / `update_app` / `delete_app`
|
|
128
|
+
|
|
129
|
+
### Server
|
|
130
|
+
- `get_server_info` / `get_server_settings`
|
|
131
|
+
- `check_restart_required` / `restart_splunk` / `refresh_splunk`
|
|
132
|
+
- `list_jobs` / `get_job_results` / `cancel_job`
|
|
133
|
+
|
|
134
|
+
## Example Prompts
|
|
135
|
+
|
|
136
|
+
- "Search for errors in the last hour"
|
|
137
|
+
- "List all indexes and their sizes"
|
|
138
|
+
- "Create an alert for failed logins"
|
|
139
|
+
- "Show dashboards in the security app"
|
|
140
|
+
|
|
141
|
+
## Development
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
# Clone and install
|
|
145
|
+
git clone https://github.com/pahar0/mcp-server-splunk.git
|
|
146
|
+
cd mcp-server-splunk
|
|
147
|
+
uv sync
|
|
148
|
+
|
|
149
|
+
# Run locally
|
|
150
|
+
export SPLUNK_HOST=localhost SPLUNK_TOKEN=your-token
|
|
151
|
+
uv run mcp-server-splunk
|
|
152
|
+
|
|
153
|
+
# Debug with MCP Inspector
|
|
154
|
+
npx @modelcontextprotocol/inspector uv run mcp-server-splunk
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## License
|
|
158
|
+
|
|
159
|
+
Apache 2.0
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "mcp-server-splunk"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "A Model Context Protocol server for Splunk - search, manage, and analyze Splunk data via LLMs"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.10"
|
|
7
|
+
license = {text = "Apache-2.0"}
|
|
8
|
+
authors = [
|
|
9
|
+
{name = "pahar0", email = "pahar0@users.noreply.github.com"}
|
|
10
|
+
]
|
|
11
|
+
keywords = ["mcp", "splunk", "llm", "ai", "model-context-protocol"]
|
|
12
|
+
classifiers = [
|
|
13
|
+
"Development Status :: 4 - Beta",
|
|
14
|
+
"Intended Audience :: Developers",
|
|
15
|
+
"License :: OSI Approved :: Apache Software License",
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"Programming Language :: Python :: 3.10",
|
|
18
|
+
"Programming Language :: Python :: 3.11",
|
|
19
|
+
"Programming Language :: Python :: 3.12",
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
dependencies = [
|
|
23
|
+
"mcp>=1.0.0",
|
|
24
|
+
"splunk-sdk>=2.0.0",
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
[project.optional-dependencies]
|
|
28
|
+
dev = [
|
|
29
|
+
"pytest>=7.0.0",
|
|
30
|
+
"ruff>=0.1.0",
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
[project.scripts]
|
|
34
|
+
mcp-server-splunk = "splunk_mcp_server:main"
|
|
35
|
+
|
|
36
|
+
[project.urls]
|
|
37
|
+
Homepage = "https://github.com/pahar0/mcp-server-splunk"
|
|
38
|
+
Repository = "https://github.com/pahar0/mcp-server-splunk"
|
|
39
|
+
Issues = "https://github.com/pahar0/mcp-server-splunk/issues"
|
|
40
|
+
|
|
41
|
+
[build-system]
|
|
42
|
+
requires = ["hatchling"]
|
|
43
|
+
build-backend = "hatchling.build"
|
|
44
|
+
|
|
45
|
+
[tool.hatch.build.targets.wheel]
|
|
46
|
+
packages = ["."]
|
|
47
|
+
|
|
48
|
+
[tool.ruff]
|
|
49
|
+
line-length = 100
|
|
50
|
+
target-version = "py310"
|