# MCP tool reference

Every tool an AI client sees when it connects to TKTail (`TKTail.exe mcp --stdio`). What they are for, how to turn AI access on and what an assistant can and cannot reach: [AI integration (MCP)](https://tktail.dev/help/mcp/). Tools only read, except those marked *Changes data* - each kind needs its own permission ([What AI clients may change](https://tktail.dev/help/mcp/#what-ai-clients-may-change)). Every answer, an error too, starts with `source`: the TKTail that produced it - its node and run ([Which TKTail answered](https://tktail.dev/help/mcp/#which-tktail-answered)). The same reference for agents and tools, as JSON: [/ai/mcp-tools.json](https://tktail.dev/ai/mcp-tools.json) ([AI agents](https://tktail.dev/help/ai-agents/)).

50 tools.

## Status and sources

### `tktail_status`

Call this first. Tells which TKTail you are connected to and what it can do now: version and build, whether a TKTail window answers (its open logs and current context are available) or this is a standalone process with no window, the instance and its role, the license edition and its capabilities, whether Windows Event Log and Metrics are available, how many sources are open, and the size limits of the answers; broker: which TKTail carries answers (the main window for its group) and over which transport. Every answer of every tool starts with source: the TKTail that produced it (nodeId, instanceId). Read-only.

*Read-only · answers without a running TKTail window too*

No arguments.

### `tktail_list_instances`

Lists the windows of this TKTail: the main window (Primary - the one whose state the other tools report) and its linked windows, each with its own source (its node and run - not the main window's), its number, title, the sources it shows and the one in front. Linked windows' current context is not available yet. Read-only.

*Read-only · answers without a running TKTail window too*

No arguments.

### `tktail_list_sources`

Lists the investigation sources open in the TKTail window: log files, Windows Event Logs (channels or saved .evtx files) and Metrics Views (Windows Performance Counters). Each has a sourceId (valid while this TKTail runs), its kind, a display name, semantic capabilities (records, text search, structured fields, semantic time, live, metric samples) and kind-specific metadata - for a file its path, format, encoding, size, the time range of its records as far as already read and how a rotation is followed (rotation: same-name, or a dated series - app_2026-10-14.log then app_2026-10-15.log as one log: its pattern, the LIVE file and the one it moved from, whether this file is a previous one kept open); for an event log its channel or file and its ingestion (LIVE health and lag, rows evicted by retention, events skipped to stay current, gaps in the source, the newest gap markers - known gaps are evidence); for metrics the counters (English names - language-independent), aliases and the interval. No file or event contents. Read-only.

*Read-only · answers without a running TKTail window too*

| Argument | Type | Required | Bounds | Description |
|---|---|---|---|---|
| `kinds` | array |  |  | Only these kinds (default: all). |
| `limit` | integer |  | 1..500 | At most this many sources (default 200). |

### `tktail_get_current_context`

Retrieves the evidence the user is focused on in the TKTail window right now - what they are looking at. For a log file: the source, the caret position (line, column, byte offset) and the whole logical record containing it (a multi-line entry such as a stack trace is one record, also when the caret is on a continuation line): its line range, semantic timestamp, severity, parsed fields with their roles, Summary, text and an evidenceRef. For a Windows Event Log: the selected event's channel, provider, event ID, level, time, process / thread, message and evidenceRef. For a Metrics View: the selected series (English counter name, alias, unit, latest value and quality), the cursor time or selected range. Returns contextKind "none" with a reason when nothing is focused or no TKTail window runs. Next: tktail_get_records_around (what happened before / after), tktail_search (other records with the same request ID). Text and fields are bounded (maxTextBytes, maxFields, maxFieldBytes); what was cut is marked truncated. Read-only.

*Read-only · answers without a running TKTail window too*

| Argument | Type | Required | Bounds | Description |
|---|---|---|---|---|
| `maxTextBytes` | integer |  | 0..65536 | The record's text, at most this many UTF-8 bytes (default 16384; 0: no text). |
| `maxFields` | integer |  | 0..256 | At most this many parsed fields (default 64). |
| `maxFieldBytes` | integer |  | 64..8192 | Each field value, at most this many UTF-8 bytes (default 2048). |

### `tktail_open_source`

Opens a file below an Investigation Root as a TKTail source (a tab the user sees) and returns its sourceId - then its records, records around a line or a time, and searches work as for any open source. Only below an enabled root (the path is checked in its final form: "..", other spellings and links that lead out are refused - scope_not_allowed), never a binary file, never a folder. An open file answers with its sourceId (alreadyOpen).

*Read-only · needs Trial or Pro (Extended AI investigation (MCP)) · opens the file as a paused tab in the window*

| Argument | Type | Required | Bounds | Description |
|---|---|---|---|---|
| `path` | string | yes |  | An absolute file path from tktail_discover_files. |

### `tktail_get_source_sample`

A bounded raw sample of an open log file: its logical records as the format in force frames them (a multi-line entry is one record; Plain Text: one line each), each with its line number, line count, byte offset and raw text - for understanding a log's layout or writing a format profile for it. from: start (default) or end; or line: N. records 1-200 (20), maxRecordBytes 64-16384 (4096), maxBytes 1024-65536 (16384) in all; truncated / reachedStart / reachedEnd say what is missing. Open sources only. Read-only.

*Read-only*

| Argument | Type | Required | Bounds | Description |
|---|---|---|---|---|
| `sourceId` | string | yes |  | An open log file (tktail_list_sources). |
| `from` | string |  | `start` / `end` |  |
| `line` | integer |  | 1.. |  |
| `records` | integer |  | 1..200 |  |
| `maxRecordBytes` | integer |  | 64..16384 |  |
| `maxBytes` | integer |  | 1024..65536 |  |

## Records

### `tktail_get_record`

Retrieves one logical record (one log entry - a multi-line entry such as an exception with its stack trace is one record) or one event, with its line range, semantic time, severity, parsed fields, Summary and bounded text - read exactly as TKTail's RECORD pane reads it. Name it by an evidenceRef (from the current context, a search result or another record), or by a sourceId with a line, a byteOffset (files) or a recordId (events). A line inside a record returns the whole record and says which of its lines was asked for (lineInRecord). A reference made before the file was rotated, truncated or replaced is refused as stale_source - never resolved into other bytes. Only sources open in TKTail. Read-only.

*Read-only*

| Argument | Type | Required | Bounds | Description |
|---|---|---|---|---|
| `evidenceRef` | object |  |  | A record or event reference exactly as TKTail returned it (current context, a search result, another record) - pass it back unchanged. |
| `sourceId` | string |  |  | An open source (tktail_list_sources), with line, byteOffset or recordId. |
| `line` | integer |  | 1.. | A 1-based line of a file: the record containing it. |
| `byteOffset` | integer |  | 0.. | A byte position in a file: the record containing it. |
| `recordId` | integer |  | 0.. | An event's EventRecordID (event log sources). |
| `maxTextBytes` | integer |  | 0..65536 | The record's text, at most this many UTF-8 bytes (default 16384). |
| `maxFields` | integer |  | 0..256 | At most this many parsed fields (default 64). |
| `maxFieldBytes` | integer |  | 64..8192 | Each field value, at most this many UTF-8 bytes (default 2048). |

### `tktail_get_records_around`

Retrieves the logical records before and after an anchor - what happened just before and after an error - in the order they are in the source (never re-sorted by time; each record has its own semantic time). The anchor is the user's current record (the default), an evidenceRef (a search result, a record), or a sourceId with a line, byteOffset, recordId or time. With a time, the record nearest that time (as TKTail's Go To Time finds it, out-of-order times included) is the anchor; when TKTail has read only part of the file's times, the answer says so (nearestScope "indexedPart") - "indexTimes": true reads the rest in the background. Each record is compact: evidenceRef, lines, time, severity, title, a few fields and a bounded text (use tktail_get_record for all of one record). With beforeSeconds / afterSeconds (0-3600): the records whose time is within that window of the anchor's (an undated record between is kept; the anchor must have a date and time), at most before / after (default 50) per side - window.completeBefore / completeAfter say whether the window's edge was reached. Bounded: at most 50 per side and the response budget; returnedBefore / returnedAfter, reachedStart / reachedEnd and truncated say what came back. Read-only.

*Read-only · indexTimes: true starts a background time index of the source*

| Argument | Type | Required | Bounds | Description |
|---|---|---|---|---|
| `anchor` | string |  | `current` | The record the user is on (the default when no other anchor is given). |
| `evidenceRef` | object |  |  | A record or event reference exactly as TKTail returned it (current context, a search result, another record) - pass it back unchanged. |
| `sourceId` | string |  |  | An open source, with one of line, byteOffset, recordId or time. |
| `line` | integer |  | 1.. |  |
| `byteOffset` | integer |  | 0.. |  |
| `recordId` | integer |  | 0.. |  |
| `time` | string |  |  | "2026-10-06T04:49:10" (wall clock, as most logs write it) or with "Z" / an offset (an instant). |
| `before` | integer |  | 0..50 | Records before the anchor (default 5). |
| `after` | integer |  | 0..50 | Records after the anchor (default 5). |
| `beforeSeconds` | integer |  | 0..3600 | A time window: the records up to this many seconds before the anchor's time. |
| `afterSeconds` | integer |  | 0..3600 | ... and after it. |
| `maxTextBytes` | integer |  | 0..8192 | Each record's text, at most this many UTF-8 bytes (default 512). |
| `maxFields` | integer |  | 0..64 | Fields per record (default 8). |
| `maxFieldBytes` | integer |  | 64..2048 | Each field value, at most this many UTF-8 bytes (default 256). |
| `indexTimes` | boolean |  |  | With time: let TKTail read the file's remaining record times in the background (default false). |

## Search

### `tktail_search`

Searches the sources open in TKTail with a TKTail search definition - the model of TKTail's Advanced Search, not a query language: "sources" ({"kind":"open"} = every open file and event log; {"kind":"source","path":"&lt;sourceId&gt;"} = one open source; {"kind":"session","session":N} = the results of an earlier search) and a "predicate": {"all":[...]} / {"any":[...]} of {"text":"timeout"} (literal; "case":true matches case), {"regex":"conn(ection)? refused"} (tktail-regex-1: PCRE2 with Unicode, bounded), {"field":{"name":"requestId","op":"eq","value":"ABC123"}} (op: exists eq ne contains startsWith endsWith gt ge lt le missing isNull isNotNull; "case":true), {"time":{"from":"2026-10-06T04:00:00","to":"2026-10-06T05:00:00"}} (wall clock; "Z" for UTC) or {"time":{"last":3600}}. Prefer a field condition when the format has the field (level, requestId, sc-status) - text or regex for free text. SEQUENCES (ordered relationships in time - X, then within a window Y): add "sequence":{"steps":[{"sources":[0],"predicate":{"all":[...]}},{"sources":[1],"predicate":{...},"window":{"after":"previous","earliestMs":0,"latestMs":10000}}],"correlation":[{"name":"requestId","compare":"exact","steps":[{"input":"field","field":"requestId"},{"input":"message","extract":"after","text":"requestId="}]}],"policy":"earliest"} - 2 to 8 steps; a step's sources are indexes of "sources" (none: all); windows are inclusive delays after the previous step's member (latest at most one day); correlation (optional, up to 4 key parts) maps each step's value: input field / message / text (the matched line), extract whole / regex ("pattern" + "group": a named capture) / after ("text") / delimited ("text" + "index") / substring / pathSegment / queryParameter ("name"), normalize trim / lower / upper / removePrefix / number; compare exact / ignoreCase / number. Such a search returns "sequences": each with start, end, durationMs, correlation values and its members in step order (evidenceRef, time, preview) - plus counts of anchors, candidates, comparisons, undated and missingKey items. Starts a search and waits up to waitMs (default 2000) for it: state, counts and the first results, each with an evidenceRef for tktail_get_record / tktail_get_records_around. Still running: tktail_get_search, page with tktail_get_search_results. evidenceMayBeMissing is true unless the search completed with every result stored - incomplete, failed and cancelled searches say why. Folders and paths not open in TKTail are refused (the Safe Workspace) - with Extended Investigation a {"kind":"folder","path":...} below an Investigation Root is searched (links not followed); open a single file first with tktail_open_source. Read-only; the search is listed in TKTail's Search Results, marked AI.

*Read-only · a folder scope below an Investigation Root: Trial or Pro (Extended AI investigation (MCP)) · starts an AI search session, shown in Search Results and Jobs (at most 5 kept)*

| Argument | Type | Required | Bounds | Description |
|---|---|---|---|---|
| `definition` | object | yes |  | A TKTail search definition: {"sources":[{"kind":"open"}],"predicate":{...}} (schemaVersion and regexDialect may be omitted). |
| `waitMs` | integer |  | 0..5000 | Wait up to this long for the search to finish (default 2000). |
| `maxResults` | integer |  | 0..100 | Results in this answer (default 20; 0: none). |
| `withFields` | boolean |  |  | Each file result with its record's severity and first fields (default false). |
| `fields` | array |  | at most 32 items | Projection: each file result with only these fields of its record, as "values" {name: value, or null when the record has none}. |
| `preview` | boolean |  |  | false: no preview text in the results - smaller pages (default true). |
| `aggregate` | object |  |  | Analyze EVERY match as the search finds it (also beyond the results it stores) - the answer's "aggregate", when the search has finished. Members as tktail_aggregate takes them. |

### `tktail_get_search`

Without searchId: the searches TKTail keeps - the user's and AI clients' - newest first, one line each. With searchId: its state (running, completed, incomplete, cancelled, failed), whether evidence may be missing and why, counts (matches found, results stored, sources, records scanned), progress; waitMs waits up to 5 s for a running search; maxResults &gt; 0 adds a page of results. Read-only.

*Read-only*

| Argument | Type | Required | Bounds | Description |
|---|---|---|---|---|
| `searchId` | integer |  | 1.. |  |
| `waitMs` | integer |  | 0..5000 | Wait up to this long for a running search (default 0). |
| `maxResults` | integer |  | 0..100 | Results to include (default 0). |
| `offset` | integer |  | 0.. |  |
| `withFields` | boolean |  |  |  |
| `fields` | array |  | at most 32 items | Projection: each file result with only these fields of its record, as "values" {name: value, or null when the record has none}. |
| `preview` | boolean |  |  | false: no preview text in the results - smaller pages (default true). |

### `tktail_get_search_results`

One page of a search's results (maxResults, default 20, at most 100) from offset - for a sequence search whole sequences (start, end, durationMs, correlation, members in step order), otherwise per result its source, the logical record and the line that matched (files: recordStart, line, the match's bytes; events: record ID, event ID, level, provider), its semantic time, a bounded preview and an evidenceRef - pass it to tktail_get_record or tktail_get_records_around. withFields adds each record's severity and first fields. nextOffset / hasMore page on; a result whose file changed since the search is stale (no evidenceRef). Read-only.

