Splunk的MCP服务器
Splunk MCP服务器的Go实现。 支持STDIO和SSE(服务器事件HTTP API)。使用github/mark3labs/mcp-go SDK。
快速入门-光标集成
通过在Cursor中配置MCP设置,您可以将远程数据直接包含到LLM上下文中。
STDIO模式
cd /tmp # CHANGE ME
git clone https://github.com/jkosik/mcp-server-splunk.git
cd mcp-server-splunk/cmd/mcp-server-splunk/更新中的光标设置 ~/.cursor/mcp.json:
{
"mcpServers": {
"splunk_stdio": {
"name": "Splunk MCP Server",
"description": "Splunk MCP server",
"type": "stdio",
"command": "/tmp/mcp-server-splunk/cmd/mcp-server-splunk/mcp-server-splunk", # CHANGE ME
"env": {
"SPLUNK_URL": "https://changeme.splunkcloud.com:8089", # CHANGE ME
"SPLUNK_TOKEN": "abcdef" # CHANGE ME
}
}
}
}或者先重新构建服务器:
go build -o cmd/mcp-server-splunk/mcp-server-splunk cmd/mcp-server-splunk/main.goSSE模式
启动服务器:
export SPLUNK_URL=https://your-splunk-instance:8089
export SPLUNK_TOKEN=your-splunk-token
# Start the server
go run cmd/mcp-server-splunk/main.go -transport sse -port 3001更新中的光标设置 ~/.cursor/mcp.json:
{
"mcpServers": {
"splunk_sse": {
"name": "Splunk MCP Server (SSE)",
"description": "MCP server for Splunk integration (SSE mode)",
"type": "sse",
"url": "http://localhost:3001/sse"
}
}
}MCP工具和提示
list_splunk_saved_searches
- 参数: - count (number,可选):要返回的结果数(最大值100,默认值100) - offset (数字,可选):分页偏移量(默认值0)
list_splunk_alerts
- 参数: - count (number,可选):要返回的结果数(最大100,默认10) - offset (数字,可选):分页偏移量(默认值0) - title (string,可选):用于筛选警报标题的不区分大小写的子字符串
list_splunk_fired_alerts
- 参数: - count (number,可选):要返回的结果数(最大100,默认10) - offset (数字,可选):分页偏移量(默认值0) - ss_name (字符串,可选):搜索名称模式以过滤警报(默认“\*”) - earliest (字符串,可选):回顾的时间范围(默认“-24h”)
list_splunk_indexes
- 参数: - count (number,可选):要返回的结果数(最大100,默认10) - offset (数字,可选):分页偏移量(默认值0)
list_splunk_macros
- 参数: - count (number,可选):要返回的结果数(最大100,默认10) - offset (数字,可选):分页偏移量(默认值0)
internal/splunk/prompt.go实现MCP提示以查找特定关键字(例如GitHub或OKTA)的Splunk警报,并指示Cursor使用多个MCP工具首先查看所有Splunk警告、索引和宏,以提供最佳答案。
cmd/mcp/server/main.go以本地CSV文件的形式实现MCP资源,其中包含Splunk相关内容,为聊天提供进一步的上下文。
本地使用和测试
STDIO模式(默认)
export SPLUNK_URL=https://your-splunk-instance:8089
export SPLUNK_TOKEN=your-splunk-token
# List available tools
echo '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}' | go run cmd/mcp-server-splunk/main.go | jq
# Call list_splunk_saved_searches tool
echo '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"list_splunk_saved_searches","arguments":{}}}' | go run cmd/mcp-server-splunk/main.go | jqSSE模式(服务器发送事件HTTP API)
export SPLUNK_URL=https://your-splunk-instance:8089
export SPLUNK_TOKEN=your-splunk-token
# Start the server
go run cmd/mcp-server-splunk/main.go -transport sse -port 3001
# Call the server and get Session ID from the output. Do not terminate the session.
curl http://localhost:3001/sse
# Keep session running and and use different terminal window for the final MCP call
curl -X POST "http://localhost:3001/message?sessionId=YOUR_SESSION_ID" \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}' | jq通过Smithery安装
](https://smithery.ai/server/@jkosik/mcp-server-splunk)
Dockerfile 和 smithery.yaml 用于支持在\[Smithery\]托管此MCP服务器(https://smithery.ai/server/@jkosik/。
_经MCP审查认证:https://mcpreview.com/mcp-servers/jkosik/mcp-server-splunk_
