---
name: kimaai_mcp_log_retention_days
type: filter
since: 1.5.8
tier: premium
feature: mcp-server
area: settings-admin
summary: Changes how many days KimaAI Pro keeps the MCP audit log and the log of ungrounded answers.
parameters:
  - name: days
    type: int
    description: The days to keep, 90 by default.
returns:
  type: int
  description: The days to keep; less than 1 keeps every row.
---

# kimaai_mcp_log_retention_days

## When it fires

Once a day, on the first request (front end, admin, REST or cron) more than 24 hours after the last cleanup. KimaAI Pro then deletes the rows older than the days returned from two tables, in the same run:

- `kimaai_mcp_audit`: one row per call of an MCP tool, with the user, the tool, its status, its arguments with personal data redacted and a summary of the result.
- `kimaai_mcp_groundedness`: the chatbot's answers that failed the groundedness check, with the visitor's question, the answer and the reason, for the MCP tools that diagnose answers.

Both hold what visitors and AI clients asked, and no setting changes how long they are kept. A row's age is counted from its `created_at`, in the database's time. The cleanup runs whether the MCP server is used or not, and the time of the last one is stored before the delete, so a failing delete is not retried until the next day. A new value takes effect with the next daily run. Less than 1 deletes nothing and keeps the rows for good.

## Example

```php
add_filter(
  'kimaai_mcp_log_retention_days',
  function (int $days): int {
    // A privacy policy that keeps such logs for 30 days.
    return 30;
  }
);
```

## Related

- `kimaai_chatbot_ungrounded_answer`: fires for the answers the groundedness log stores.
- `kimaai_chatbot_session_retention_days`: how long the chatbot's conversations are kept.
