cloudwatch_list_log_streams
List and retrieve log streams from a specified CloudWatch log group in your AWS region. Specify parameters like log group name and limit to return JSON-formatted results.
Instructions
Lists log streams in a specified CloudWatch log group.
Parameters:
aws_region (str): The AWS region - use 'us-east-1' if not specified.
log_group (str): The name of the log group.
limit (int): Maximum number of log streams to return.
Returns:
str: JSON-formatted list of log streams.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| aws_region | Yes | ||
| limit | No | ||
| log_group | Yes |
Implementation Reference
- server.py:424-447 (handler)This is the handler function for the 'cloudwatch_list_log_streams' tool. It is decorated with @mcp.tool(), which registers it with the MCP server. The function uses the boto3 CloudWatch Logs client to describe log streams in the specified log group and returns them as JSON.@mcp.tool() async def cloudwatch_list_log_streams( aws_region: str, log_group: str, limit: int = 50 ) -> str: """ Lists log streams in a specified CloudWatch log group. Parameters: aws_region (str): The AWS region - use 'us-east-1' if not specified. log_group (str): The name of the log group. limit (int): Maximum number of log streams to return. Returns: str: JSON-formatted list of log streams. """ try: cw_client = boto3.client('logs', region_name=aws_region) response = cw_client.describe_log_streams(logGroupName=log_group, limit=limit) log_streams = response.get('logStreams', []) return json.dumps(log_streams, indent=2) except Exception as e: return f"Error listing log streams: {str(e)}"