# Total Cost Optimization log policies

Manage [Coralogix Total Cost Optimization (TCO) Optimizer](https://coralogix.com/docs/user-guides/account-management/tco-optimizer/index.md) log policies directly from your AI agent. The Model Context Protocol (MCP) server provides a unified tool to create, retrieve, update, and delete log policies, and to generate infrastructure-as-code definitions.

## Tool

Use `manage_tco_log_policies` for all log policy operations.

| Action value          | Description                                                                |
| --------------------- | -------------------------------------------------------------------------- |
| `create`              | Create a log policy.                                                       |
| `get`                 | Retrieve a specific log policy by ID.                                      |
| `list`                | List log policies with an optional case-insensitive name filter.           |
| `update`              | Update an existing policy.                                                 |
| `delete`              | Delete a log policy by ID.                                                 |
| `generate_openapi`    | Generate the OpenAPI JSON payload for an atomic overwrite request.         |
| `generate_kubernetes` | Generate a Kubernetes Operator YAML manifest for the full log policy list. |
| `generate_terraform`  | Generate Terraform configuration for the full log policy list.             |

## Example prompts

### Create a policy

```text
Create a Total Cost Optimization log policy named low-priority-backend-errors.
Enable it, set priority low, match severities error and critical, match
applications that start with mcp-beta, and match subsystems that include backend.
```

### Export 1 policy

```text
Generate Terraform configuration for the Total Cost Optimization log policy named
low-priority-backend-errors. Do not apply it.
```

### Export the full policy list

```text
Generate Terraform configuration and Kubernetes YAML for the full current Total Cost
Optimization log policy list. This is inspect-only; do not apply the output.
```

## Important behaviors

- **Generated Terraform and Kubernetes are atomic overwrite resources.** Applying generated output replaces the complete backend log policy set.
- **Prefer full-list generation.** The tool allows single-policy generation, but returns a warning because the generated resource represents the full list.
- **Priority and severity values must be valid.** The tool rejects invalid values before it sends the request.
- **Archive retention output needs a resolvable retention name.** Provide it when generating Kubernetes YAML for archive-retention policies.