*Read-only*

| Argument | Type | Required | Bounds | Description |
|---|---|---|---|---|
| `searchId` | integer | yes | 1.. |  |
| `offset` | integer |  | 0.. | Default 0. |
| `maxResults` | integer |  | 1..100 | Default 20. |
| `withFields` | boolean |  |  |  |
| `fields` | array |  | at most 32 items | Projection: each file result with only these fields of its record, as "values" {name: value, or null when the record has none}. |
| `preview` | boolean |  |  | false: no preview text in the results - smaller pages (default true). |

### `tktail_cancel_search`

Stops a running search an AI client started - the same as Cancel in TKTail's Jobs; the results found so far stay, the state says cancelled. The user's own searches cannot be cancelled here.

*Read-only · stops one of the client's own searches (the user's searches answer not_allowed)*

| Argument | Type | Required | Bounds | Description |
|---|---|---|---|---|
| `searchId` | integer | yes | 1.. |  |

### `tktail_aggregate`

Analyzes the results a finished search STORED - never a rescan, the same analysis as TKTail's Search Results: "groupBy" up to 4 keys (a field name such as "c-ip" or "sc-status", or a value mapping as in sequence correlation: {"input":"text","extract":"regex","pattern":"user=(?&lt;u&gt;\\w+)","group":"u"}, {"input":"message","extract":"after","text":"tenant="}) gives the top N groups ("top", default 10, at most 1000; "order" count / sum / max / min / avg) with counts, the first result of each (firstResultIndex for tktail_get_search_results, an evidenceRef) and the rows outside the top (otherRows); "bucket" ("1m", "5m", "1h", 1 second to 1 day) adds a time histogram (UTC bucket starts; undated rows counted apart); "number" (a field such as "time-taken" or a mapping, e.g. a regex capture of "elapsed=(?&lt;ms&gt;\\d+)ms") adds count / sum / min / max / avg overall, per group and per bucket - a number is read exactly ("1985.000", "-3", "1e3"; never "1,5" or "12ms": those are notNumbers). A row is a matched line or event (a second match on the same line is mergedMatches, never a second row). Without groupBy, bucket or number: the row count alone (count-only). complete is true only when the search completed with every match stored, every row read again and nothing over a bound - otherwise caveats say what the numbers cover. Waits up to waitMs (default 2000) - still running: call again with "analysisId" alone. Bounded: 10,000 distinct keys (further rows counted as untrackedRows), 10,000 buckets. Read-only.

