SEQ MCP Server 是一个 MCP(模型上下文协议)服务器,它使大语言模型(LLMs)能够从 SEQ 结构化日志记录服务器查询和分析日志。该服务器为日志管理和分析提供了强大的功能,帮助用户更高效地处理和理解日志数据。
# 使用 GitHub 容器注册表
docker pull ghcr.io/roeej/seq-mcp:latest
# 或者使用 Docker Hub
docker pull roeej/seq-mcp:latest
git clone https://github.com/RoeeJ/seq-mcp.git
cd seq-mcp
npm install
npm run build
| 变量 | 描述 | 默认值 | 是否必需 |
|---|---|---|---|
SEQ_URL |
SEQ 服务器的 URL | http://localhost:5341 |
是 |
SEQ_API_KEY |
用于身份验证的 API 密钥 | - | 否* |
SEQ_DEFAULT_LIMIT |
返回的默认事件数 | 100 |
否 |
SEQ_TIMEOUT |
请求超时时间(毫秒) | 30000 |
否 |
*如果您的 SEQ 实例启用了身份验证,则必需。
cp .env.example .env
.env 文件:SEQ_URL=http://your-seq-server:5341
SEQ_API_KEY=your-api-key-here
{
"mcpServers": {
"seq": {
"command": "node",
"args": ["/absolute/path/to/seq-mcp/dist/index.js"],
"env": {
"SEQ_URL": "http://localhost:5341",
"SEQ_API_KEY": "your-api-key-here"
}
}
}
}
{
"mcpServers": {
"seq": {
"command": "node.exe",
"args": ["C:\\path\\to\\seq-mcp\\dist\\index.js"],
"env": {
"SEQ_URL": "http://localhost:5341",
"SEQ_API_KEY": "your-api-key-here"
}
}
}
}
.env 文件:SEQ_URL=http://localhost:5341
SEQ_API_KEY=your-api-key-here
{
"seq": {
"command": "node",
"args": ["/path/to/seq-mcp/dist/index.js"]
}
}
{
"seq": {
"command": "node",
"args": ["/path/to/seq-mcp/dist/index.js"],
"env": {
"SEQ_URL": "http://localhost:5341",
"SEQ_API_KEY": "your-api-key-here",
"SEQ_DEFAULT_LIMIT": "200",
"SEQ_TIMEOUT": "60000"
}
}
}
在您的 shell 中设置环境变量:
# macOS/Linux - 添加到 ~/.bashrc 或 ~/.zshrc
export SEQ_URL="http://localhost:5341"
export SEQ_API_KEY="your-api-key-here"
# Windows PowerShell
$env:SEQ_URL = "http://localhost:5341"
$env:SEQ_API_KEY = "your-api-key-here"
然后使用简单的配置:
{
"seq": {
"command": "node",
"args": ["/path/to/seq-mcp/dist/index.js"]
}
}
配置完成后,您可以自然地查询日志:
"Show me all error logs from the last hour"
"Find logs containing 'timeout' errors"
"Analyze the log patterns for my API service"
"What are the most common errors in the last 24 hours?"
"Get details for event ID abc123"
使用过滤器搜索事件:
- query: SEQ 过滤语法(例如,"Level = 'Error'" 或 "@Message like '%failed%'")
- count: 结果数量(1 - 1000)
- fromDate/toDate: ISO 日期字符串
- level: 按日志级别过滤
按 ID 获取特定事件的详细信息。
分析日志模式:
- query: 可选的 SEQ 过滤器
- timeRange: 1h、6h、24h、7d 或 30d
- groupBy: 用于分组结果的属性名称
列出 SEQ 中所有配置的信号(已保存的搜索)。
检查 SEQ 服务器的健康状态。
curl http://localhost:5341/api/health
SEQ_TIMEOUT。# 在开发模式下运行
npm run dev
# 运行测试
npm test
# 代码检查
npm run lint
# 类型检查
npm run typecheck
Level = 'Error' - 所有错误日志@Message like '%timeout%' - 包含“timeout”的消息Application = 'MyApp' and Level in ['Warning', 'Error'] - MyApp 的警告和错误@Timestamp > Now() - 1h - 最近一小时的事件StatusCode >= 400 - HTTP 错误Environment = 'Production' and ResponseTime > 1000 - 生产环境中的慢请求UserId = '12345' - 特定用户的所有日志@Exception is not null - 所有包含异常的日志如果 SEQ 在 Docker 中运行:
{
"seq": {
"command": "node",
"args": ["/path/to/seq-mcp/dist/index.js"],
"env": {
"SEQ_URL": "http://host.docker.internal:5341",
"SEQ_API_KEY": "your-api-key"
}
}
}
对于云托管的 SEQ 实例:
{
"seq": {
"command": "node",
"args": ["/path/to/seq-mcp/dist/index.js"],
"env": {
"SEQ_URL": "https://seq.yourcompany.com",
"SEQ_API_KEY": "your-api-key",
"SEQ_TIMEOUT": "60000"
}
}
}
# 基本用法
docker run --rm \
-e SEQ_URL=http://host.docker.internal:5341 \
-e SEQ_API_KEY=your-api-key \
ghcr.io/roeej/seq-mcp:latest
# 使用所有环境变量
docker run --rm \
-e SEQ_URL=http://your-seq-server:5341 \
-e SEQ_API_KEY=your-api-key \
-e SEQ_DEFAULT_LIMIT=200 \
-e SEQ_TIMEOUT=60000 \
ghcr.io/roeej/seq-mcp:latest
添加到您的 Claude Desktop 配置中:
{
"mcpServers": {
"seq": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"-e", "SEQ_URL=http://host.docker.internal:5341",
"-e", "SEQ_API_KEY=your-api-key",
"ghcr.io/roeej/seq-mcp:latest"
]
}
}
}
{
"seq": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"-e", "SEQ_URL=http://your-seq-server:5341",
"-e", "SEQ_API_KEY=your-api-key",
"ghcr.io/roeej/seq-mcp:latest"
]
}
}
创建一个 docker-compose.yml 文件:
version: '3.8'
services:
seq-mcp:
image: ghcr.io/roeej/seq-mcp:latest
environment:
- SEQ_URL=http://seq:5341
- SEQ_API_KEY=${SEQ_API_KEY}
networks:
- seq-network
seq:
image: datalust/seq:latest
ports:
- "5341:5341"
environment:
- ACCEPT_EULA=Y
networks:
- seq-network
networks:
seq-network:
driver: bridge
本项目使用 GitHub Actions 进行持续集成和部署:
CI:每次推送和 PR 时运行,以确保代码质量。
Docker 发布:
git tag v1.0.0
git push origin v1.0.0
ghcr.io/roeej/seq-mcp:1.0.0。dockerhub/roeej/seq-mcp:1.0.0(需要设置密钥)。对于 Docker Hub 发布(可选):
DOCKERHUB_USERNAME:您的 Docker Hub 用户名。DOCKERHUB_TOKEN:Docker Hub 访问令牌。注意:GitHub 容器注册表(ghcr.io)发布使用存储库的 GITHUB_TOKEN 自动工作,无需额外设置。
git checkout -b feature/amazing-feature)。git commit -m 'Add some amazing feature')。git push origin feature/amazing-feature)。本项目采用 MIT 许可证。