使用说明
相扑mcp
A. 模型上下文协议(MCP) 将AI助手连接到的服务器 相扑逻辑.直接从Claude、Cursor或任何兼容MCP的客户端搜索日志、运行聚合查询和管理收集器。
特性
- 日志搜索 --运行Sumo Logic查询并检索匹配的日志消息
- 聚集查询 --使用执行查询
count,sum,avg,group by,timeslice,以及其他运营商 - 收集器管理 --列出所有收集器并检查单个收集器的详细信息
- 灵活的时间范围 --支持ISO 8601时间戳和相对时间(
now,-15m,-1h,-7d,-1w) - 自动分页 --透明地处理大型结果集(最多10000个结果)
- 异步作业处理 -使用指数退避轮询管理Sumo Logic的基于作业的搜索API
工具
| 工具 | 说明 |
|---|---|
search_logs |
搜索与查询匹配的原始日志消息 |
get_records |
运行聚合查询并返回计算记录 |
list_collectors |
列出所有Sumo Logic收集器及其状态 |
get_collector |
按ID获取特定收集器的详细信息 |
先决条件
安装
来源
git clone https://github.com/morcegon/sumo-mcp.git
cd sumo-mcp
npm install
npm run build
配置
服务器需要三个环境变量:
| 变量 | 描述 | 示例 |
|---|---|---|
SUMO_ACCESS_ID |
您的Sumo Logic访问ID | suXXXXXXXXXXXXXX |
SUMO_ACCESS_KEY |
您的Sumo Logic访问密钥 | XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX |
SUMO_API_ENDPOINT |
相扑逻辑API端点 | https://api.us2.sumologic.com |
按部署列出的API终结点
| 部署 | 端点 |
|---|---|
| 美国1 | https://api.sumologic.com |
| 美国2 | https://api.us2.sumologic.com |
| 欧盟 | https://api.eu.sumologic.com |
| AU | https://api.au.sumologic.com |
| DE | https://api.de.sumologic.com |
| JP | https://api.jp.sumologic.com |
| CA | https://api.ca.sumologic.com |
在……里面 https://api.in.sumologic.com |
|
| 喂养 | https://api.fed.sumologic.com |
请参阅 Sumo Logic文档 查看完整列表。
与MCP客户端一起使用
克劳德桌面
添加到您的 claude_desktop_config.json:
{
"mcpServers": {
"sumo-mcp": {
"command": "node",
"args": ["/path/to/sumo-mcp/dist/index.js"],
"env": {
"SUMO_ACCESS_ID": "your-access-id",
"SUMO_ACCESS_KEY": "your-access-key",
"SUMO_API_ENDPOINT": "https://api.us2.sumologic.com"
}
}
}
}
克劳德代码
添加到您的 .claude/settings.json 或使用CLI:
{
"mcpServers": {
"sumo-mcp": {
"command": "node",
"args": ["/path/to/sumo-mcp/dist/index.js"],
"env": {
"SUMO_ACCESS_ID": "your-access-id",
"SUMO_ACCESS_KEY": "your-access-key",
"SUMO_API_ENDPOINT": "https://api.us2.sumologic.com"
}
}
}
}
光标
添加到光标MCP设置中:
{
"mcpServers": {
"sumo-mcp": {
"command": "node",
"args": ["/path/to/sumo-mcp/dist/index.js"],
"env": {
"SUMO_ACCESS_ID": "your-access-id",
"SUMO_ACCESS_KEY": "your-access-key",
"SUMO_API_ENDPOINT": "https://api.us2.sumologic.com"
}
}
}
}
更新MCP客户端
拉取此服务器的新版本后,运行 npm install 如果依赖关系发生了变化 npm run build 刷新 dist/index.js然后重新启动MCP客户端或服务器进程,以便客户端加载重建的服务器并刷新工具模式。
工具参考
search_logs
从Sumo Logic搜索原始日志消息。
参数:
| 参数 | 类型 | 必填 | 默认 | 说明 |
|---|---|---|---|---|
query |
string | yes | -- | Sumo Logic搜索查询 |
from |
string | 是 | -- | 开始时间(now相对或ISO 8601) |
to |
string | 是 | -- | 结束时间(now相对或ISO 8601) |
timeZone |
string | 否 | UTC |
时区无关的ISO输入时区 |
maxResults |
编号 | 否 | 100 |
要返回的最大消息数(1-10000) |
示例查询:
# Search for errors in the last 15 minutes
query: "_sourceCategory=prod/app error"
from: "-15m"
to: "now"
# Search a specific time window
query: "_sourceCategory=prod/api | where status >= 500"
from: "2024-01-15T00:00:00Z"
to: "2024-01-15T01:00:00Z"
获取记录
运行聚合查询并返回计算记录。将其用于包含以下运算符的查询 count, sum, avg, group by, timeslice等等。
参数: 同 search_logs.
示例查询:
# Count errors by status code in the last hour
query: "_sourceCategory=prod/api | where status >= 400 | count by status"
from: "-1h"
to: "now"
# Average response time over 5-minute intervals
query: "_sourceCategory=prod/api | timeslice 5m | avg(response_time) by _timeslice"
from: "-6h"
to: "now"
list_collectors
列出所有Sumo Logic收集器及其ID、名称、类型和活动状态。
参数: 没有。
get_收集器
获取特定收集器的详细信息。
参数:
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
id |
number | yes | 数字收集器ID |
时间格式参考
这 from 和 to 参数接受:
| 格式 | 示例 | 说明 |
|---|---|---|
| 关键字 | now |
MCP服务器时钟的当前时间 |
| 相对秒数 | -30s |
30秒前 |
| 相对分钟数 | -15m |
15分钟前 |
| 相对小时数 | -1h |
1小时前 |
| 相对天数 | -7d |
7天前 |
| 相对周数 | -1w |
1周前 |
| ISO 8601,带区域 | 2024-01-15T00:00:00Z |
绝对时间戳 |
| ISO 8601(毫秒) | 2024-01-15T00:00:00.123Z |
绝对时间戳;在调用Sumo Logic之前删除毫秒 |
| ISO 8601无区域 | 2024-01-15T00:00:00 |
已提供解释 timeZone |
在创建Sumo Logic搜索作业之前,服务器将所有接受的时间值标准化为秒精度UTC时间戳,例如 2024-01-15T00:00:00Z这避免了相扑搜索工作API在几秒钟内被拒绝,并为MCP客户端提供了使用相对时间范围的稳定方式。相对时间使用MCP服务器的实际时钟,而不是调用LLM指定的任何当前日期。
时区感知解析通过以下方式处理 卢克森选择Luxon而不是Moment.js是因为Moment的维护者不鼓励新的Moment使用,并将其描述为传统的维护模式项目;Luxon没有运行时依赖关系,并使用该平台 Intl 时区支持。
发展
# Install dependencies
npm install
# Run in development mode (auto-compiles TypeScript)
npm run dev
# Run tests
npm test
# Build for production
npm run build
# Run the built server
npm start
建筑
src/
index.ts # Server entry point — wires config, client, and tools
config.ts # Loads and validates environment variables
client.ts # Sumo Logic API client with job management
time.ts # Search time parsing, normalization, and validation
tools/
search.ts # search_logs tool
records.ts # get_records tool
collectors.ts # list_collectors and get_collector tools
error.ts # Error formatting utility
服务器使用MCP协议通过stdio进行通信。所有Sumo Logic搜索都是异步的——客户端创建搜索作业,以指数回退(500ms到5s)轮询完成情况,获取分页结果,并清理作业。