CloudWatch Logs MCP 服务器
一个 MCP(模型上下文协议)服务器,提供用于访问 AWS CloudWatch 日志的工具。该服务器允许 AI 助手列出日志组并从 AWS CloudWatch 读取日志条目。
可用工具
列表组
列出可用的 CloudWatch 日志组。
参数:
prefix
(可选):日志组名称前缀region
(可选):AWS 区域accessKeyId
(可选):AWS 访问密钥 IDsecretAccessKey
(可选):AWS 秘密访问密钥sessionToken
(可选):AWS 会话令牌
**返回:**带有日志组列表的 JSON 字符串,包括logGroupName
、 creationTime
和storedBytes
。
获取日志
从特定日志组获取 CloudWatch 日志。
参数:
logGroupName
(必需):日志组的名称logStreamName
(可选):日志流的名称startTime
(可选):ISO 格式或相对时间的开始时间(例如“5m”、“1h”、“1d”)endTime
(可选):ISO 格式的结束时间filterPattern
(可选):日志的过滤模式region
(可选):AWS 区域accessKeyId
(可选):AWS 访问密钥 IDsecretAccessKey
(可选):AWS 秘密访问密钥sessionToken
(可选):AWS 会话令牌
**返回:**带有日志事件的 JSON 字符串,包括timestamp
、 message
和logStreamName
。
设置
AWS 凭证
确保已配置 AWS 凭证。您可以使用 AWS CLI 或通过设置环境变量来设置它们:
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
与 Claude Desktop 一起使用
将以下内容添加到您的claude_desktop_config.json
中:
Docker
如果您希望在 Docker 容器中运行服务器,则可以设置 Dockerfile 并使用以下配置:
实现细节
此服务器使用 MCP SDK 中的 FastMCP 类构建,该类提供了一种创建 MCP 服务器的简便方法。该服务器公开了两个主要工具:
list_groups
:列出可用的 CloudWatch 日志组get_logs
:从特定日志组读取日志条目
每个工具都实现为一个用@mcp.tool()
修饰的异步函数。服务器使用 boto3 库与 AWS CloudWatch Logs API 进行交互。
执照
麻省理工学院
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
MCP 服务器允许 AI 助手通过列出日志组和读取日志条目来访问 AWS CloudWatch 日志。
Related MCP Servers
- -securityAlicense-qualityA Model Context Protocol server that provides AI assistants access to AWS CloudWatch Logs, enabling browsing, searching, summarizing, and correlating logs across multiple AWS services.Last updated -86PythonApache 2.0
- -securityFlicense-qualityA simplified MCP server that provides a streamlined way to interact with AWS CloudWatch resources (log groups, log queries, and alarms) through the MCP protocol.Last updated -4Python
- -securityFlicense-qualityAn MCP server that enables interaction with Google Cloud Logging API, allowing users to write, read, and manage log entries and configurations through natural language.Last updated -Python
- -securityFlicense-qualityAn MCP server that provides access to Google Cloud Monitoring API, enabling interaction with cloud resources monitoring data through natural language commands.Last updated -Python