config_get_resource_config_history
Retrieve AWS resource configuration snapshots within a specified time range. Input AWS region, resource type, ID, start and end timestamps, and limit to fetch historical configurations.
Instructions
Fetch configuration snapshots for a resource between two ISO timestamps.
Parameters:
aws_region (str): The AWS region - use 'us-east-1' if not specified.
resource_type (str): e.g. 'AWS::S3::Bucket'.
resource_id (str): the resource's ARN or ID.
start_time (str): ISO timestamp, e.g. '2025-04-01T00:00:00Z'.
end_time (str): ISO timestamp.
limit (int): Maximum number of configuration items to return.
Returns:
JSON list of ConfigurationItem objects.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| aws_region | Yes | ||
| end_time | Yes | ||
| limit | No | ||
| resource_id | Yes | ||
| resource_type | Yes | ||
| start_time | Yes |
Input Schema (JSON Schema)
{
"properties": {
"aws_region": {
"title": "Aws Region",
"type": "string"
},
"end_time": {
"title": "End Time",
"type": "string"
},
"limit": {
"default": 10,
"title": "Limit",
"type": "integer"
},
"resource_id": {
"title": "Resource Id",
"type": "string"
},
"resource_type": {
"title": "Resource Type",
"type": "string"
},
"start_time": {
"title": "Start Time",
"type": "string"
}
},
"required": [
"aws_region",
"resource_type",
"resource_id",
"start_time",
"end_time"
],
"title": "config_get_resource_config_historyArguments",
"type": "object"
}
Implementation Reference
- server.py:722-761 (handler)The handler function decorated with @mcp.tool() implements the 'config_get_resource_config_history' tool. It uses the AWS Config boto3 client to retrieve the configuration history for a specified resource between given timestamps, parses the timestamps, handles errors, and returns JSON-serialized configuration items using a custom DateTimeEncoder.@mcp.tool() def config_get_resource_config_history( aws_region: str, resource_type: str, resource_id: str, start_time: str, end_time: str, limit: int = 10 ) -> str: """ Fetch configuration snapshots for a resource between two ISO timestamps. Parameters: aws_region (str): The AWS region - use 'us-east-1' if not specified. resource_type (str): e.g. 'AWS::S3::Bucket'. resource_id (str): the resource's ARN or ID. start_time (str): ISO timestamp, e.g. '2025-04-01T00:00:00Z'. end_time (str): ISO timestamp. limit (int): Maximum number of configuration items to return. Returns: JSON list of ConfigurationItem objects. """ client = boto3.client('config', region_name=aws_region) # Parse ISO timestamps into datetime (with UTC) try: start_dt = datetime.datetime.fromisoformat(start_time.replace('Z', '+00:00')) end_dt = datetime.datetime.fromisoformat(end_time.replace('Z', '+00:00')) except Exception as e: return f"Error parsing timestamps: {e}" resp = client.get_resource_config_history( resourceType=resource_type, resourceId=resource_id, earlierTime=start_dt, laterTime=end_dt, limit=limit ) items = resp.get("configurationItems", []) return json.dumps(items, indent=2, cls=DateTimeEncoder)
- server.py:616-620 (helper)Custom JSON encoder class used by the tool to properly serialize datetime objects in the response JSON.class DateTimeEncoder(json.JSONEncoder): def default(self, o): if isinstance(o, datetime.datetime): return o.isoformat() # Convert datetime to ISO-format string. return super().default(o)