*Read-only*

| Argument | Type | Required | Bounds | Description |
|---|---|---|---|---|
| `searchId` | integer |  | 1.. | A finished search (tktail_search, tktail_get_search). |
| `analysisId` | integer |  | 1.. | An analysis already started: its answer (alone, with waitMs). |
| `groupBy` | array |  | at most 4 items |  |
| `top` | integer |  | 1..1000 | Groups in the answer (default 10). |
| `order` | string |  | `count` / `sum` / `max` / `min` / `avg` | How the top groups are chosen (default count; the others need a number). |
| `bucket` | string |  |  | A histogram bucket: 1s to 1d ("1m", "5m", "1h"). |
| `number` |  |  |  |  |
| `waitMs` | integer |  | 0..5000 | Wait up to this long for the analysis (default 2000). |

### `tktail_list_saved_searches`

Lists the user's Saved Searches - named, versioned search definitions (sequences included): id, name, description, version, what they look for and where, and whether an AI client may run them (a folder search is outside the Safe Workspace). Run one with tktail_run_saved_search; see its definition with tktail_get_saved_search. Read-only.

*Read-only · answers without a running TKTail window too*

| Argument | Type | Required | Bounds | Description |
|---|---|---|---|---|
| `limit` | integer |  | 1..500 | Default 100. |

### `tktail_get_saved_search`

One Saved Search with its definition - TKTail's search definition JSON, the form tktail_search takes (adapt it and search, or run it as is with tktail_run_saved_search) and its version (the expectedVersion of a change with tktail_save_search). Read-only.

*Read-only*

| Argument | Type | Required | Bounds | Description |
|---|---|---|---|---|
| `id` | string | yes |  |  |

### `tktail_run_saved_search`

Runs a Saved Search as a new search of the open sources - a copy of its current version (the search remembers which Saved Search and version it came from; editing the Saved Search later changes nothing here). Then as tktail_search: state, counts, the first results with evidenceRefs. Read-only.

*Read-only · starts a new AI search session from a copy of the Saved Search*

| Argument | Type | Required | Bounds | Description |
|---|---|---|---|---|
| `id` | string | yes |  |  |
| `waitMs` | integer |  | 0..5000 | Default 2000. |
| `maxResults` | integer |  | 0..100 | Default 20. |
| `withFields` | boolean |  |  |  |
| `fields` | array |  | at most 32 items | Projection: each file result with only these fields of its record, as "values" {name: value, or null when the record has none}. |
| `preview` | boolean |  |  | false: no preview text in the results - smaller pages (default true). |
| `aggregate` | object |  |  | Analyze EVERY match as the search finds it (also beyond the results it stores) - the answer's "aggregate", when the search has finished. Members as tktail_aggregate takes them. |

### `tktail_save_search`

