# Total Cost Optimization trace policies

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

## Tool

Use `manage_tco_trace_policies` for all trace policy operations.

| Action value          | Description                                                                  |
| --------------------- | ---------------------------------------------------------------------------- |
| `create`              | Create a trace policy.                                                       |
| `get`                 | Retrieve a specific trace policy by ID.                                      |
| `list`                | List trace policies with an optional case-insensitive name filter.           |
| `update`              | Update an existing policy.                                                   |
| `delete`              | Delete a trace 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 trace policy list. |
| `generate_terraform`  | Generate Terraform configuration for the full trace policy list.             |

## Example prompts

### Create a trace policy

```text
Create a Total Cost Optimization trace policy named checkout-traces-low.
Enable it, set priority low, match applications that start with mcp-beta,
match subsystems that include backend, match action exactly GET /checkout,
exclude service internal, and add tag rule tags.http.method includes GET.
```

### Export 1 policy

```text
Generate Terraform configuration for the Total Cost Optimization trace policy named
checkout-traces-low. Do not apply it.
```

### Export the full policy list

```text
Generate Terraform configuration and Kubernetes YAML for the full current Total Cost
Optimization trace 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 trace policy set.
- **Prefer full-list generation.** The tool allows single-policy generation, but returns a warning because the generated resource represents the full list.
- **Trace tag rules must be valid.** The tool rejects duplicate tag names, blank tag names, and missing rule types.
- **Archive retention output needs a resolvable retention name.** Provide it when generating Kubernetes YAML for archive-retention policies.
