cloudwatch_describe_log_groups
Retrieve and filter CloudWatch log groups in a specified AWS region using name patterns to identify relevant logging resources.
Instructions
Describes available CloudWatch log groups in the specified region.
Parameters:
aws_region (str): The AWS region - use 'us-east-1' if not specified.
log_group_name_pattern (str): The pattern to filter log group names.
Pattern: [\.\-_/#A-Za-z0-9]*
If you specify a string for this parameter, the operation returns only log groups that have names that match the string based on a case-sensitive substring search.
For example, if you specify Foo, log groups named FooBar, aws/Foo, and GroupFoo would match, but foo, F/o/o and Froo would not match.
Thus, if you don't find any results with uppercase letters, try using lowercase letters.
Returns:
str: JSON-formatted list of log groups.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| aws_region | Yes | ||
| log_group_name_pattern | Yes | ||
| limit | No |
Implementation Reference
- server.py:393-422 (handler)The async handler function implementing the cloudwatch_describe_log_groups tool logic using boto3 CloudWatch Logs client to describe log groups matching the pattern.async def cloudwatch_describe_log_groups( aws_region: str, log_group_name_pattern: str, limit: int = 50 ) -> str: """ Describes available CloudWatch log groups in the specified region. Parameters: aws_region (str): The AWS region - use 'us-east-1' if not specified. log_group_name_pattern (str): The pattern to filter log group names. Pattern: [\.\-_/#A-Za-z0-9]* If you specify a string for this parameter, the operation returns only log groups that have names that match the string based on a case-sensitive substring search. For example, if you specify Foo, log groups named FooBar, aws/Foo, and GroupFoo would match, but foo, F/o/o and Froo would not match. Thus, if you don't find any results with uppercase letters, try using lowercase letters. Returns: str: JSON-formatted list of log groups. """ try: cw_client = boto3.client('logs', region_name=aws_region) # Describe log groups (you can add pagination if necessary) response = cw_client.describe_log_groups(logGroupNamePattern=log_group_name_pattern, limit=limit) log_groups = response.get('logGroups', []) if not log_groups: return "No log groups found." return json.dumps(log_groups, indent=2) except Exception as e: return f"Error describing log groups: {str(e)}"
- server.py:392-392 (registration)The @mcp.tool() decorator that registers the cloudwatch_describe_log_groups function as an MCP tool.@mcp.tool()
- server.py:398-411 (schema)The docstring provides the input schema description (parameters and return type), used by MCP for tool schema generation.""" Describes available CloudWatch log groups in the specified region. Parameters: aws_region (str): The AWS region - use 'us-east-1' if not specified. log_group_name_pattern (str): The pattern to filter log group names. Pattern: [\.\-_/#A-Za-z0-9]* If you specify a string for this parameter, the operation returns only log groups that have names that match the string based on a case-sensitive substring search. For example, if you specify Foo, log groups named FooBar, aws/Foo, and GroupFoo would match, but foo, F/o/o and Froo would not match. Thus, if you don't find any results with uppercase letters, try using lowercase letters. Returns: str: JSON-formatted list of log groups. """