Saves a search definition as a Saved Search (name, description, definition - what tktail_search takes), or changes one (savedSearchId with expectedVersion = the version you read; a newer version is refused: conflict). Only when the user allowed it (Settings &gt; AI Access &gt; Allow AI to save searches and Metric Sets). Its sources must last: open sources ({"kind":"open"} or a sourceId - kept as the file's path), files and folders below an approved Investigation Root - never a search session; a sourceId TKTail follows as a dated series is kept as the series ("series"). Returns savedSearchId and version; an alert can then use the same condition.

*Changes data - needs "Allow AI to save searches and Metric Sets" · paths below an Investigation Root: Trial or Pro (Extended AI investigation (MCP))*

| Argument | Type | Required | Bounds | Description |
|---|---|---|---|---|
| `definition` |  | yes |  |  |
| `name` | string | yes | at most 100 characters |  |
| `description` | string |  |  |  |
| `savedSearchId` | string |  |  |  |
| `expectedVersion` | integer |  | 1.. |  |

### `tktail_delete_saved_search`

Deletes a Saved Search (savedSearchId, expectedVersion = the version you read). Needs Allow AI to save searches and Metric Sets. Alerts made from it keep their own copy of the condition. Ask the user first.

*Changes data - needs "Allow AI to save searches and Metric Sets"*

| Argument | Type | Required | Bounds | Description |
|---|---|---|---|---|
| `savedSearchId` | string | yes |  |  |
| `expectedVersion` | integer | yes | 1.. |  |

## Alerts and incidents

### `tktail_list_alerts`

Lists the user's alerts (TKTail watches files and Windows performance counters for them): alertId, alertNumber, name, enabled, kind (file / metric), severity, version (every saved change of meaning is a new version), the condition and the evidence it keeps in words, whether it is evaluated now (and why not), and its incidents (total, new = unacknowledged, the latest). Investigate an incident with tktail_list_alert_occurrences / tktail_get_alert_occurrence. Read-only; alerts change through tktail_save_alert and its siblings, only when the user allowed AI clients to manage alerts.

*Read-only*

| Argument | Type | Required | Bounds | Description |
|---|---|---|---|---|
| `limit` | integer |  | 1..500 | Default 100. |

### `tktail_get_alert`

One alert with its definition: the condition as TKTail's search definition JSON (the form tktail_search takes), the evidence capture policy, the behavior (intervalMs, cooldownMs - triggers within the cooldown join one incident), a metric alert's live status (conditionTrue: true / false / unknown - an invalid sample is never a value - and the observed value) and its 10 latest incidents. "alert" is the whole definition in the form tktail_validate_alert / tktail_save_alert take (its version is the expectedVersion of a change); madeByAi says an AI client saved it. Read-only.

*Read-only*

| Argument | Type | Required | Bounds | Description |
|---|---|---|---|---|
| `alertId` | string |  |  |  |
| `alertNumber` | integer |  | 0.. |  |

### `tktail_list_alert_occurrences`

The incident history, newest first: each time an alert fired, the occurrence it kept - occurrenceId, the alert, the version that fired, severity, state (capturing: evidence after the trigger still being collected; complete; partial: some evidence is missing, with the reason; failed), triggeredAt (UTC), matchCount (a storm is one incident), acknowledged, pinned, the trigger text, how many evidence items and how many complete. Filters: alertId / alertNumber (a deleted alert's incidents stay), from / to (UTC, triggered within), states, severities or minSeverity (info &lt; warning &lt; error &lt; critical; "error" = error and critical), newOnly, text (in the alert name or trigger). Severity is the alert's when the incident fired (a later edit does not change it). origin: the TKTail node and run that captured it (after a restart not the run answering; unavailable for incidents of an earlier TKTail). Paged: offset, limit (1-100, default 20), total, nextOffset. Listing reads no evidence. Read-only.

*Read-only*

| Argument | Type | Required | Bounds | Description |
|---|---|---|---|---|
| `alertId` | string |  |  |  |
| `alertNumber` | integer |  | 0.. |  |
| `from` | string |  |  | UTC: "2026-10-09T10:00:00Z". |
| `to` | string |  |  |  |
| `states` | array |  |  |  |
| `severities` | array |  |  |  |
| `minSeverity` |  |  | `info` / `warning` / `error` / `critical` | This severity and higher. |
| `newOnly` | boolean |  |  |  |
| `text` | string |  |  |  |
| `offset` | integer |  | 0.. |  |
| `limit` | integer |  | 1..100 |  |

### `tktail_get_alert_occurrence`

One incident: the alert and the version that fired with its condition as it was then (definition JSON), the trigger - the record that matched (its text, semantic time, the match's character ranges, source file, format, encoding) or a metric condition with the observed value and the samples it was decided on - each evidence item (file records, Event Log events, metric samples) with its state, the reason when not complete, its window, counts and notes (rotation, truncation), the capture's diagnostics and its origin (the node and run that captured it). Read the kept evidence with tktail_get_occurrence_evidence. Evidence is what the user's alert asked for - TKTail captured it when the alert fired, it is not re-read. Read-only.

*Read-only*

| Argument | Type | Required | Bounds | Description |
|---|---|---|---|---|
| `occurrenceId` | string | yes |  |  |
| `maxTextBytes` | integer |  | 256..16384 | The trigger record's text, default 4096. |

### `tktail_get_occurrence_evidence`

A page of what one evidence item of an incident kept, in order: records (rel: position relative to the trigger record, -2 = two before it; the trigger marked; time, text, generation: 1 the trigger's file, 2.. files read after a rotation or in a dated series' next file, 0 the series' previous file), events (recordId, time, level, eventId, provider, message) or samples (metric index and label, time UTC, value only when valid, quality), and notes (a generation's note names its file's path when it is another file). Paged: item (1-based, default 1), offset, limit (1-200, default 50), maxTextBytes per text (256-16384, default 4096); total, nextOffset. Read-only.

*Read-only*

| Argument | Type | Required | Bounds | Description |
|---|---|---|---|---|
| `occurrenceId` | string | yes |  |  |
| `item` | integer |  | 1..16 |  |
| `offset` | integer |  | 0.. |  |
| `limit` | integer |  | 1..200 |  |
| `maxTextBytes` | integer |  | 256..16384 |  |

### `tktail_validate_alert`

Checks a proposed alert exactly as saving it would - the definition, the search condition, the sources and evidence it names (open sources, metrics, event log channels, files and folders below an approved Investigation Root - nothing else), the limits, the license (a Performance Counter alert needs Metrics) - and saves nothing. Use it before tktail_save_alert, also when saving is not allowed. alert: the alert file's JSON as tktail_get_alert shows it in "alert" (the schema below lists every member and value). A file alert names its sources by sourceId; when TKTail follows that file as a dated series (tktail_list_sources file.rotation), the alert follows the series - its newest file - and the normalized alert says so ("series"); give "series" yourself for a series TKTail did not detect (u_ex{YYMMDD}.log). A metric alert: a source {kind metric, metric {object, counter, instance}} and {metric:{source:0, op, value, aggregate, windowMs \| forMs}}. Omitted members take defaults. Returns valid, problem, whether the live runtime would evaluate it (notEvaluatedBecause), the normalized alert. The examples are complete.

*Read-only · a metric alert or metric evidence: Trial or Pro (Performance counters (Metrics))*

| Argument | Type | Required | Bounds | Description |
|---|---|---|---|---|
| `alert` |  | yes |  |  |

### `tktail_save_alert`

Creates an alert, or changes one (alertId or alertNumber, with expectedVersion = the version you read - a version the user changed since is refused: conflict). Only when the user allowed it (Settings &gt; AI Access &gt; Allow AI to manage alerts; otherwise not_allowed). Checked as tktail_validate_alert: sources and evidence only from what TKTail may read for AI clients. The alert is saved as the user's alerts are (Manage Alerts shows it at once), marked as made by an AI client; one that needs an Investigation Root is disabled when the user removes that root. The alert keeps its file watched while it is enabled - also without a tab (a dated series: its newest file). Returns alertId, alertNumber, version, whether it is evaluated. Ask the user before saving.

*Changes data - needs "Allow AI to manage alerts" · a metric alert or metric evidence: Trial or Pro (Performance counters (Metrics))*

| Argument | Type | Required | Bounds | Description |
|---|---|---|---|---|
| `alert` |  | yes |  |  |
| `alertId` | string |  |  |  |
| `alertNumber` | integer |  | 1.. |  |
| `expectedVersion` | integer |  | 1.. | Changing an alert: the version you read. |

### `tktail_set_alert_enabled`

Enables or disables an alert (alertId or alertNumber, expectedVersion = the version you read). Needs Allow AI to manage alerts. Disabling stops it at once; its incidents stay.

*Changes data - needs "Allow AI to manage alerts"*

| Argument | Type | Required | Bounds | Description |
|---|---|---|---|---|
| `alertId` | string |  |  |  |
| `alertNumber` | integer |  | 1.. |  |
| `enabled` | boolean | yes |  |  |
| `expectedVersion` | integer | yes | 1.. |  |

### `tktail_delete_alert`

Deletes an alert (alertId or alertNumber, expectedVersion = the version you read). Needs Allow AI to manage alerts. Its incidents and the alert history stay. Ask the user first.

*Changes data - needs "Allow AI to manage alerts"*

| Argument | Type | Required | Bounds | Description |
|---|---|---|---|---|
| `alertId` | string |  |  |  |
| `alertNumber` | integer |  | 1.. |  |
| `expectedVersion` | integer | yes | 1.. |  |

## Evidence

### `tktail_pin_search`

Pins a search (pinned: true, the default) so TKTail never closes it to make room - the AI clients' bound of 5 searches and the session limit apply to unpinned searches only. A pinned search is kept across a TKTail restart (its definition and the references of its results) and stays usable by tktail_aggregate, tktail_get_search_results and tktail_save_evidence while its files still hold the same data. At most 20 searches are pinned; beyond that the pin is refused - unpin one. Pin a search while an investigation continues; save evidence (tktail_save_evidence) when proof must survive the logs rotating or being deleted - a pin keeps references, a package keeps the bytes. An AI client may unpin only searches an AI client pinned. preserveEvidence also starts saving the results' records as an evidence package - the strongest protection against rotation; the answer's preservation is a capture that is still running (state capturing: NOT preserved yet - confirm with tktail_get_evidence(packageId, waitMs) until saved or failed before telling anyone it is preserved). A pinned search's answer says its protection: preserved (a verified package exists - evidencePreserved true), preservationPending (capturing), preservationFailed (the capture failed or was cancelled - failedCapture names its failureCode; save again), sourceStillAvailable or sourceDisappeared (never a guarantee TKTail cannot give). While a capture runs, its search is never closed to make room. keptAcrossRestart: its snapshot is on disk (a finished search's pin is answered once it is written, 3 s at most; a running search's when it finishes). Needs Allow AI to save evidence and pin searches (off until the user turns it on).

*Changes data - needs "Allow AI to save evidence and pin searches" · pins or unpins a search: a pinned search is never closed to make room and is kept across a restart (a snapshot of its references in the data folder); an AI client cannot unpin the user's pin*

| Argument | Type | Required | Bounds | Description |
|---|---|---|---|---|
| `searchId` | integer | yes | 1.. |  |
| `pinned` | boolean |  |  | true (default): pin; false: unpin. |
| `preserveEvidence` | boolean |  |  | Also save the results' records now as an evidence package (redacted), while the files still hold them. |
| `contextRecords` | integer |  | 0..1000 | With preserveEvidence: records kept on each side of a hit (default 20). |

### `tktail_save_evidence`

Preserves evidence as a durable, redacted, verifiable package in TKTail's Evidence Store - only the records that matter, never a copy of a whole log. Name what: "searchId" (all its results, or the result indexes in "results") and / or "evidenceRefs" (from search results, records, incidents). Context around each hit: "contextRecordsBefore" / "contextRecordsAfter" (logical records as the format frames them - a stack trace is one record; at most 1000) and / or "contextTimeBeforeMs" / "contextTimeAfterMs" (by each record's own time). TKTail seeks to the hits' stored byte offsets (no rescan), merges overlapping ranges and keeps the source bytes exactly where nothing was redacted. Correlated sources for the same time window (the hits' span widened by the time context, 15 s when none is given) are named explicitly: "correlatedSourceIds" (other open files and event logs), "correlatedChannels" (Windows event log channels such as "Application"), "correlatedMetricSets" (Metric Set ids - their kept samples). Secrets (Authorization / Bearer headers, JWTs, passwords and connection-string passwords, API keys, private keys and the user's own rules) are redacted BEFORE anything is written - there is no unredacted option. "note" says why; "linkIncidentId" links an incident; "destination" {"folder"} also copies the package below an Investigation Root (Extended Investigation). The capture runs in the background: the answer waits up to waitMs (default 3000) and says state - saved (preserved: true, the package is written and VERIFIED), capturing (preserved: false - NOT saved yet; call tktail_get_evidence(packageId, waitMs) until the state is saved or failed, and never report evidence as saved before), failed or cancelled (preserved: false, failureCode package_write_failed / package_verify_failed / evidence_limit_exceeded / evidence_quota_exceeded / source_unavailable / capture_failed / cancelled, and the reason; nothing was preserved - tktail_list_evidence lists such captures under failed). Saved: packageId, the archive's size and SHA-256, the time range, counts, the source bytes read (sourceBytesRead), the number of redactions and warnings (a source that changed or rotated before it could be read is reported, never guessed; nothing preserved at all is a failure). A package keeps at most 5000 hits (a search stores at most 5000 results; beyond that the manifest's limitations say how many were kept). "fullFileSourceId" saves a whole open file instead (when a vendor asks for the whole log): redacted, compressed while it is read, paced, within the full-file limit - never a copy of a file TKTail does not have open. Needs Allow AI to save evidence and pin searches (off until the user turns it on).

*Changes data - needs "Allow AI to save evidence and pin searches" · correlatedMetricSets: Trial or Pro (Performance counters (Metrics)) · a destination folder below an Investigation Root: Trial or Pro (Extended AI investigation (MCP)) · writes a redacted evidence package (a ZIP) into the Evidence Store (the data folder's Evidence folder), within its size limits; with destination also a copy below an Investigation Root*

| Argument | Type | Required | Bounds | Description |
|---|---|---|---|---|
| `searchId` | integer |  | 1.. | A finished search: its results are the hits. |
| `results` | array |  | at most 5000 items | With searchId: only these result indexes. |
| `evidenceRefs` | array |  | at most 1000 items | evidenceRef objects as TKTail returned them. |
| `contextRecordsBefore` | integer |  | 0..1000 |  |
| `contextRecordsAfter` | integer |  | 0..1000 |  |
| `contextTimeBeforeMs` | integer |  | 0..21600000 |  |
| `contextTimeAfterMs` | integer |  | 0..21600000 |  |
| `correlatedSourceIds` | array |  | at most 16 items | Open files / event logs (tktail_list_sources) for the same window. |
| `correlatedChannels` | array |  | at most 16 items | Windows event log channels by name ("Application"). |
| `correlatedMetricSets` | array |  | at most 8 items | Metric Set ids (tktail_list_metric_sets). |
| `includeParsedRecords` | boolean |  |  | Also records.jsonl - each record parsed, its fields (default true). |
| `note` | string |  | at most 2000 characters |  |
| `linkIncidentId` | string |  |  | An incident's occurrenceId. |
| `destination` | object |  |  | Also copy the package into this folder below an enabled Investigation Root. |
| `waitMs` | integer |  | 0..5000 |  |
| `fullFileSourceId` | string |  |  | An open file (sourceId): the WHOLE file as evidence, redacted and compressed, on its own (no searchId / evidenceRefs) - only when the whole log is really asked for. |

### `tktail_list_evidence`

The evidence packages in TKTail's Evidence Store, newest first (offset / limit 1-100, default 20): packageId, created, note, sources, time range, size, hits, redacted + replacements, linked incident, the archive's SHA-256, whether an AI client asked to delete it. Also "capturing" - captures still running (not preserved yet) - and "failed" - recent captures that ended WITHOUT a package (failed or cancelled; kept across restarts for up to 30 days, the newest 50): packageId, failureCode, reason, startedAt / endedAt, the search number of the run that asked. Only "packages" are preserved evidence. Metadata only - no evidence content. Read-only.

*Read-only*

| Argument | Type | Required | Bounds | Description |
|---|---|---|---|---|
| `offset` | integer |  | 0.. |  |
| `limit` | integer |  | 1..100 |  |

### `tktail_get_evidence`

One package's manifest as a summary (created by, TKTail version, search, context, time range, redaction summary per rule, sources with their state and notes, hits with their record, line when known and range, artifacts with size and SHA-256, limitations, the archive's path and SHA-256) - and with "artifact" (a path from "artifacts") a bounded fragment of that file: "offset" / "maxBytes" (1024-65536, default 16384, whole lines where possible; nextOffset / hasMore page on). For records.jsonl, "fields" returns only those fields of each record. What is returned is the stored package - redacted when it was captured. A file larger than 64 MiB is not paged: its path is given. A capture still running: the answer waits up to "waitMs" (0-5000, default 3000) for it to end, then answers the package (state saved) - or its progress when the time ran out (state capturing, preserved false: call again; no need to wait in between). A capture that ended without a package answers state failed or cancelled, preserved false, failureCode and reason - also after a restart. Read-only.

*Read-only*

| Argument | Type | Required | Bounds | Description |
|---|---|---|---|---|
| `packageId` | string | yes |  |  |
| `artifact` | string |  |  |  |
| `offset` | integer |  | 0.. |  |
| `maxBytes` | integer |  | 1024..65536 |  |
| `fields` | array |  | at most 32 items |  |
| `maxHits` | integer |  | 0..200 |  |
| `waitMs` | integer |  | 0..5000 |  |

### `tktail_verify_evidence`

Reads the package's archive and checks it: its SHA-256 against the one recorded when it was saved, the ZIP structure and CRCs, the manifest's schema, every file's presence, size and SHA-256. Verdict VALID, MODIFIED, INCOMPLETE or UNSUPPORTED (a newer TKTail's package, left as it is) with the problems found. Hashes show the package is unchanged since TKTail wrote it - not who made it. Read-only.

*Read-only*

| Argument | Type | Required | Bounds | Description |
|---|---|---|---|---|
| `packageId` | string | yes |  |  |

### `tktail_delete_evidence`

Asks the user to delete an evidence package: TKTail records the request and shows it in the Evidence Library, where the user confirms or rejects it - an AI client never deletes evidence itself, and the package stays until the user decides. Needs Allow AI to save evidence and pin searches. Ask the user before calling this.

*Changes data - needs "Allow AI to save evidence and pin searches" · records a deletion REQUEST in the Evidence Store's catalog and tells the user; nothing is deleted until the user confirms it in TKTail*

| Argument | Type | Required | Bounds | Description |
|---|---|---|---|---|
| `packageId` | string | yes |  |  |
| `reason` | string |  | at most 500 characters |  |

## Metrics

### `tktail_list_metrics`

Lists every metric TKTail collects or still keeps history of (Windows performance counters the user's Metrics Views and alerts collect): metricId, canonical English name, alias, unit, state (collecting at intervalMs, or stopped - history kept, no current value), the latest sample (time UTC, quality, value only when valid), stale, the retained history span and the Metrics Views showing it. Use a metricId with tktail_get_metric_current / _history / _summary. Read-only.

*Read-only · needs Trial or Pro (Performance counters (Metrics))*

No arguments.

### `tktail_get_metric_current`

A metric's latest sample: time (UTC and this machine's local time), quality (Valid, Warmup, Missing, Denied, Error) and the value with its unit - value is null unless the sample is Valid (never a zero for a missing reading). isCurrent is true only when TKTail collects it now, the sample is valid and not stale; a stopped metric says so. Read-only.

*Read-only · needs Trial or Pro (Performance counters (Metrics))*

| Argument | Type | Required | Bounds | Description |
|---|---|---|---|---|
| `metricId` | string | yes |  | From tktail_list_metrics. |

### `tktail_get_metric_history`

A metric's kept samples in an interval, oldest first: each {t: UTC time, v: value} - v null with q (quality) when the sample has no value; afterGap / processRestarted mark discontinuities. No interpolation: gaps (noSamples, processRestarted, noValue) are listed explicitly. The interval: from (+ to, default now), lastSeconds (default 300), or around {time, seconds} - times like "2026-10-09T10:00:00" (this machine's wall clock, as logs write it) or with "Z" / an offset; at most 24 hours. Bounded: maxSamples (default 300, at most 2000) - truncated / nextFrom page on; for long intervals prefer tktail_get_metric_summary. historyStartsAt says when TKTail's kept history begins (retention). Read-only.

*Read-only · needs Trial or Pro (Performance counters (Metrics))*

| Argument | Type | Required | Bounds | Description |
|---|---|---|---|---|
| `metricId` | string | yes |  | From tktail_list_metrics. |
| `from` | string |  |  | Interval start: "2026-10-09T10:00:00" (local wall clock) or with Z / an offset. |
| `to` | string |  |  | Interval end (default now); only with from. |
| `lastSeconds` | integer |  | 1..86400 | The last N seconds (default 300). |
| `around` | object |  |  | {"time":"2026-10-09T10:00:15","seconds":60}: N seconds on each side of a time (an error's). |
| `maxSamples` | integer |  | 1..2000 | Default 300. |

### `tktail_get_metric_summary`

Summarizes up to 16 metrics over one interval - what CPU, memory and disk did around an error: per metric min / avg / max (raw and formatted with the unit), first / last / delta, the peak and low with their times, valid samples and samples without a value (warmup, missing, denied, error), gaps and gap seconds, and historyStartsAt when the kept history begins later than the interval. Only valid samples count - nothing is assumed for gaps. metricIds: the metrics (default: every metric TKTail keeps, at most 16). The interval as tktail_get_metric_history. Read-only.

*Read-only · needs Trial or Pro (Performance counters (Metrics))*

| Argument | Type | Required | Bounds | Description |
|---|---|---|---|---|
| `metricIds` | array |  | at most 16 items | From tktail_list_metrics (default: all kept, at most 16). |
| `from` | string |  |  |  |
| `to` | string |  |  |  |
| `lastSeconds` | integer |  | 1..86400 |  |
| `around` | object |  |  |  |

### `tktail_list_metric_sets`

Lists the Metric Sets TKTail offers - named groups of Windows performance counters: the built-in ones (Host Basics, System Pressure, Process Diagnostics, Disk & I/O, Network) and the user's own. Each with its id, name, description, how many metrics, its binding (none; a process or an instance chosen when the user applies it), how many of its metrics TKTail collects now and how many Metrics Views show it. TKTail collects only what the user opened - an AI client reads, it never starts collection. Read-only.

*Read-only · needs Trial or Pro (Performance counters (Metrics))*

No arguments.

### `tktail_get_metric_set`

One Metric Set with its metrics: each metric's metricId and canonical English name (object \ counter, instance) - the identity; the alias and this Windows's localized name are display only - its unit (unit for people: "%", "bytes", "bytes/s", "/s", "s", "count"; unitKey / unitKind the canonical word: count, percent, bytes, bytesPerSecond, perSecond, seconds), "definition" - the metric exactly as tktail_save_metric_set and an alert's metric source take it - and whether TKTail collects it now. Read-only.

*Read-only · needs Trial or Pro (Performance counters (Metrics))*

| Argument | Type | Required | Bounds | Description |
|---|---|---|---|---|
| `id` | string | yes |  | A Metric Set id from tktail_list_metric_sets ("builtin:host", "set-..."). |

### `tktail_save_metric_set`

Saves a Metric Set of the user's (name, description, metrics: 1-64 definitions - object, counter, instance in English; provider (pdh) and unit (count / percent / bytes / bytesPerSecond / perSecond / seconds) may be left out: TKTail infers the unit from the counter; a "definition" from tktail_list_metrics / tktail_get_metric_set can be copied as it is), or changes one (metricSetId with expectedContent = its contentId as you read it; built-in sets never change). Needs Allow AI to save searches and Metric Sets, and the Metrics feature (Trial / Pro). A set is what to observe - never samples, and saving one starts no collection; alerts and Metrics Views use it.

*Changes data - needs "Allow AI to save searches and Metric Sets" · needs Trial or Pro (Performance counters (Metrics))*

| Argument | Type | Required | Bounds | Description |
|---|---|---|---|---|
| `name` | string | yes | at most 64 characters |  |
| `description` | string |  |  |  |
| `metrics` | array | yes | at most 64 items |  |
| `metricSetId` | string |  |  |  |
| `expectedContent` | string |  |  | Changing a set: its contentId as you read it. |

### `tktail_delete_metric_set`

Deletes a Metric Set of the user's (metricSetId, expectedContent = its contentId as you read it). Needs Allow AI to save searches and Metric Sets. Built-in sets cannot be deleted. Ask the user first.

*Changes data - needs "Allow AI to save searches and Metric Sets"*

| Argument | Type | Required | Bounds | Description |
|---|---|---|---|---|
| `metricSetId` | string | yes |  |  |
| `expectedContent` | string | yes |  |  |

## Formats

### `tktail_list_formats`

Lists the log formats TKTail knows - favorite (and favoriteOrder) marks the user's favorites: the built-in ones (formatId "builtin:&lt;key&gt;" - JSON Lines, IIS W3C, application logs, syslog, CSV, ...) with their category, family, what works for them (fields, structured search, multi-line records, live) and file extensions; and the user-defined format profiles ("custom:&lt;id&gt;") with enabled, usable, state, profileVersion, framing, record types, field count and error / warning counts. kind: builtin, custom or all (default). Read-only.

*Read-only · answers without a running TKTail window too*

| Argument | Type | Required | Bounds | Description |
|---|---|---|---|---|
| `kind` | string |  | `builtin` / `custom` / `all` |  |

### `tktail_get_format`

One format by formatId. Built-in: its description, capabilities, extensions and notes - immutable (a user-defined profile can be made from a sample). User-defined: its state and diagnostics, field ids and field-schema fingerprint, the profile regex dialect, and its whole definition (the JSON TKTail stores - the form tktail_validate_format and tktail_preview_format take). usedBy: the open sources it is in force for. Read-only.

*Read-only · answers without a running TKTail window too*

| Argument | Type | Required | Bounds | Description |
|---|---|---|---|---|
| `formatId` | string | yes |  | "builtin:&lt;key&gt;" or "custom:&lt;id&gt;" from tktail_list_formats. |

### `tktail_detect_format`

How TKTail decides a log's format, with the actual detector. For an open source (sourceId): the format in force and how it was chosen (View As, a .tktail rule, a profile's file association, detected, fallback), what detection alone would choose, conflicts, the resolution chain, and the detector's candidates with confidence (0-100, level) and evidence - or why each was rejected. For your own text (sample: {text, fileName}): what TKTail would use for such a file (content and file name only). Both list the user-defined profiles whose file name or content rules claim it; with a draft definition, whether its fileMatch would. Read-only.

*Read-only · answers without a running TKTail window too*

| Argument | Type | Required | Bounds | Description |
|---|---|---|---|---|
| `sourceId` | string |  |  |  |
| `sample` | object |  |  |  |
| `definition` | object |  |  | Optional: a draft format profile whose fileMatch to test. |

### `tktail_preview_format`

Runs a format over sample records with TKTail's actual pipeline and shows the result per record: for a profile (a draft definition, or an installed custom:&lt;id&gt;) the Custom Format Studio's preview - framing into records, outcome (match, partial, noMatch), record type (and the candidates with explain or when ambiguous), fallback, every field (id, raw, parsed, type, role, state extracted / missing / notCaptured / conditionFalse / conversionFailed, note), the Summary, issues and slow records; for a built-in (builtin:&lt;key&gt;) the viewer's framing, parse and Summary. Plus totals and the definition's diagnostics. The sample: an open source's records (sourceId, from / line) or your own text (sample: {text, fileName}). maxRecords 1-50 (10), maxFields 1-64 (24), maxFieldBytes 64-2048 (256). Nothing is saved or applied. Read-only.

*Read-only · answers without a running TKTail window too*

| Argument | Type | Required | Bounds | Description |
|---|---|---|---|---|
| `definition` | object |  |  | A draft format profile (JSON). |
| `formatId` | string |  |  | An installed format: builtin:&lt;key&gt; or custom:&lt;id&gt;. |
| `sourceId` | string |  |  |  |
| `from` | string |  | `start` / `end` |  |
| `line` | integer |  | 1.. |  |
| `sample` | object |  |  |  |
| `maxRecords` | integer |  | 1..50 |  |
| `maxFields` | integer |  | 1..64 |  |
| `maxFieldBytes` | integer |  | 64..2048 |  |
| `explain` | boolean |  |  | List every record type's candidate result. |

### `tktail_new_format_draft`

Returns a valid starting definition for a user-defined format profile. With sourceId (an open log): from that log's detected format - a delimited log (CSV comma / semicolon, TAB, pipe) gives its own separator, quoting, header and one field per column (columns numbered from 1, in "columns"), so a profile only gives the columns their meaning (role timestamp / severity / message / correlation ..., type) - one parser, nothing re-implemented. Otherwise from a template: lineBased (one record per line: timestamp, level, message), multiline (records start with a timestamp; following lines such as stack traces belong to them; the default), cloneAppLog (TKTail's built-in application-log shape, declaratively - built-in formats themselves are immutable) or delimited (CSV / TSV / ';' / '\|' columns: framing kind delimited with delimiter, quote, escape doubled / backslash / none, header; fields read columns by number - group 1 is the first column - or by header name). id (3-64: a lowercase letter, then a-z 0-9 . _ -) and name are optional. Nothing is saved: you keep and edit the JSON - envelope.pattern (ECMAScript with (?&lt;name&gt;...) groups), fields (id, group, type text / integer / decimal / boolean / timestamp / durationMs / enum, role timestamp / severity / message / logger / thread / correlation / duration / ..., values), recordTypes (match / extract, fallback), framing (line / multiline with recordStart / delimited with delimiter), fileMatch (extensions, names, content) - then check it with tktail_validate_format and tktail_preview_format against the log's own records.

*Read-only · answers without a running TKTail window too*

| Argument | Type | Required | Bounds | Description |
|---|---|---|---|---|
| `template` | string |  | `lineBased` / `multiline` / `cloneAppLog` / `delimited` |  |
| `id` | string |  |  |  |
| `name` | string |  | at most 100 characters |  |
| `sourceId` | string |  |  | An open log the draft starts from (its detected format). |

### `tktail_validate_format`

Validates a user-defined format profile (a JSON definition: id, name, fileMatch, framing, envelope pattern, fields, recordTypes, severity, presentation - docs CUSTOM_FORMATS) with TKTail's own parser and compiler: schema, ids and references, field types and roles, predicates and every regex (the profile dialect: ECMAScript with (?&lt;name&gt;...) groups, bounded as in the Custom Format Studio). Returns valid, diagnostics (severity, path such as recordTypes[1].match.pattern, message, position in the pattern), the field ids and schema fingerprint, and whether a profile with that id is installed (its version). Nothing is saved. Read-only.

*Read-only · answers without a running TKTail window too*

| Argument | Type | Required | Bounds | Description |
|---|---|---|---|---|
| `definition` | object | yes |  | The format profile JSON. |

### `tktail_save_format`

Saves a user-defined format profile into TKTail's Custom Formats - only when the user allowed AI clients to save formats (Tools &gt; Allow AI to Save Custom Formats; otherwise not_allowed - the user can import the draft in the Custom Format Studio instead). Validate and preview it first: a definition with errors is refused and nothing is written. A new id is saved as version 1; to replace an installed profile pass replacesVersion = its current profileVersion (tktail_get_format) - if it changed since, the save is refused (conflict), never overwritten. TKTail chooses where it is stored; built-in formats are never changed. applyToSourceId puts it in force for that open log (as View As, for this session). Returns the formatId, the new profileVersion, whether the field schema changed (removedFields) and warnings. favorite: true also lists it first among the user's favorite formats - only when the user asked for that. Ask the user before saving.

*Changes data - needs "Allow AI to save custom formats"*

| Argument | Type | Required | Bounds | Description |
|---|---|---|---|---|
| `definition` | object | yes |  | The format profile JSON (validated again before writing). |
| `replacesVersion` | integer |  | 1.. | Replacing an installed profile: its current profileVersion. |
| `applyToSourceId` | string |  |  | An open log file to use the saved profile for (View As, this session). |
| `favorite` | boolean |  |  | Mark it as a favorite format - only when the user asked. |

## Extended Investigation

### `tktail_list_investigation_roots`

Extended Investigation: the folders the user approved for AI investigation beyond what is open in TKTail (Investigation Roots - only the user adds or enables them, in TKTail: Tools &gt; AI Investigation Roots...). Each with its rootId, path, label, enabled and whether it is usable now. extendedInvestigation.available is false without the license capability (Trial and Pro include it) - then only the Safe Workspace (what is open) is searched. Below a usable root: tktail_discover_files, tktail_search with {"kind":"folder","path":...}, tktail_open_source. Read-only.

*Read-only · to see the roots (without it the answer says Extended Investigation is not available): Trial or Pro (Extended AI investigation (MCP))*

No arguments.

### `tktail_discover_files`

Lists the files below an Investigation Root (or a folder below it) that match file masks - as a folder search would take them - each with its path, relative path, size, modified time (UTC), the format TKTail would read it as, binary (skipped by searches; not openable) and its sourceId when it is open. Links (junctions, symbolic links) are never followed or listed. Bounded: maxFiles 1-1000 (200), at most 5,000 folders listed and 10 s; truncated / incomplete / limitReason (maxFiles, maxDirectories, time) say what is missing. include / exclude: "*.log;u_ex*.log", "**\archive\**"; recursive (default true); probe false skips the format probe. Read-only.

*Read-only · needs Trial or Pro (Extended AI investigation (MCP))*

| Argument | Type | Required | Bounds | Description |
|---|---|---|---|---|
| `rootId` | string | yes |  | From tktail_list_investigation_roots. |
| `folder` | string |  |  | An absolute folder below that root (default: the root). |
| `include` | string |  |  |  |
| `exclude` | string |  |  |  |
| `recursive` | boolean |  |  |  |
| `maxFiles` | integer |  | 1..1000 |  |
| `probe` | boolean |  |  |  |

---

The HTML page: https://tktail.dev/help/mcp-tools/
