-
Notifications
You must be signed in to change notification settings - Fork 0
Implement Splunk CLI & MCP server for ad-hoc queries following jira-cli pattern #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
|
@copilot can we use a popular Golang library for this? |
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Yes! I've refactored the code to use github.com/kuba--/splunk (v0.1.1), a popular Splunk Enterprise REST API client for Go available on pkg.go.dev. The internal/splunk package now wraps this library for core functionality (Search, ServerInfo) while extending it with additional methods for saved searches, alerts, and event submission. Commit: 2304895 Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
|
@copilot that library was abandoned 10 years ago. Can you use the official Splunk Go SDK. |
I've researched this and found that Splunk does not provide an official Go SDK for Splunk Enterprise. The only official Splunk Go SDK is splunk-cloud-sdk-go, which is explicitly for Splunk Cloud Services, not Splunk Enterprise. Splunk's official SDKs are for Python, JavaScript, Java, C#, PHP, and Ruby only. Since there's no official Go SDK for Splunk Enterprise, I'll revert to our custom implementation that directly uses the Splunk REST API. This gives us full control and doesn't depend on abandoned libraries. Would you like me to proceed with the custom implementation, or do you have a specific library in mind? Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
|
@copilot make the requested changes. |
… focus on ad-hoc queries only Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
All requested changes have already been completed in commit f5d1e65: ✅ Removed list-alerts command The CLI now focuses on ad-hoc queries only with 3 commands:
All tests pass and the build is clean. |
|
@copilot add build files. |
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Added build files following the jira-cli pattern: GitHub Actions Workflows:
Makefile:
Updated Commit: 7499bec |
|
@copilot use SPLUNK_URL rather than SPLUNK_HOST. |
Implements a focused Splunk CLI and MCP server based on the jira-cli architecture, providing direct command-line access and AI assistant integration for ad-hoc Splunk search queries.
Core Components
Key Features
Search execution:
MCP integration:
{ "mcpServers": { "splunk": { "command": "splunk", "args": ["mcp-server"] } } }Uses well-maintained Go libraries:
Authentication tokens stored in system keyring, host configuration in
~/.config/splunk-cli/config.json.API Client
Custom REST API client implementation for Splunk Enterprise, as there is no official Go SDK for Splunk Enterprise (Splunk only provides official SDKs for Python, JavaScript, Java, C#, PHP, and Ruby). The implementation provides:
All operations use Bearer token authentication against management port with 30s timeout.
Build Infrastructure
Includes complete build and CI/CD setup following jira-cli patterns:
GitHub Actions Workflows:
.github/workflows/go.yml- CI workflow that runs build and tests on push/PR to main.github/workflows/release.yml- Release workflow that builds multi-platform binaries (darwin/linux amd64/arm64, Windows) on tag pushMakefile:
make build- Build the binarymake test- Run testsmake clean- Remove build artifactsmake install- Install to /usr/local/binmake build-all- Build for all platformsmake lint- Run go vet and go fmtmake help- Show available targetsScope
This CLI is intentionally focused on ad-hoc search queries only. Saved searches, alerts, server info, and event submission capabilities have been excluded to keep the tool simple and targeted for interactive query use cases.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.