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
- AsecurityFlicenseAqualityA Model Context Protocol (MCP) server that enables AI assistants like Claude to interact with your AWS environment. This allows for natural language querying and management of your AWS resources during conversations. Think of better Amazon Q alternative.Last updated -3264TypeScript
- AsecurityAlicenseAqualityAn MCP server that lets AI assistants interact with your Lunchmoney data, enabling natural language queries about transactions, budgets, and spending patterns.Last updated -438TypeScriptMIT License
- AsecurityAlicenseAqualityMCP-compatible server that enables AI assistants to interact with Lightdash analytics data, providing tools to list and retrieve projects, spaces, charts, dashboards, and metrics through a standardized interface.Last updated -132217TypeScriptMIT License
- -securityAlicense-qualityA lightweight service that enables AI assistants to execute AWS CLI commands through the Model Context Protocol (MCP), allowing AI tools to retrieve AWS documentation and interact with AWS services.Last updated -57PythonMIT License