{
  "$comment": "Generated by tools/gen-mcp-reference.py from the tools TKTail.exe serves (tools/list) and docs/ai/mcp-tool-policy.json - do not edit. The Help page: https://tktail.dev/help/mcp-tools/",
  "schemaVersion": 1,
  "product": "TKTail",
  "productVersion": "1.2.1",
  "server": {
    "name": "tktail",
    "command": "TKTail.exe mcp --stdio"
  },
  "protocolVersions": {
    "current": "2026-07-28",
    "handshake": [
      "2025-11-25",
      "2025-06-18",
      "2025-03-26",
      "2024-11-05"
    ]
  },
  "registry": {
    "toolCount": 50,
    "digest": "sha256:26ba0e740309265d2668dc6ac11d62774ba2f97e3dd11655c503c41441ff957d"
  },
  "transports": [
    {
      "id": "stdio",
      "start": "TKTail.exe mcp --stdio",
      "capability": "mcp-workspace",
      "summary": "Every edition. The client starts TKTail.exe mcp --stdio; it relays to the running TKTail window (the Primary) after the user allowed AI access (setting mcp.allowWindow). Without a running window it answers on its own: status, formats and samples, no sources."
    },
    {
      "id": "http",
      "start": "POST http://127.0.0.1:47711/mcp (the default address) with Authorization: Bearer <token>",
      "capability": "mcp-http",
      "summary": "Trial and Pro. Streamable HTTP from the running Primary window, off by default (Settings > AI Access (MCP) > Accept AI clients over HTTP, setting mcp.http.enabled), this computer only unless the user chose the network, plain HTTP with a bearer token on every request; the same tools and the same window gate as stdio."
    }
  ],
  "capabilities": {
    "mcp-extended": {
      "name": "Extended AI investigation (MCP)",
      "editions": [
        "trial",
        "pro-personal",
        "pro-business"
      ]
    },
    "mcp-http": {
      "name": "AI clients over HTTP (MCP)",
      "editions": [
        "trial",
        "pro-personal",
        "pro-business"
      ]
    },
    "mcp-workspace": {
      "name": "AI integration (MCP)",
      "editions": [
        "free",
        "trial",
        "pro-personal",
        "pro-business"
      ]
    },
    "metrics": {
      "name": "Performance counters (Metrics)",
      "editions": [
        "trial",
        "pro-personal",
        "pro-business"
      ]
    }
  },
  "consents": {
    "mcp.allowWindow": "Allow AI access (MCP) - Settings > AI Access (MCP) or Tools > Allow AI Access (MCP); off by default; every tool that reads the window's sources",
    "mcp.allowFormatSave": "Allow AI to save custom formats - never over a built-in format; needs AI access",
    "mcp.allowSearchSave": "Allow AI to save searches and Metric Sets - Saved Searches and the user's Metric Sets, never the built-in ones; needs AI access",
    "mcp.allowAlertManage": "Allow AI to manage alerts - create, change, enable, disable and delete alerts on sources AI clients may read; needs AI access",
    "mcp.allowEvidenceSave": "Allow AI to save evidence and pin searches - redacted packages in the Evidence Store, within its limits, and pinned searches kept across restarts; off by default (ADR-049: AI access alone writes nothing durable); deleting a package is only a request the user confirms in TKTail; needs AI access"
  },
  "errorCategories": {
    "invalid_arguments": "an argument is missing, of the wrong type or unknown",
    "access_off": "the user has not allowed AI access (mcp.allowWindow)",
    "capability_unavailable": "the license does not include the capability (Metrics, Investigation Roots, HTTP)",
    "unavailable": "no running TKTail window, not the Primary, or it is closing",
    "busy": "the window did not answer in time, or a bound was reached - retry later",
    "source_not_found": "no open source with this sourceId",
    "stale_source": "the reference belongs to an older state of the source",
    "not_found": "no such search, saved search, metric set, format, event or metric",
    "no_context": "nothing is selected in the window",
    "scope_not_allowed": "the path is neither an open source nor below an approved Investigation Root",
    "unsupported": "the source kind cannot answer this (e.g. a Metrics View as a record source)",
    "not_allowed": "the user's consent for this change is off, or the object is the user's own",
    "conflict": "the stored version or content changed - read it again",
    "time_not_indexed": "the source has no time index yet (indexTimes starts one)",
    "time_indexing": "the time index is being built",
    "no_record_times": "the source's records have no timestamps",
    "response_too_large": "the answer exceeds the response budget - ask for fewer items",
    "internal": "an unexpected failure"
  },
  "tools": [
    {
      "name": "tktail_status",
      "title": "TKTail status",
      "category": "Status and sources",
      "description": "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.",
      "readOnly": true,
      "capability": "mcp-workspace",
      "window": "optional",
      "annotations": {
        "title": "TKTail status",
        "readOnlyHint": true,
        "destructiveHint": false,
        "idempotentHint": true,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {},
        "additionalProperties": false
      }
    },
    {
      "name": "tktail_list_instances",
      "title": "List TKTail windows",
      "category": "Status and sources",
      "description": "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.",
      "readOnly": true,
      "capability": "mcp-workspace",
      "window": "optional",
      "annotations": {
        "title": "List TKTail windows",
        "readOnlyHint": true,
        "destructiveHint": false,
        "idempotentHint": true,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {},
        "additionalProperties": false
      }
    },
    {
      "name": "tktail_list_sources",
      "title": "List open investigation sources",
      "category": "Status and sources",
      "description": "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.",
      "readOnly": true,
      "capability": "mcp-workspace",
      "window": "optional",
      "annotations": {
        "title": "List open investigation sources",
        "readOnlyHint": true,
        "destructiveHint": false,
        "idempotentHint": true,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {
          "kinds": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "file",
                "eventlog",
                "metrics"
              ]
            },
            "description": "Only these kinds (default: all)."
          },
          "limit": {
            "type": "integer",
            "minimum": 1,
            "maximum": 500,
            "description": "At most this many sources (default 200)."
          }
        },
        "additionalProperties": false
      }
    },
    {
      "name": "tktail_get_current_context",
      "title": "Get the user's current evidence",
      "category": "Status and sources",
      "description": "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.",
      "readOnly": true,
      "capability": "mcp-workspace",
      "window": "optional",
      "annotations": {
        "title": "Get the user's current evidence",
        "readOnlyHint": true,
        "destructiveHint": false,
        "idempotentHint": true,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {
          "maxTextBytes": {
            "type": "integer",
            "minimum": 0,
            "maximum": 65536,
            "description": "The record's text, at most this many UTF-8 bytes (default 16384; 0: no text)."
          },
          "maxFields": {
            "type": "integer",
            "minimum": 0,
            "maximum": 256,
            "description": "At most this many parsed fields (default 64)."
          },
          "maxFieldBytes": {
            "type": "integer",
            "minimum": 64,
            "maximum": 8192,
            "description": "Each field value, at most this many UTF-8 bytes (default 2048)."
          }
        },
        "additionalProperties": false
      }
    },
    {
      "name": "tktail_open_source",
      "title": "Open a log below a root",
      "category": "Status and sources",
      "description": "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).",
      "readOnly": true,
      "capability": "mcp-extended",
      "window": "required",
      "sideEffects": "opens the file as a paused tab in the window",
      "annotations": {
        "title": "Open a log below a root",
        "readOnlyHint": true,
        "destructiveHint": false,
        "idempotentHint": true,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {
          "path": {
            "type": "string",
            "description": "An absolute file path from tktail_discover_files."
          }
        },
        "required": [
          "path"
        ],
        "additionalProperties": false
      }
    },
    {
      "name": "tktail_get_source_sample",
      "title": "Get raw sample records of a log",
      "category": "Status and sources",
      "description": "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.",
      "readOnly": true,
      "capability": "mcp-workspace",
      "window": "required",
      "annotations": {
        "title": "Get raw sample records of a log",
        "readOnlyHint": true,
        "destructiveHint": false,
        "idempotentHint": true,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {
          "sourceId": {
            "type": "string",
            "description": "An open log file (tktail_list_sources)."
          },
          "from": {
            "type": "string",
            "enum": [
              "start",
              "end"
            ]
          },
          "line": {
            "type": "integer",
            "minimum": 1
          },
          "records": {
            "type": "integer",
            "minimum": 1,
            "maximum": 200
          },
          "maxRecordBytes": {
            "type": "integer",
            "minimum": 64,
            "maximum": 16384
          },
          "maxBytes": {
            "type": "integer",
            "minimum": 1024,
            "maximum": 65536
          }
        },
        "required": [
          "sourceId"
        ],
        "additionalProperties": false
      }
    },
    {
      "name": "tktail_get_record",
      "title": "Get one logical record",
      "category": "Records",
      "description": "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.",
      "readOnly": true,
      "capability": "mcp-workspace",
      "window": "required",
      "annotations": {
        "title": "Get one logical record",
        "readOnlyHint": true,
        "destructiveHint": false,
        "idempotentHint": true,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {
          "evidenceRef": {
            "type": "object",
            "description": "A record or event reference exactly as TKTail returned it (current context, a search result, another record) - pass it back unchanged."
          },
          "sourceId": {
            "type": "string",
            "description": "An open source (tktail_list_sources), with line, byteOffset or recordId."
          },
          "line": {
            "type": "integer",
            "minimum": 1,
            "description": "A 1-based line of a file: the record containing it."
          },
          "byteOffset": {
            "type": "integer",
            "minimum": 0,
            "description": "A byte position in a file: the record containing it."
          },
          "recordId": {
            "type": "integer",
            "minimum": 0,
            "description": "An event's EventRecordID (event log sources)."
          },
          "maxTextBytes": {
            "type": "integer",
            "minimum": 0,
            "maximum": 65536,
            "description": "The record's text, at most this many UTF-8 bytes (default 16384)."
          },
          "maxFields": {
            "type": "integer",
            "minimum": 0,
            "maximum": 256,
            "description": "At most this many parsed fields (default 64)."
          },
          "maxFieldBytes": {
            "type": "integer",
            "minimum": 64,
            "maximum": 8192,
            "description": "Each field value, at most this many UTF-8 bytes (default 2048)."
          }
        },
        "additionalProperties": false
      }
    },
    {
      "name": "tktail_get_records_around",
      "title": "Get the records around evidence",
      "category": "Records",
      "description": "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.",
      "readOnly": true,
      "capability": "mcp-workspace",
      "window": "required",
      "sideEffects": "indexTimes: true starts a background time index of the source",
      "annotations": {
        "title": "Get the records around evidence",
        "readOnlyHint": true,
        "destructiveHint": false,
        "idempotentHint": true,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {
          "anchor": {
            "type": "string",
            "enum": [
              "current"
            ],
            "description": "The record the user is on (the default when no other anchor is given)."
          },
          "evidenceRef": {
            "type": "object",
            "description": "A record or event reference exactly as TKTail returned it (current context, a search result, another record) - pass it back unchanged."
          },
          "sourceId": {
            "type": "string",
            "description": "An open source, with one of line, byteOffset, recordId or time."
          },
          "line": {
            "type": "integer",
            "minimum": 1
          },
          "byteOffset": {
            "type": "integer",
            "minimum": 0
          },
          "recordId": {
            "type": "integer",
            "minimum": 0
          },
          "time": {
            "type": "string",
            "description": "\"2026-10-06T04:49:10\" (wall clock, as most logs write it) or with \"Z\" / an offset (an instant)."
          },
          "before": {
            "type": "integer",
            "minimum": 0,
            "maximum": 50,
            "description": "Records before the anchor (default 5)."
          },
          "after": {
            "type": "integer",
            "minimum": 0,
            "maximum": 50,
            "description": "Records after the anchor (default 5)."
          },
          "beforeSeconds": {
            "type": "integer",
            "minimum": 0,
            "maximum": 3600,
            "description": "A time window: the records up to this many seconds before the anchor's time."
          },
          "afterSeconds": {
            "type": "integer",
            "minimum": 0,
            "maximum": 3600,
            "description": "... and after it."
          },
          "maxTextBytes": {
            "type": "integer",
            "minimum": 0,
            "maximum": 8192,
            "description": "Each record's text, at most this many UTF-8 bytes (default 512)."
          },
          "maxFields": {
            "type": "integer",
            "minimum": 0,
            "maximum": 64,
            "description": "Fields per record (default 8)."
          },
          "maxFieldBytes": {
            "type": "integer",
            "minimum": 64,
            "maximum": 2048,
            "description": "Each field value, at most this many UTF-8 bytes (default 256)."
          },
          "indexTimes": {
            "type": "boolean",
            "description": "With time: let TKTail read the file's remaining record times in the background (default false)."
          }
        },
        "additionalProperties": false
      }
    },
    {
      "name": "tktail_search",
      "title": "Search the open sources",
      "category": "Search",
      "description": "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\":\"<sourceId>\"} = 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.",
      "readOnly": true,
      "capability": "mcp-workspace",
      "alsoNeeds": [
        {
          "capability": "mcp-extended",
          "when": "a folder scope below an Investigation Root"
        }
      ],
      "window": "required",
      "sideEffects": "starts an AI search session, shown in Search Results and Jobs (at most 5 kept)",
      "annotations": {
        "title": "Search the open sources",
        "readOnlyHint": true,
        "destructiveHint": false,
        "idempotentHint": true,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {
          "definition": {
            "type": "object",
            "description": "A TKTail search definition: {\"sources\":[{\"kind\":\"open\"}],\"predicate\":{...}} (schemaVersion and regexDialect may be omitted)."
          },
          "waitMs": {
            "type": "integer",
            "minimum": 0,
            "maximum": 5000,
            "description": "Wait up to this long for the search to finish (default 2000)."
          },
          "maxResults": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100,
            "description": "Results in this answer (default 20; 0: none)."
          },
          "withFields": {
            "type": "boolean",
            "description": "Each file result with its record's severity and first fields (default false)."
          },
          "fields": {
            "type": "array",
            "maxItems": 32,
            "items": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "description": "Projection: each file result with only these fields of its record, as \"values\" {name: value, or null when the record has none}."
          },
          "preview": {
            "type": "boolean",
            "description": "false: no preview text in the results - smaller pages (default true)."
          },
          "aggregate": {
            "type": "object",
            "description": "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.",
            "properties": {
              "groupBy": {
                "type": "array",
                "maxItems": 4,
                "items": {
                  "anyOf": [
                    {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 256
                    },
                    {
                      "type": "object",
                      "required": [
                        "input"
                      ],
                      "description": "A value mapping (tktail_aggregate)."
                    }
                  ]
                }
              },
              "top": {
                "type": "integer",
                "minimum": 1,
                "maximum": 1000
              },
              "order": {
                "type": "string",
                "enum": [
                  "count",
                  "sum",
                  "max",
                  "min",
                  "avg"
                ]
              },
              "bucket": {
                "type": "string",
                "pattern": "^[0-9]{1,7}[smhd]$"
              },
              "number": {
                "anyOf": [
                  {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  },
                  {
                    "type": "object",
                    "required": [
                      "input"
                    ]
                  }
                ]
              }
            },
            "additionalProperties": false
          }
        },
        "required": [
          "definition"
        ],
        "additionalProperties": false
      }
    },
    {
      "name": "tktail_get_search",
      "title": "Get a search's state",
      "category": "Search",
      "description": "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 > 0 adds a page of results. Read-only.",
      "readOnly": true,
      "capability": "mcp-workspace",
      "window": "required",
      "annotations": {
        "title": "Get a search's state",
        "readOnlyHint": true,
        "destructiveHint": false,
        "idempotentHint": true,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {
          "searchId": {
            "type": "integer",
            "minimum": 1
          },
          "waitMs": {
            "type": "integer",
            "minimum": 0,
            "maximum": 5000,
            "description": "Wait up to this long for a running search (default 0)."
          },
          "maxResults": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100,
            "description": "Results to include (default 0)."
          },
          "offset": {
            "type": "integer",
            "minimum": 0
          },
          "withFields": {
            "type": "boolean"
          },
          "fields": {
            "type": "array",
            "maxItems": 32,
            "items": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "description": "Projection: each file result with only these fields of its record, as \"values\" {name: value, or null when the record has none}."
          },
          "preview": {
            "type": "boolean",
            "description": "false: no preview text in the results - smaller pages (default true)."
          }
        },
        "additionalProperties": false
      }
    },
    {
      "name": "tktail_get_search_results",
      "title": "Page a search's results",
      "category": "Search",
      "description": "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.",
      "readOnly": true,
      "capability": "mcp-workspace",
      "window": "required",
      "annotations": {
        "title": "Page a search's results",
        "readOnlyHint": true,
        "destructiveHint": false,
        "idempotentHint": true,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {
          "searchId": {
            "type": "integer",
            "minimum": 1
          },
          "offset": {
            "type": "integer",
            "minimum": 0,
            "description": "Default 0."
          },
          "maxResults": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100,
            "description": "Default 20."
          },
          "withFields": {
            "type": "boolean"
          },
          "fields": {
            "type": "array",
            "maxItems": 32,
            "items": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "description": "Projection: each file result with only these fields of its record, as \"values\" {name: value, or null when the record has none}."
          },
          "preview": {
            "type": "boolean",
            "description": "false: no preview text in the results - smaller pages (default true)."
          }
        },
        "required": [
          "searchId"
        ],
        "additionalProperties": false
      }
    },
    {
      "name": "tktail_cancel_search",
      "title": "Cancel an AI client's search",
      "category": "Search",
      "description": "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.",
      "readOnly": true,
      "capability": "mcp-workspace",
      "window": "required",
      "sideEffects": "stops one of the client's own searches (the user's searches answer not_allowed)",
      "annotations": {
        "title": "Cancel an AI client's search",
        "readOnlyHint": true,
        "destructiveHint": false,
        "idempotentHint": true,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {
          "searchId": {
            "type": "integer",
            "minimum": 1
          }
        },
        "required": [
          "searchId"
        ],
        "additionalProperties": false
      }
    },
    {
      "name": "tktail_aggregate",
      "title": "Count, group and sum a search's results",
      "category": "Search",
      "description": "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=(?<u>\\\\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=(?<ms>\\\\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.",
      "readOnly": true,
      "capability": "mcp-workspace",
      "window": "required",
      "annotations": {
        "title": "Count, group and sum a search's results",
        "readOnlyHint": true,
        "destructiveHint": false,
        "idempotentHint": true,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {
          "searchId": {
            "type": "integer",
            "minimum": 1,
            "description": "A finished search (tktail_search, tktail_get_search)."
          },
          "analysisId": {
            "type": "integer",
            "minimum": 1,
            "description": "An analysis already started: its answer (alone, with waitMs)."
          },
          "groupBy": {
            "type": "array",
            "maxItems": 4,
            "items": {
              "anyOf": [
                {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 256,
                  "description": "A field name."
                },
                {
                  "$ref": "#/$defs/mapping"
                }
              ]
            }
          },
          "top": {
            "type": "integer",
            "minimum": 1,
            "maximum": 1000,
            "description": "Groups in the answer (default 10)."
          },
          "order": {
            "type": "string",
            "enum": [
              "count",
              "sum",
              "max",
              "min",
              "avg"
            ],
            "description": "How the top groups are chosen (default count; the others need a number)."
          },
          "bucket": {
            "type": "string",
            "pattern": "^[0-9]{1,7}[smhd]$",
            "description": "A histogram bucket: 1s to 1d (\"1m\", \"5m\", \"1h\")."
          },
          "number": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 256,
                "description": "A field name."
              },
              {
                "$ref": "#/$defs/mapping"
              }
            ]
          },
          "waitMs": {
            "type": "integer",
            "minimum": 0,
            "maximum": 5000,
            "description": "Wait up to this long for the analysis (default 2000)."
          }
        },
        "additionalProperties": false,
        "$defs": {
          "mapping": {
            "type": "object",
            "properties": {
              "input": {
                "type": "string",
                "enum": [
                  "field",
                  "message",
                  "text"
                ]
              },
              "field": {
                "type": "string"
              },
              "extract": {
                "type": "string",
                "enum": [
                  "whole",
                  "regex",
                  "after",
                  "delimited",
                  "substring",
                  "pathSegment",
                  "queryParameter"
                ]
              },
              "pattern": {
                "type": "string"
              },
              "group": {
                "type": "string"
              },
              "case": {
                "type": "boolean"
              },
              "text": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "index": {
                "type": "integer",
                "minimum": 0
              },
              "length": {
                "type": "integer",
                "minimum": 0
              },
              "normalize": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "op": {
                      "type": "string",
                      "enum": [
                        "trim",
                        "lower",
                        "upper",
                        "removePrefix",
                        "number"
                      ]
                    },
                    "text": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "op"
                  ],
                  "additionalProperties": false
                }
              }
            },
            "required": [
              "input"
            ],
            "additionalProperties": false
          }
        }
      }
    },
    {
      "name": "tktail_list_saved_searches",
      "title": "List Saved Searches",
      "category": "Search",
      "description": "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.",
      "readOnly": true,
      "capability": "mcp-workspace",
      "window": "optional",
      "annotations": {
        "title": "List Saved Searches",
        "readOnlyHint": true,
        "destructiveHint": false,
        "idempotentHint": true,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {
          "limit": {
            "type": "integer",
            "minimum": 1,
            "maximum": 500,
            "description": "Default 100."
          }
        },
        "additionalProperties": false
      }
    },
    {
      "name": "tktail_get_saved_search",
      "title": "Get a Saved Search",
      "category": "Search",
      "description": "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.",
      "readOnly": true,
      "capability": "mcp-workspace",
      "window": "required",
      "annotations": {
        "title": "Get a Saved Search",
        "readOnlyHint": true,
        "destructiveHint": false,
        "idempotentHint": true,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          }
        },
        "required": [
          "id"
        ],
        "additionalProperties": false
      }
    },
    {
      "name": "tktail_run_saved_search",
      "title": "Run a Saved Search",
      "category": "Search",
      "description": "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.",
      "readOnly": true,
      "capability": "mcp-workspace",
      "window": "required",
      "sideEffects": "starts a new AI search session from a copy of the Saved Search",
      "annotations": {
        "title": "Run a Saved Search",
        "readOnlyHint": true,
        "destructiveHint": false,
        "idempotentHint": true,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "waitMs": {
            "type": "integer",
            "minimum": 0,
            "maximum": 5000,
            "description": "Default 2000."
          },
          "maxResults": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100,
            "description": "Default 20."
          },
          "withFields": {
            "type": "boolean"
          },
          "fields": {
            "type": "array",
            "maxItems": 32,
            "items": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "description": "Projection: each file result with only these fields of its record, as \"values\" {name: value, or null when the record has none}."
          },
          "preview": {
            "type": "boolean",
            "description": "false: no preview text in the results - smaller pages (default true)."
          },
          "aggregate": {
            "type": "object",
            "description": "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.",
            "properties": {
              "groupBy": {
                "type": "array",
                "maxItems": 4,
                "items": {
                  "anyOf": [
                    {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 256
                    },
                    {
                      "type": "object",
                      "required": [
                        "input"
                      ],
                      "description": "A value mapping (tktail_aggregate)."
                    }
                  ]
                }
              },
              "top": {
                "type": "integer",
                "minimum": 1,
                "maximum": 1000
              },
              "order": {
                "type": "string",
                "enum": [
                  "count",
                  "sum",
                  "max",
                  "min",
                  "avg"
                ]
              },
              "bucket": {
                "type": "string",
                "pattern": "^[0-9]{1,7}[smhd]$"
              },
              "number": {
                "anyOf": [
                  {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  },
                  {
                    "type": "object",
                    "required": [
                      "input"
                    ]
                  }
                ]
              }
            },
            "additionalProperties": false
          }
        },
        "required": [
          "id"
        ],
        "additionalProperties": false
      }
    },
    {
      "name": "tktail_save_search",
      "title": "Save a search",
      "category": "Search",
      "description": "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 > AI Access > 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.",
      "readOnly": false,
      "capability": "mcp-workspace",
      "alsoNeeds": [
        {
          "capability": "mcp-extended",
          "when": "paths below an Investigation Root"
        }
      ],
      "consent": "mcp.allowSearchSave",
      "window": "required",
      "annotations": {
        "title": "Save a search",
        "readOnlyHint": false,
        "destructiveHint": true,
        "idempotentHint": false,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {
          "definition": {
            "$ref": "#/$defs/definition"
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "description": {
            "type": "string"
          },
          "savedSearchId": {
            "type": "string"
          },
          "expectedVersion": {
            "type": "integer",
            "minimum": 1
          }
        },
        "required": [
          "definition",
          "name"
        ],
        "additionalProperties": false,
        "$defs": {
          "alert": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 100
              },
              "enabled": {
                "type": "boolean",
                "description": "Default true."
              },
              "severity": {
                "type": "string",
                "enum": [
                  "info",
                  "warning",
                  "error",
                  "critical"
                ],
                "description": "Default warning."
              },
              "condition": {
                "$ref": "#/$defs/definition"
              },
              "evaluation": {
                "type": "object",
                "properties": {
                  "mode": {
                    "type": "string",
                    "enum": [
                      "newData"
                    ]
                  }
                },
                "additionalProperties": false,
                "description": "newData (the default, the only mode): what arrives after the alert is armed."
              },
              "trigger": {
                "type": "object",
                "description": "How matches become incidents; omitted members take their defaults.",
                "properties": {
                  "kind": {
                    "type": "string",
                    "enum": [
                      "everyMatch",
                      "firstMatch",
                      "oncePerInterval",
                      "aggregate"
                    ],
                    "description": "everyMatch: each match batch; firstMatch: once, then counted until re-armed; oncePerInterval: at most one per intervalMs; aggregate (default): the first at once, then one summary per intervalMs."
                  },
                  "intervalMs": {
                    "type": "integer",
                    "minimum": 100,
                    "maximum": 3600000,
                    "description": "Default 5000."
                  },
                  "cooldownMs": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 86400000,
                    "description": "Default 60000: a trigger this soon after the previous incident joins it (its match count grows) - a storm is one incident."
                  }
                },
                "additionalProperties": false
              },
              "actions": {
                "type": "array",
                "uniqueItems": true,
                "items": {
                  "type": "string",
                  "enum": [
                    "notify",
                    "tray",
                    "sound",
                    "foreground"
                  ]
                },
                "description": "Default [\"notify\",\"tray\"]. Never a program, a script or a shell command."
              },
              "detail": {
                "type": "string",
                "enum": [
                  "matchingText",
                  "ruleNameOnly"
                ],
                "description": "What a notification shows (default matchingText)."
              },
              "capture": {
                "type": "object",
                "description": "Evidence kept when it fires (bounded).",
                "properties": {
                  "items": {
                    "type": "array",
                    "maxItems": 16,
                    "items": {
                      "$ref": "#/$defs/evidence"
                    }
                  }
                },
                "required": [
                  "items"
                ],
                "additionalProperties": false
              }
            },
            "required": [
              "name",
              "condition"
            ],
            "additionalProperties": false
          },
          "definition": {
            "type": "object",
            "description": "A TKTail search definition (what tktail_search takes).",
            "properties": {
              "schemaVersion": {
                "type": "integer",
                "enum": [
                  1,
                  2
                ],
                "description": "Optional (TKTail's current version)."
              },
              "regexDialect": {
                "type": "string",
                "enum": [
                  "tktail-regex-1"
                ],
                "description": "Optional."
              },
              "sources": {
                "type": "array",
                "minItems": 1,
                "maxItems": 16,
                "items": {
                  "$ref": "#/$defs/source"
                }
              },
              "predicate": {
                "$ref": "#/$defs/predicate"
              },
              "sequence": {
                "type": "object",
                "description": "A temporal sequence (see tktail_search) - searched; an alert does not evaluate one live."
              }
            },
            "required": [
              "sources",
              "predicate"
            ],
            "additionalProperties": false
          },
          "source": {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "open",
                  "source",
                  "folder",
                  "session",
                  "metric"
                ],
                "description": "An alert watches \"source\" files and \"metric\" counters (open sources, folders and sessions are searched, not watched)."
              },
              "path": {
                "type": "string",
                "description": "source: a sourceId from tktail_list_sources (or the file's path, an event log's address); folder: an absolute folder below an Investigation Root."
              },
              "series": {
                "type": "string",
                "description": "source, a file: the dated series it belongs to - the logical source an alert follows (app_{YYYY-MM-DD}.log, u_ex{YYMMDD}.log, app.{YYYYMMDD}.{N}.log; dates {YYYYMMDD} {YYYY-MM-DD} {YYYY_MM_DD} {YYYY.MM.DD} {DD-MM-YYYY} {DD_MM_YYYY} {DD.MM.YYYY} {YYMMDD}, times {HH} {HHmm} {HHmmss} {HH-mm} {HH-mm-ss}, {N} a number). Left out for a sourceId TKTail follows as a series (tktail_list_sources file.rotation): TKTail fills it in. \"\": exactly this file."
              },
              "recursive": {
                "type": "boolean"
              },
              "include": {
                "type": "string",
                "description": "folder: file masks (*.log;u_ex*.log)."
              },
              "exclude": {
                "type": "string"
              },
              "formats": {
                "type": "array",
                "maxItems": 16,
                "items": {
                  "type": "string"
                },
                "description": "Only these formats (builtin:<key>, custom:<id>)."
              },
              "session": {
                "type": "integer",
                "minimum": 1
              },
              "metric": {
                "type": "object",
                "description": "A Windows performance counter by its English names - copy a \"definition\" from tktail_list_metrics / tktail_get_metric_set.",
                "properties": {
                  "object": {
                    "type": "string",
                    "minLength": 1,
                    "description": "English object name: Processor, Memory, Process, LogicalDisk, Network Interface ..."
                  },
                  "counter": {
                    "type": "string",
                    "minLength": 1,
                    "description": "English counter name: % Processor Time, Available Bytes ..."
                  },
                  "instance": {
                    "type": "string",
                    "description": "The instance (_Total, a process name, C:); leave out for an object without instances."
                  },
                  "provider": {
                    "type": "string",
                    "enum": [
                      "pdh"
                    ],
                    "description": "Optional: pdh (Windows Performance Counters - the only provider)."
                  },
                  "unit": {
                    "type": "string",
                    "enum": [
                      "count",
                      "percent",
                      "bytes",
                      "bytesPerSecond",
                      "perSecond",
                      "seconds"
                    ],
                    "description": "Optional: TKTail infers it from the counter's name as its counter picker does."
                  },
                  "policy": {
                    "type": "string",
                    "enum": [
                      "fixed",
                      "followName",
                      "pinPid"
                    ],
                    "description": "Process instances: followName (by name, restarts marked), fixed, pinPid (one process: with pid). Only for the Process object; default fixed."
                  },
                  "pid": {
                    "type": "integer",
                    "minimum": 1,
                    "description": "policy pinPid only."
                  },
                  "scale": {
                    "type": "number",
                    "exclusiveMinimum": 0,
                    "description": "A multiplier of the raw value (default 1)."
                  },
                  "normalize": {
                    "type": "string",
                    "enum": [
                      "none",
                      "machine"
                    ],
                    "description": "machine: divided by the processor count (a process's CPU)."
                  },
                  "name": {
                    "type": "string",
                    "maxLength": 1024,
                    "description": "A label of its own."
                  },
                  "counterSet": {
                    "type": "string",
                    "description": "A PerfLib V2 counter set GUID, when TKTail listed one."
                  },
                  "localized": {
                    "type": "boolean",
                    "description": "The names are this Windows's localized ones (as TKTail listed them)."
                  }
                },
                "required": [
                  "object",
                  "counter"
                ],
                "additionalProperties": false
              }
            },
            "required": [
              "kind"
            ],
            "additionalProperties": false
          },
          "predicate": {
            "type": "object",
            "description": "A group (all / any) or one condition; a condition alone is taken as all of it. A metric condition is never combined with record conditions.",
            "properties": {
              "all": {
                "type": "array",
                "maxItems": 32,
                "items": {
                  "$ref": "#/$defs/predicate"
                }
              },
              "any": {
                "type": "array",
                "maxItems": 32,
                "items": {
                  "$ref": "#/$defs/predicate"
                }
              },
              "text": {
                "type": "string",
                "description": "Literal text on a line."
              },
              "regex": {
                "type": "string",
                "description": "tktail-regex-1 (PCRE2, bounded)."
              },
              "case": {
                "type": "boolean",
                "description": "With text / regex: match case."
              },
              "field": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1
                  },
                  "op": {
                    "type": "string",
                    "enum": [
                      "exists",
                      "eq",
                      "ne",
                      "contains",
                      "startsWith",
                      "endsWith",
                      "gt",
                      "ge",
                      "lt",
                      "le",
                      "missing",
                      "isNull",
                      "isNotNull"
                    ]
                  },
                  "value": {
                    "type": "string",
                    "description": "Compared as a number when both sides are numbers (gt ge lt le)."
                  },
                  "case": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "name",
                  "op"
                ],
                "additionalProperties": false
              },
              "time": {
                "type": "object",
                "properties": {
                  "from": {
                    "type": "string"
                  },
                  "to": {
                    "type": "string"
                  },
                  "last": {
                    "type": "integer",
                    "minimum": 1,
                    "description": "Seconds before now (relative: an alert's only kind of time range)."
                  }
                },
                "additionalProperties": false
              },
              "source": {
                "type": "integer",
                "minimum": 0,
                "description": "The record came from sources[i]."
              },
              "metric": {
                "$ref": "#/$defs/metricCondition"
              }
            },
            "minProperties": 1,
            "additionalProperties": false
          },
          "metricCondition": {
            "type": "object",
            "description": "Compares a metric source's samples, in its canonical unit (percent, bytes). aggregate latest (default): the newest valid sample - forMs makes it sustained (every sample of the last forMs valid and satisfying it); avg / min / max: of the valid samples of the last windowMs (required) - forMs applies to latest only (an aggregate has its window). An invalid sample never satisfies a condition.",
            "properties": {
              "source": {
                "type": "integer",
                "minimum": 0,
                "description": "sources[i] of kind metric."
              },
              "op": {
                "type": "string",
                "enum": [
                  "gt",
                  "ge",
                  "lt",
                  "le",
                  "eq",
                  "ne"
                ]
              },
              "value": {
                "type": "number"
              },
              "aggregate": {
                "type": "string",
                "enum": [
                  "latest",
                  "avg",
                  "min",
                  "max"
                ]
              },
              "windowMs": {
                "type": "integer",
                "minimum": 1000,
                "maximum": 3600000
              },
              "forMs": {
                "type": "integer",
                "minimum": 1000,
                "maximum": 3600000
              }
            },
            "required": [
              "source",
              "op",
              "value"
            ],
            "additionalProperties": false,
            "if": {
              "properties": {
                "aggregate": {
                  "enum": [
                    "avg",
                    "min",
                    "max"
                  ]
                }
              },
              "required": [
                "aggregate"
              ]
            },
            "then": {
              "required": [
                "windowMs"
              ],
              "not": {
                "required": [
                  "forMs"
                ]
              }
            },
            "else": {
              "not": {
                "required": [
                  "windowMs"
                ]
              }
            }
          },
          "evidence": {
            "type": "object",
            "description": "One item to keep: file records (path left out: the trigger's file), an event log's time window (path: a channel such as System), or metric samples (set or metrics) - each bounded.",
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "file",
                  "eventLog",
                  "metrics"
                ]
              },
              "path": {
                "type": "string"
              },
              "recordsBefore": {
                "type": "integer",
                "minimum": 0,
                "maximum": 500
              },
              "recordsAfter": {
                "type": "integer",
                "minimum": 0,
                "maximum": 500
              },
              "beforeMs": {
                "type": "integer",
                "minimum": 0,
                "maximum": 3600000
              },
              "afterMs": {
                "type": "integer",
                "minimum": 0,
                "maximum": 3600000
              },
              "levels": {
                "type": "array",
                "items": {
                  "type": "string",
                  "enum": [
                    "critical",
                    "error",
                    "warning",
                    "information",
                    "verbose"
                  ]
                }
              },
              "providers": {
                "type": "array",
                "maxItems": 8,
                "items": {
                  "type": "string"
                }
              },
              "set": {
                "type": "string",
                "description": "A Metric Set id (builtin:host, set-...)."
              },
              "metrics": {
                "type": "array",
                "maxItems": 32,
                "items": {
                  "type": "object",
                  "description": "A Windows performance counter by its English names - copy a \"definition\" from tktail_list_metrics / tktail_get_metric_set.",
                  "properties": {
                    "object": {
                      "type": "string",
                      "minLength": 1,
                      "description": "English object name: Processor, Memory, Process, LogicalDisk, Network Interface ..."
                    },
                    "counter": {
                      "type": "string",
                      "minLength": 1,
                      "description": "English counter name: % Processor Time, Available Bytes ..."
                    },
                    "instance": {
                      "type": "string",
                      "description": "The instance (_Total, a process name, C:); leave out for an object without instances."
                    },
                    "provider": {
                      "type": "string",
                      "enum": [
                        "pdh"
                      ],
                      "description": "Optional: pdh (Windows Performance Counters - the only provider)."
                    },
                    "unit": {
                      "type": "string",
                      "enum": [
                        "count",
                        "percent",
                        "bytes",
                        "bytesPerSecond",
                        "perSecond",
                        "seconds"
                      ],
                      "description": "Optional: TKTail infers it from the counter's name as its counter picker does."
                    },
                    "policy": {
                      "type": "string",
                      "enum": [
                        "fixed",
                        "followName",
                        "pinPid"
                      ],
                      "description": "Process instances: followName (by name, restarts marked), fixed, pinPid (one process: with pid). Only for the Process object; default fixed."
                    },
                    "pid": {
                      "type": "integer",
                      "minimum": 1,
                      "description": "policy pinPid only."
                    },
                    "scale": {
                      "type": "number",
                      "exclusiveMinimum": 0,
                      "description": "A multiplier of the raw value (default 1)."
                    },
                    "normalize": {
                      "type": "string",
                      "enum": [
                        "none",
                        "machine"
                      ],
                      "description": "machine: divided by the processor count (a process's CPU)."
                    },
                    "name": {
                      "type": "string",
                      "maxLength": 1024,
                      "description": "A label of its own."
                    },
                    "counterSet": {
                      "type": "string",
                      "description": "A PerfLib V2 counter set GUID, when TKTail listed one."
                    },
                    "localized": {
                      "type": "boolean",
                      "description": "The names are this Windows's localized ones (as TKTail listed them)."
                    }
                  },
                  "required": [
                    "object",
                    "counter"
                  ],
                  "additionalProperties": false
                }
              }
            },
            "required": [
              "kind"
            ],
            "additionalProperties": false
          }
        },
        "examples": [
          {
            "name": "Timeouts",
            "description": "Every timeout of the service",
            "definition": {
              "sources": [
                {
                  "kind": "source",
                  "path": "<sourceId>"
                }
              ],
              "predicate": {
                "any": [
                  {
                    "text": "timeout"
                  },
                  {
                    "regex": "conn(ection)? refused"
                  }
                ]
              }
            }
          }
        ]
      }
    },
    {
      "name": "tktail_delete_saved_search",
      "title": "Delete a Saved Search",
      "category": "Search",
      "description": "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.",
      "readOnly": false,
      "capability": "mcp-workspace",
      "consent": "mcp.allowSearchSave",
      "window": "required",
      "annotations": {
        "title": "Delete a Saved Search",
        "readOnlyHint": false,
        "destructiveHint": true,
        "idempotentHint": false,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {
          "savedSearchId": {
            "type": "string"
          },
          "expectedVersion": {
            "type": "integer",
            "minimum": 1
          }
        },
        "required": [
          "savedSearchId",
          "expectedVersion"
        ],
        "additionalProperties": false,
        "examples": [
          {
            "savedSearchId": "<savedSearchId>",
            "expectedVersion": 1
          }
        ]
      }
    },
    {
      "name": "tktail_list_alerts",
      "title": "List alerts",
      "category": "Alerts and incidents",
      "description": "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.",
      "readOnly": true,
      "capability": "mcp-workspace",
      "window": "required",
      "annotations": {
        "title": "List alerts",
        "readOnlyHint": true,
        "destructiveHint": false,
        "idempotentHint": true,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {
          "limit": {
            "type": "integer",
            "minimum": 1,
            "maximum": 500,
            "description": "Default 100."
          }
        },
        "additionalProperties": false
      }
    },
    {
      "name": "tktail_get_alert",
      "title": "Get an alert",
      "category": "Alerts and incidents",
      "description": "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.",
      "readOnly": true,
      "capability": "mcp-workspace",
      "window": "required",
      "annotations": {
        "title": "Get an alert",
        "readOnlyHint": true,
        "destructiveHint": false,
        "idempotentHint": true,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {
          "alertId": {
            "type": "string"
          },
          "alertNumber": {
            "type": "integer",
            "minimum": 0
          }
        },
        "additionalProperties": false
      }
    },
    {
      "name": "tktail_list_alert_occurrences",
      "title": "List alert incidents",
      "category": "Alerts and incidents",
      "description": "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 < warning < error < 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.",
      "readOnly": true,
      "capability": "mcp-workspace",
      "window": "required",
      "annotations": {
        "title": "List alert incidents",
        "readOnlyHint": true,
        "destructiveHint": false,
        "idempotentHint": true,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {
          "alertId": {
            "type": "string"
          },
          "alertNumber": {
            "type": "integer",
            "minimum": 0
          },
          "from": {
            "type": "string",
            "description": "UTC: \"2026-10-09T10:00:00Z\"."
          },
          "to": {
            "type": "string"
          },
          "states": {
            "type": "array",
            "items": {
              "enum": [
                "capturing",
                "complete",
                "partial",
                "failed"
              ]
            }
          },
          "severities": {
            "type": "array",
            "items": {
              "enum": [
                "info",
                "warning",
                "error",
                "critical"
              ]
            }
          },
          "minSeverity": {
            "enum": [
              "info",
              "warning",
              "error",
              "critical"
            ],
            "description": "This severity and higher."
          },
          "newOnly": {
            "type": "boolean"
          },
          "text": {
            "type": "string"
          },
          "offset": {
            "type": "integer",
            "minimum": 0
          },
          "limit": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100
          }
        },
        "additionalProperties": false
      }
    },
    {
      "name": "tktail_get_alert_occurrence",
      "title": "Get an alert incident",
      "category": "Alerts and incidents",
      "description": "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.",
      "readOnly": true,
      "capability": "mcp-workspace",
      "window": "required",
      "annotations": {
        "title": "Get an alert incident",
        "readOnlyHint": true,
        "destructiveHint": false,
        "idempotentHint": true,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {
          "occurrenceId": {
            "type": "string"
          },
          "maxTextBytes": {
            "type": "integer",
            "minimum": 256,
            "maximum": 16384,
            "description": "The trigger record's text, default 4096."
          }
        },
        "required": [
          "occurrenceId"
        ],
        "additionalProperties": false
      }
    },
    {
      "name": "tktail_get_occurrence_evidence",
      "title": "Read an incident's evidence",
      "category": "Alerts and incidents",
      "description": "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.",
      "readOnly": true,
      "capability": "mcp-workspace",
      "window": "required",
      "annotations": {
        "title": "Read an incident's evidence",
        "readOnlyHint": true,
        "destructiveHint": false,
        "idempotentHint": true,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {
          "occurrenceId": {
            "type": "string"
          },
          "item": {
            "type": "integer",
            "minimum": 1,
            "maximum": 16
          },
          "offset": {
            "type": "integer",
            "minimum": 0
          },
          "limit": {
            "type": "integer",
            "minimum": 1,
            "maximum": 200
          },
          "maxTextBytes": {
            "type": "integer",
            "minimum": 256,
            "maximum": 16384
          }
        },
        "required": [
          "occurrenceId"
        ],
        "additionalProperties": false
      }
    },
    {
      "name": "tktail_validate_alert",
      "title": "Check a proposed alert",
      "category": "Alerts and incidents",
      "description": "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.",
      "readOnly": true,
      "capability": "mcp-workspace",
      "alsoNeeds": [
        {
          "capability": "metrics",
          "when": "a metric alert or metric evidence"
        }
      ],
      "window": "required",
      "annotations": {
        "title": "Check a proposed alert",
        "readOnlyHint": true,
        "destructiveHint": false,
        "idempotentHint": true,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {
          "alert": {
            "$ref": "#/$defs/alert"
          }
        },
        "required": [
          "alert"
        ],
        "additionalProperties": false,
        "$defs": {
          "alert": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 100
              },
              "enabled": {
                "type": "boolean",
                "description": "Default true."
              },
              "severity": {
                "type": "string",
                "enum": [
                  "info",
                  "warning",
                  "error",
                  "critical"
                ],
                "description": "Default warning."
              },
              "condition": {
                "$ref": "#/$defs/definition"
              },
              "evaluation": {
                "type": "object",
                "properties": {
                  "mode": {
                    "type": "string",
                    "enum": [
                      "newData"
                    ]
                  }
                },
                "additionalProperties": false,
                "description": "newData (the default, the only mode): what arrives after the alert is armed."
              },
              "trigger": {
                "type": "object",
                "description": "How matches become incidents; omitted members take their defaults.",
                "properties": {
                  "kind": {
                    "type": "string",
                    "enum": [
                      "everyMatch",
                      "firstMatch",
                      "oncePerInterval",
                      "aggregate"
                    ],
                    "description": "everyMatch: each match batch; firstMatch: once, then counted until re-armed; oncePerInterval: at most one per intervalMs; aggregate (default): the first at once, then one summary per intervalMs."
                  },
                  "intervalMs": {
                    "type": "integer",
                    "minimum": 100,
                    "maximum": 3600000,
                    "description": "Default 5000."
                  },
                  "cooldownMs": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 86400000,
                    "description": "Default 60000: a trigger this soon after the previous incident joins it (its match count grows) - a storm is one incident."
                  }
                },
                "additionalProperties": false
              },
              "actions": {
                "type": "array",
                "uniqueItems": true,
                "items": {
                  "type": "string",
                  "enum": [
                    "notify",
                    "tray",
                    "sound",
                    "foreground"
                  ]
                },
                "description": "Default [\"notify\",\"tray\"]. Never a program, a script or a shell command."
              },
              "detail": {
                "type": "string",
                "enum": [
                  "matchingText",
                  "ruleNameOnly"
                ],
                "description": "What a notification shows (default matchingText)."
              },
              "capture": {
                "type": "object",
                "description": "Evidence kept when it fires (bounded).",
                "properties": {
                  "items": {
                    "type": "array",
                    "maxItems": 16,
                    "items": {
                      "$ref": "#/$defs/evidence"
                    }
                  }
                },
                "required": [
                  "items"
                ],
                "additionalProperties": false
              }
            },
            "required": [
              "name",
              "condition"
            ],
            "additionalProperties": false
          },
          "definition": {
            "type": "object",
            "description": "A TKTail search definition (what tktail_search takes).",
            "properties": {
              "schemaVersion": {
                "type": "integer",
                "enum": [
                  1,
                  2
                ],
                "description": "Optional (TKTail's current version)."
              },
              "regexDialect": {
                "type": "string",
                "enum": [
                  "tktail-regex-1"
                ],
                "description": "Optional."
              },
              "sources": {
                "type": "array",
                "minItems": 1,
                "maxItems": 16,
                "items": {
                  "$ref": "#/$defs/source"
                }
              },
              "predicate": {
                "$ref": "#/$defs/predicate"
              },
              "sequence": {
                "type": "object",
                "description": "A temporal sequence (see tktail_search) - searched; an alert does not evaluate one live."
              }
            },
            "required": [
              "sources",
              "predicate"
            ],
            "additionalProperties": false
          },
          "source": {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "open",
                  "source",
                  "folder",
                  "session",
                  "metric"
                ],
                "description": "An alert watches \"source\" files and \"metric\" counters (open sources, folders and sessions are searched, not watched)."
              },
              "path": {
                "type": "string",
                "description": "source: a sourceId from tktail_list_sources (or the file's path, an event log's address); folder: an absolute folder below an Investigation Root."
              },
              "series": {
                "type": "string",
                "description": "source, a file: the dated series it belongs to - the logical source an alert follows (app_{YYYY-MM-DD}.log, u_ex{YYMMDD}.log, app.{YYYYMMDD}.{N}.log; dates {YYYYMMDD} {YYYY-MM-DD} {YYYY_MM_DD} {YYYY.MM.DD} {DD-MM-YYYY} {DD_MM_YYYY} {DD.MM.YYYY} {YYMMDD}, times {HH} {HHmm} {HHmmss} {HH-mm} {HH-mm-ss}, {N} a number). Left out for a sourceId TKTail follows as a series (tktail_list_sources file.rotation): TKTail fills it in. \"\": exactly this file."
              },
              "recursive": {
                "type": "boolean"
              },
              "include": {
                "type": "string",
                "description": "folder: file masks (*.log;u_ex*.log)."
              },
              "exclude": {
                "type": "string"
              },
              "formats": {
                "type": "array",
                "maxItems": 16,
                "items": {
                  "type": "string"
                },
                "description": "Only these formats (builtin:<key>, custom:<id>)."
              },
              "session": {
                "type": "integer",
                "minimum": 1
              },
              "metric": {
                "type": "object",
                "description": "A Windows performance counter by its English names - copy a \"definition\" from tktail_list_metrics / tktail_get_metric_set.",
                "properties": {
                  "object": {
                    "type": "string",
                    "minLength": 1,
                    "description": "English object name: Processor, Memory, Process, LogicalDisk, Network Interface ..."
                  },
                  "counter": {
                    "type": "string",
                    "minLength": 1,
                    "description": "English counter name: % Processor Time, Available Bytes ..."
                  },
                  "instance": {
                    "type": "string",
                    "description": "The instance (_Total, a process name, C:); leave out for an object without instances."
                  },
                  "provider": {
                    "type": "string",
                    "enum": [
                      "pdh"
                    ],
                    "description": "Optional: pdh (Windows Performance Counters - the only provider)."
                  },
                  "unit": {
                    "type": "string",
                    "enum": [
                      "count",
                      "percent",
                      "bytes",
                      "bytesPerSecond",
                      "perSecond",
                      "seconds"
                    ],
                    "description": "Optional: TKTail infers it from the counter's name as its counter picker does."
                  },
                  "policy": {
                    "type": "string",
                    "enum": [
                      "fixed",
                      "followName",
                      "pinPid"
                    ],
                    "description": "Process instances: followName (by name, restarts marked), fixed, pinPid (one process: with pid). Only for the Process object; default fixed."
                  },
                  "pid": {
                    "type": "integer",
                    "minimum": 1,
                    "description": "policy pinPid only."
                  },
                  "scale": {
                    "type": "number",
                    "exclusiveMinimum": 0,
                    "description": "A multiplier of the raw value (default 1)."
                  },
                  "normalize": {
                    "type": "string",
                    "enum": [
                      "none",
                      "machine"
                    ],
                    "description": "machine: divided by the processor count (a process's CPU)."
                  },
                  "name": {
                    "type": "string",
                    "maxLength": 1024,
                    "description": "A label of its own."
                  },
                  "counterSet": {
                    "type": "string",
                    "description": "A PerfLib V2 counter set GUID, when TKTail listed one."
                  },
                  "localized": {
                    "type": "boolean",
                    "description": "The names are this Windows's localized ones (as TKTail listed them)."
                  }
                },
                "required": [
                  "object",
                  "counter"
                ],
                "additionalProperties": false
              }
            },
            "required": [
              "kind"
            ],
            "additionalProperties": false
          },
          "predicate": {
            "type": "object",
            "description": "A group (all / any) or one condition; a condition alone is taken as all of it. A metric condition is never combined with record conditions.",
            "properties": {
              "all": {
                "type": "array",
                "maxItems": 32,
                "items": {
                  "$ref": "#/$defs/predicate"
                }
              },
              "any": {
                "type": "array",
                "maxItems": 32,
                "items": {
                  "$ref": "#/$defs/predicate"
                }
              },
              "text": {
                "type": "string",
                "description": "Literal text on a line."
              },
              "regex": {
                "type": "string",
                "description": "tktail-regex-1 (PCRE2, bounded)."
              },
              "case": {
                "type": "boolean",
                "description": "With text / regex: match case."
              },
              "field": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1
                  },
                  "op": {
                    "type": "string",
                    "enum": [
                      "exists",
                      "eq",
                      "ne",
                      "contains",
                      "startsWith",
                      "endsWith",
                      "gt",
                      "ge",
                      "lt",
                      "le",
                      "missing",
                      "isNull",
                      "isNotNull"
                    ]
                  },
                  "value": {
                    "type": "string",
                    "description": "Compared as a number when both sides are numbers (gt ge lt le)."
                  },
                  "case": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "name",
                  "op"
                ],
                "additionalProperties": false
              },
              "time": {
                "type": "object",
                "properties": {
                  "from": {
                    "type": "string"
                  },
                  "to": {
                    "type": "string"
                  },
                  "last": {
                    "type": "integer",
                    "minimum": 1,
                    "description": "Seconds before now (relative: an alert's only kind of time range)."
                  }
                },
                "additionalProperties": false
              },
              "source": {
                "type": "integer",
                "minimum": 0,
                "description": "The record came from sources[i]."
              },
              "metric": {
                "$ref": "#/$defs/metricCondition"
              }
            },
            "minProperties": 1,
            "additionalProperties": false
          },
          "metricCondition": {
            "type": "object",
            "description": "Compares a metric source's samples, in its canonical unit (percent, bytes). aggregate latest (default): the newest valid sample - forMs makes it sustained (every sample of the last forMs valid and satisfying it); avg / min / max: of the valid samples of the last windowMs (required) - forMs applies to latest only (an aggregate has its window). An invalid sample never satisfies a condition.",
            "properties": {
              "source": {
                "type": "integer",
                "minimum": 0,
                "description": "sources[i] of kind metric."
              },
              "op": {
                "type": "string",
                "enum": [
                  "gt",
                  "ge",
                  "lt",
                  "le",
                  "eq",
                  "ne"
                ]
              },
              "value": {
                "type": "number"
              },
              "aggregate": {
                "type": "string",
                "enum": [
                  "latest",
                  "avg",
                  "min",
                  "max"
                ]
              },
              "windowMs": {
                "type": "integer",
                "minimum": 1000,
                "maximum": 3600000
              },
              "forMs": {
                "type": "integer",
                "minimum": 1000,
                "maximum": 3600000
              }
            },
            "required": [
              "source",
              "op",
              "value"
            ],
            "additionalProperties": false,
            "if": {
              "properties": {
                "aggregate": {
                  "enum": [
                    "avg",
                    "min",
                    "max"
                  ]
                }
              },
              "required": [
                "aggregate"
              ]
            },
            "then": {
              "required": [
                "windowMs"
              ],
              "not": {
                "required": [
                  "forMs"
                ]
              }
            },
            "else": {
              "not": {
                "required": [
                  "windowMs"
                ]
              }
            }
          },
          "evidence": {
            "type": "object",
            "description": "One item to keep: file records (path left out: the trigger's file), an event log's time window (path: a channel such as System), or metric samples (set or metrics) - each bounded.",
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "file",
                  "eventLog",
                  "metrics"
                ]
              },
              "path": {
                "type": "string"
              },
              "recordsBefore": {
                "type": "integer",
                "minimum": 0,
                "maximum": 500
              },
              "recordsAfter": {
                "type": "integer",
                "minimum": 0,
                "maximum": 500
              },
              "beforeMs": {
                "type": "integer",
                "minimum": 0,
                "maximum": 3600000
              },
              "afterMs": {
                "type": "integer",
                "minimum": 0,
                "maximum": 3600000
              },
              "levels": {
                "type": "array",
                "items": {
                  "type": "string",
                  "enum": [
                    "critical",
                    "error",
                    "warning",
                    "information",
                    "verbose"
                  ]
                }
              },
              "providers": {
                "type": "array",
                "maxItems": 8,
                "items": {
                  "type": "string"
                }
              },
              "set": {
                "type": "string",
                "description": "A Metric Set id (builtin:host, set-...)."
              },
              "metrics": {
                "type": "array",
                "maxItems": 32,
                "items": {
                  "type": "object",
                  "description": "A Windows performance counter by its English names - copy a \"definition\" from tktail_list_metrics / tktail_get_metric_set.",
                  "properties": {
                    "object": {
                      "type": "string",
                      "minLength": 1,
                      "description": "English object name: Processor, Memory, Process, LogicalDisk, Network Interface ..."
                    },
                    "counter": {
                      "type": "string",
                      "minLength": 1,
                      "description": "English counter name: % Processor Time, Available Bytes ..."
                    },
                    "instance": {
                      "type": "string",
                      "description": "The instance (_Total, a process name, C:); leave out for an object without instances."
                    },
                    "provider": {
                      "type": "string",
                      "enum": [
                        "pdh"
                      ],
                      "description": "Optional: pdh (Windows Performance Counters - the only provider)."
                    },
                    "unit": {
                      "type": "string",
                      "enum": [
                        "count",
                        "percent",
                        "bytes",
                        "bytesPerSecond",
                        "perSecond",
                        "seconds"
                      ],
                      "description": "Optional: TKTail infers it from the counter's name as its counter picker does."
                    },
                    "policy": {
                      "type": "string",
                      "enum": [
                        "fixed",
                        "followName",
                        "pinPid"
                      ],
                      "description": "Process instances: followName (by name, restarts marked), fixed, pinPid (one process: with pid). Only for the Process object; default fixed."
                    },
                    "pid": {
                      "type": "integer",
                      "minimum": 1,
                      "description": "policy pinPid only."
                    },
                    "scale": {
                      "type": "number",
                      "exclusiveMinimum": 0,
                      "description": "A multiplier of the raw value (default 1)."
                    },
                    "normalize": {
                      "type": "string",
                      "enum": [
                        "none",
                        "machine"
                      ],
                      "description": "machine: divided by the processor count (a process's CPU)."
                    },
                    "name": {
                      "type": "string",
                      "maxLength": 1024,
                      "description": "A label of its own."
                    },
                    "counterSet": {
                      "type": "string",
                      "description": "A PerfLib V2 counter set GUID, when TKTail listed one."
                    },
                    "localized": {
                      "type": "boolean",
                      "description": "The names are this Windows's localized ones (as TKTail listed them)."
                    }
                  },
                  "required": [
                    "object",
                    "counter"
                  ],
                  "additionalProperties": false
                }
              }
            },
            "required": [
              "kind"
            ],
            "additionalProperties": false
          }
        },
        "examples": [
          {
            "alert": {
              "name": "Payment timeouts",
              "severity": "error",
              "condition": {
                "sources": [
                  {
                    "kind": "source",
                    "path": "<sourceId>"
                  }
                ],
                "predicate": {
                  "all": [
                    {
                      "text": "timeout"
                    }
                  ]
                }
              },
              "trigger": {
                "kind": "aggregate",
                "intervalMs": 5000,
                "cooldownMs": 60000
              },
              "actions": [
                "notify",
                "tray"
              ],
              "capture": {
                "items": [
                  {
                    "kind": "file",
                    "recordsBefore": 10,
                    "recordsAfter": 10
                  }
                ]
              }
            }
          },
          {
            "alert": {
              "name": "Server errors",
              "severity": "warning",
              "condition": {
                "sources": [
                  {
                    "kind": "source",
                    "path": "<sourceId>"
                  }
                ],
                "predicate": {
                  "all": [
                    {
                      "field": {
                        "name": "level",
                        "op": "eq",
                        "value": "ERROR"
                      }
                    }
                  ]
                }
              },
              "trigger": {
                "kind": "firstMatch"
              }
            }
          },
          {
            "alert": {
              "name": "CPU busy",
              "severity": "critical",
              "condition": {
                "sources": [
                  {
                    "kind": "metric",
                    "metric": {
                      "object": "Processor",
                      "counter": "% Processor Time",
                      "instance": "_Total"
                    }
                  }
                ],
                "predicate": {
                  "all": [
                    {
                      "metric": {
                        "source": 0,
                        "op": "gt",
                        "value": 90,
                        "aggregate": "latest",
                        "forMs": 30000
                      }
                    }
                  ]
                }
              },
              "trigger": {
                "kind": "firstMatch",
                "cooldownMs": 300000
              }
            }
          },
          {
            "alert": {
              "name": "Memory low - 1 min average",
              "condition": {
                "sources": [
                  {
                    "kind": "metric",
                    "metric": {
                      "object": "Memory",
                      "counter": "Available Bytes",
                      "unit": "bytes",
                      "provider": "pdh"
                    }
                  }
                ],
                "predicate": {
                  "all": [
                    {
                      "metric": {
                        "source": 0,
                        "op": "lt",
                        "value": 536870912,
                        "aggregate": "avg",
                        "windowMs": 60000
                      }
                    }
                  ]
                }
              },
              "actions": [
                "notify"
              ]
            }
          }
        ]
      }
    },
    {
      "name": "tktail_save_alert",
      "title": "Create or change an alert",
      "category": "Alerts and incidents",
      "description": "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 > AI Access > 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.",
      "readOnly": false,
      "capability": "mcp-workspace",
      "alsoNeeds": [
        {
          "capability": "metrics",
          "when": "a metric alert or metric evidence"
        }
      ],
      "consent": "mcp.allowAlertManage",
      "window": "required",
      "annotations": {
        "title": "Create or change an alert",
        "readOnlyHint": false,
        "destructiveHint": true,
        "idempotentHint": false,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {
          "alert": {
            "$ref": "#/$defs/alert"
          },
          "alertId": {
            "type": "string"
          },
          "alertNumber": {
            "type": "integer",
            "minimum": 1
          },
          "expectedVersion": {
            "type": "integer",
            "minimum": 1,
            "description": "Changing an alert: the version you read."
          }
        },
        "required": [
          "alert"
        ],
        "additionalProperties": false,
        "$defs": {
          "alert": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 100
              },
              "enabled": {
                "type": "boolean",
                "description": "Default true."
              },
              "severity": {
                "type": "string",
                "enum": [
                  "info",
                  "warning",
                  "error",
                  "critical"
                ],
                "description": "Default warning."
              },
              "condition": {
                "$ref": "#/$defs/definition"
              },
              "evaluation": {
                "type": "object",
                "properties": {
                  "mode": {
                    "type": "string",
                    "enum": [
                      "newData"
                    ]
                  }
                },
                "additionalProperties": false,
                "description": "newData (the default, the only mode): what arrives after the alert is armed."
              },
              "trigger": {
                "type": "object",
                "description": "How matches become incidents; omitted members take their defaults.",
                "properties": {
                  "kind": {
                    "type": "string",
                    "enum": [
                      "everyMatch",
                      "firstMatch",
                      "oncePerInterval",
                      "aggregate"
                    ],
                    "description": "everyMatch: each match batch; firstMatch: once, then counted until re-armed; oncePerInterval: at most one per intervalMs; aggregate (default): the first at once, then one summary per intervalMs."
                  },
                  "intervalMs": {
                    "type": "integer",
                    "minimum": 100,
                    "maximum": 3600000,
                    "description": "Default 5000."
                  },
                  "cooldownMs": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 86400000,
                    "description": "Default 60000: a trigger this soon after the previous incident joins it (its match count grows) - a storm is one incident."
                  }
                },
                "additionalProperties": false
              },
              "actions": {
                "type": "array",
                "uniqueItems": true,
                "items": {
                  "type": "string",
                  "enum": [
                    "notify",
                    "tray",
                    "sound",
                    "foreground"
                  ]
                },
                "description": "Default [\"notify\",\"tray\"]. Never a program, a script or a shell command."
              },
              "detail": {
                "type": "string",
                "enum": [
                  "matchingText",
                  "ruleNameOnly"
                ],
                "description": "What a notification shows (default matchingText)."
              },
              "capture": {
                "type": "object",
                "description": "Evidence kept when it fires (bounded).",
                "properties": {
                  "items": {
                    "type": "array",
                    "maxItems": 16,
                    "items": {
                      "$ref": "#/$defs/evidence"
                    }
                  }
                },
                "required": [
                  "items"
                ],
                "additionalProperties": false
              }
            },
            "required": [
              "name",
              "condition"
            ],
            "additionalProperties": false
          },
          "definition": {
            "type": "object",
            "description": "A TKTail search definition (what tktail_search takes).",
            "properties": {
              "schemaVersion": {
                "type": "integer",
                "enum": [
                  1,
                  2
                ],
                "description": "Optional (TKTail's current version)."
              },
              "regexDialect": {
                "type": "string",
                "enum": [
                  "tktail-regex-1"
                ],
                "description": "Optional."
              },
              "sources": {
                "type": "array",
                "minItems": 1,
                "maxItems": 16,
                "items": {
                  "$ref": "#/$defs/source"
                }
              },
              "predicate": {
                "$ref": "#/$defs/predicate"
              },
              "sequence": {
                "type": "object",
                "description": "A temporal sequence (see tktail_search) - searched; an alert does not evaluate one live."
              }
            },
            "required": [
              "sources",
              "predicate"
            ],
            "additionalProperties": false
          },
          "source": {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "open",
                  "source",
                  "folder",
                  "session",
                  "metric"
                ],
                "description": "An alert watches \"source\" files and \"metric\" counters (open sources, folders and sessions are searched, not watched)."
              },
              "path": {
                "type": "string",
                "description": "source: a sourceId from tktail_list_sources (or the file's path, an event log's address); folder: an absolute folder below an Investigation Root."
              },
              "series": {
                "type": "string",
                "description": "source, a file: the dated series it belongs to - the logical source an alert follows (app_{YYYY-MM-DD}.log, u_ex{YYMMDD}.log, app.{YYYYMMDD}.{N}.log; dates {YYYYMMDD} {YYYY-MM-DD} {YYYY_MM_DD} {YYYY.MM.DD} {DD-MM-YYYY} {DD_MM_YYYY} {DD.MM.YYYY} {YYMMDD}, times {HH} {HHmm} {HHmmss} {HH-mm} {HH-mm-ss}, {N} a number). Left out for a sourceId TKTail follows as a series (tktail_list_sources file.rotation): TKTail fills it in. \"\": exactly this file."
              },
              "recursive": {
                "type": "boolean"
              },
              "include": {
                "type": "string",
                "description": "folder: file masks (*.log;u_ex*.log)."
              },
              "exclude": {
                "type": "string"
              },
              "formats": {
                "type": "array",
                "maxItems": 16,
                "items": {
                  "type": "string"
                },
                "description": "Only these formats (builtin:<key>, custom:<id>)."
              },
              "session": {
                "type": "integer",
                "minimum": 1
              },
              "metric": {
                "type": "object",
                "description": "A Windows performance counter by its English names - copy a \"definition\" from tktail_list_metrics / tktail_get_metric_set.",
                "properties": {
                  "object": {
                    "type": "string",
                    "minLength": 1,
                    "description": "English object name: Processor, Memory, Process, LogicalDisk, Network Interface ..."
                  },
                  "counter": {
                    "type": "string",
                    "minLength": 1,
                    "description": "English counter name: % Processor Time, Available Bytes ..."
                  },
                  "instance": {
                    "type": "string",
                    "description": "The instance (_Total, a process name, C:); leave out for an object without instances."
                  },
                  "provider": {
                    "type": "string",
                    "enum": [
                      "pdh"
                    ],
                    "description": "Optional: pdh (Windows Performance Counters - the only provider)."
                  },
                  "unit": {
                    "type": "string",
                    "enum": [
                      "count",
                      "percent",
                      "bytes",
                      "bytesPerSecond",
                      "perSecond",
                      "seconds"
                    ],
                    "description": "Optional: TKTail infers it from the counter's name as its counter picker does."
                  },
                  "policy": {
                    "type": "string",
                    "enum": [
                      "fixed",
                      "followName",
                      "pinPid"
                    ],
                    "description": "Process instances: followName (by name, restarts marked), fixed, pinPid (one process: with pid). Only for the Process object; default fixed."
                  },
                  "pid": {
                    "type": "integer",
                    "minimum": 1,
                    "description": "policy pinPid only."
                  },
                  "scale": {
                    "type": "number",
                    "exclusiveMinimum": 0,
                    "description": "A multiplier of the raw value (default 1)."
                  },
                  "normalize": {
                    "type": "string",
                    "enum": [
                      "none",
                      "machine"
                    ],
                    "description": "machine: divided by the processor count (a process's CPU)."
                  },
                  "name": {
                    "type": "string",
                    "maxLength": 1024,
                    "description": "A label of its own."
                  },
                  "counterSet": {
                    "type": "string",
                    "description": "A PerfLib V2 counter set GUID, when TKTail listed one."
                  },
                  "localized": {
                    "type": "boolean",
                    "description": "The names are this Windows's localized ones (as TKTail listed them)."
                  }
                },
                "required": [
                  "object",
                  "counter"
                ],
                "additionalProperties": false
              }
            },
            "required": [
              "kind"
            ],
            "additionalProperties": false
          },
          "predicate": {
            "type": "object",
            "description": "A group (all / any) or one condition; a condition alone is taken as all of it. A metric condition is never combined with record conditions.",
            "properties": {
              "all": {
                "type": "array",
                "maxItems": 32,
                "items": {
                  "$ref": "#/$defs/predicate"
                }
              },
              "any": {
                "type": "array",
                "maxItems": 32,
                "items": {
                  "$ref": "#/$defs/predicate"
                }
              },
              "text": {
                "type": "string",
                "description": "Literal text on a line."
              },
              "regex": {
                "type": "string",
                "description": "tktail-regex-1 (PCRE2, bounded)."
              },
              "case": {
                "type": "boolean",
                "description": "With text / regex: match case."
              },
              "field": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1
                  },
                  "op": {
                    "type": "string",
                    "enum": [
                      "exists",
                      "eq",
                      "ne",
                      "contains",
                      "startsWith",
                      "endsWith",
                      "gt",
                      "ge",
                      "lt",
                      "le",
                      "missing",
                      "isNull",
                      "isNotNull"
                    ]
                  },
                  "value": {
                    "type": "string",
                    "description": "Compared as a number when both sides are numbers (gt ge lt le)."
                  },
                  "case": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "name",
                  "op"
                ],
                "additionalProperties": false
              },
              "time": {
                "type": "object",
                "properties": {
                  "from": {
                    "type": "string"
                  },
                  "to": {
                    "type": "string"
                  },
                  "last": {
                    "type": "integer",
                    "minimum": 1,
                    "description": "Seconds before now (relative: an alert's only kind of time range)."
                  }
                },
                "additionalProperties": false
              },
              "source": {
                "type": "integer",
                "minimum": 0,
                "description": "The record came from sources[i]."
              },
              "metric": {
                "$ref": "#/$defs/metricCondition"
              }
            },
            "minProperties": 1,
            "additionalProperties": false
          },
          "metricCondition": {
            "type": "object",
            "description": "Compares a metric source's samples, in its canonical unit (percent, bytes). aggregate latest (default): the newest valid sample - forMs makes it sustained (every sample of the last forMs valid and satisfying it); avg / min / max: of the valid samples of the last windowMs (required) - forMs applies to latest only (an aggregate has its window). An invalid sample never satisfies a condition.",
            "properties": {
              "source": {
                "type": "integer",
                "minimum": 0,
                "description": "sources[i] of kind metric."
              },
              "op": {
                "type": "string",
                "enum": [
                  "gt",
                  "ge",
                  "lt",
                  "le",
                  "eq",
                  "ne"
                ]
              },
              "value": {
                "type": "number"
              },
              "aggregate": {
                "type": "string",
                "enum": [
                  "latest",
                  "avg",
                  "min",
                  "max"
                ]
              },
              "windowMs": {
                "type": "integer",
                "minimum": 1000,
                "maximum": 3600000
              },
              "forMs": {
                "type": "integer",
                "minimum": 1000,
                "maximum": 3600000
              }
            },
            "required": [
              "source",
              "op",
              "value"
            ],
            "additionalProperties": false,
            "if": {
              "properties": {
                "aggregate": {
                  "enum": [
                    "avg",
                    "min",
                    "max"
                  ]
                }
              },
              "required": [
                "aggregate"
              ]
            },
            "then": {
              "required": [
                "windowMs"
              ],
              "not": {
                "required": [
                  "forMs"
                ]
              }
            },
            "else": {
              "not": {
                "required": [
                  "windowMs"
                ]
              }
            }
          },
          "evidence": {
            "type": "object",
            "description": "One item to keep: file records (path left out: the trigger's file), an event log's time window (path: a channel such as System), or metric samples (set or metrics) - each bounded.",
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "file",
                  "eventLog",
                  "metrics"
                ]
              },
              "path": {
                "type": "string"
              },
              "recordsBefore": {
                "type": "integer",
                "minimum": 0,
                "maximum": 500
              },
              "recordsAfter": {
                "type": "integer",
                "minimum": 0,
                "maximum": 500
              },
              "beforeMs": {
                "type": "integer",
                "minimum": 0,
                "maximum": 3600000
              },
              "afterMs": {
                "type": "integer",
                "minimum": 0,
                "maximum": 3600000
              },
              "levels": {
                "type": "array",
                "items": {
                  "type": "string",
                  "enum": [
                    "critical",
                    "error",
                    "warning",
                    "information",
                    "verbose"
                  ]
                }
              },
              "providers": {
                "type": "array",
                "maxItems": 8,
                "items": {
                  "type": "string"
                }
              },
              "set": {
                "type": "string",
                "description": "A Metric Set id (builtin:host, set-...)."
              },
              "metrics": {
                "type": "array",
                "maxItems": 32,
                "items": {
                  "type": "object",
                  "description": "A Windows performance counter by its English names - copy a \"definition\" from tktail_list_metrics / tktail_get_metric_set.",
                  "properties": {
                    "object": {
                      "type": "string",
                      "minLength": 1,
                      "description": "English object name: Processor, Memory, Process, LogicalDisk, Network Interface ..."
                    },
                    "counter": {
                      "type": "string",
                      "minLength": 1,
                      "description": "English counter name: % Processor Time, Available Bytes ..."
                    },
                    "instance": {
                      "type": "string",
                      "description": "The instance (_Total, a process name, C:); leave out for an object without instances."
                    },
                    "provider": {
                      "type": "string",
                      "enum": [
                        "pdh"
                      ],
                      "description": "Optional: pdh (Windows Performance Counters - the only provider)."
                    },
                    "unit": {
                      "type": "string",
                      "enum": [
                        "count",
                        "percent",
                        "bytes",
                        "bytesPerSecond",
                        "perSecond",
                        "seconds"
                      ],
                      "description": "Optional: TKTail infers it from the counter's name as its counter picker does."
                    },
                    "policy": {
                      "type": "string",
                      "enum": [
                        "fixed",
                        "followName",
                        "pinPid"
                      ],
                      "description": "Process instances: followName (by name, restarts marked), fixed, pinPid (one process: with pid). Only for the Process object; default fixed."
                    },
                    "pid": {
                      "type": "integer",
                      "minimum": 1,
                      "description": "policy pinPid only."
                    },
                    "scale": {
                      "type": "number",
                      "exclusiveMinimum": 0,
                      "description": "A multiplier of the raw value (default 1)."
                    },
                    "normalize": {
                      "type": "string",
                      "enum": [
                        "none",
                        "machine"
                      ],
                      "description": "machine: divided by the processor count (a process's CPU)."
                    },
                    "name": {
                      "type": "string",
                      "maxLength": 1024,
                      "description": "A label of its own."
                    },
                    "counterSet": {
                      "type": "string",
                      "description": "A PerfLib V2 counter set GUID, when TKTail listed one."
                    },
                    "localized": {
                      "type": "boolean",
                      "description": "The names are this Windows's localized ones (as TKTail listed them)."
                    }
                  },
                  "required": [
                    "object",
                    "counter"
                  ],
                  "additionalProperties": false
                }
              }
            },
            "required": [
              "kind"
            ],
            "additionalProperties": false
          }
        },
        "examples": [
          {
            "alert": {
              "name": "Payment timeouts",
              "severity": "error",
              "condition": {
                "sources": [
                  {
                    "kind": "source",
                    "path": "<sourceId>"
                  }
                ],
                "predicate": {
                  "all": [
                    {
                      "text": "timeout"
                    }
                  ]
                }
              },
              "trigger": {
                "kind": "aggregate",
                "intervalMs": 5000,
                "cooldownMs": 60000
              },
              "actions": [
                "notify",
                "tray"
              ],
              "capture": {
                "items": [
                  {
                    "kind": "file",
                    "recordsBefore": 10,
                    "recordsAfter": 10
                  }
                ]
              }
            }
          },
          {
            "alert": {
              "name": "Server errors",
              "severity": "warning",
              "condition": {
                "sources": [
                  {
                    "kind": "source",
                    "path": "<sourceId>"
                  }
                ],
                "predicate": {
                  "all": [
                    {
                      "field": {
                        "name": "level",
                        "op": "eq",
                        "value": "ERROR"
                      }
                    }
                  ]
                }
              },
              "trigger": {
                "kind": "firstMatch"
              }
            }
          },
          {
            "alert": {
              "name": "CPU busy",
              "severity": "critical",
              "condition": {
                "sources": [
                  {
                    "kind": "metric",
                    "metric": {
                      "object": "Processor",
                      "counter": "% Processor Time",
                      "instance": "_Total"
                    }
                  }
                ],
                "predicate": {
                  "all": [
                    {
                      "metric": {
                        "source": 0,
                        "op": "gt",
                        "value": 90,
                        "aggregate": "latest",
                        "forMs": 30000
                      }
                    }
                  ]
                }
              },
              "trigger": {
                "kind": "firstMatch",
                "cooldownMs": 300000
              }
            }
          },
          {
            "alert": {
              "name": "Memory low - 1 min average",
              "condition": {
                "sources": [
                  {
                    "kind": "metric",
                    "metric": {
                      "object": "Memory",
                      "counter": "Available Bytes",
                      "unit": "bytes",
                      "provider": "pdh"
                    }
                  }
                ],
                "predicate": {
                  "all": [
                    {
                      "metric": {
                        "source": 0,
                        "op": "lt",
                        "value": 536870912,
                        "aggregate": "avg",
                        "windowMs": 60000
                      }
                    }
                  ]
                }
              },
              "actions": [
                "notify"
              ]
            }
          }
        ]
      }
    },
    {
      "name": "tktail_set_alert_enabled",
      "title": "Enable or disable an alert",
      "category": "Alerts and incidents",
      "description": "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.",
      "readOnly": false,
      "capability": "mcp-workspace",
      "consent": "mcp.allowAlertManage",
      "window": "required",
      "annotations": {
        "title": "Enable or disable an alert",
        "readOnlyHint": false,
        "destructiveHint": true,
        "idempotentHint": false,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {
          "alertId": {
            "type": "string"
          },
          "alertNumber": {
            "type": "integer",
            "minimum": 1
          },
          "enabled": {
            "type": "boolean"
          },
          "expectedVersion": {
            "type": "integer",
            "minimum": 1
          }
        },
        "required": [
          "enabled",
          "expectedVersion"
        ],
        "additionalProperties": false,
        "examples": [
          {
            "alertId": "<alertId>",
            "enabled": false,
            "expectedVersion": 1
          }
        ]
      }
    },
    {
      "name": "tktail_delete_alert",
      "title": "Delete an alert",
      "category": "Alerts and incidents",
      "description": "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.",
      "readOnly": false,
      "capability": "mcp-workspace",
      "consent": "mcp.allowAlertManage",
      "window": "required",
      "annotations": {
        "title": "Delete an alert",
        "readOnlyHint": false,
        "destructiveHint": true,
        "idempotentHint": false,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {
          "alertId": {
            "type": "string"
          },
          "alertNumber": {
            "type": "integer",
            "minimum": 1
          },
          "expectedVersion": {
            "type": "integer",
            "minimum": 1
          }
        },
        "required": [
          "expectedVersion"
        ],
        "additionalProperties": false,
        "examples": [
          {
            "alertId": "<alertId>",
            "expectedVersion": 1
          }
        ]
      }
    },
    {
      "name": "tktail_pin_search",
      "title": "Pin or unpin a search",
      "category": "Evidence",
      "description": "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).",
      "readOnly": false,
      "capability": "mcp-workspace",
      "consent": "mcp.allowEvidenceSave",
      "window": "required",
      "sideEffects": "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",
      "annotations": {
        "title": "Pin or unpin a search",
        "readOnlyHint": false,
        "destructiveHint": false,
        "idempotentHint": false,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {
          "searchId": {
            "type": "integer",
            "minimum": 1
          },
          "pinned": {
            "type": "boolean",
            "description": "true (default): pin; false: unpin."
          },
          "preserveEvidence": {
            "type": "boolean",
            "description": "Also save the results' records now as an evidence package (redacted), while the files still hold them."
          },
          "contextRecords": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1000,
            "description": "With preserveEvidence: records kept on each side of a hit (default 20)."
          }
        },
        "required": [
          "searchId"
        ],
        "additionalProperties": false,
        "examples": [
          {
            "searchId": 17
          },
          {
            "searchId": 17,
            "preserveEvidence": true,
            "contextRecords": 20
          },
          {
            "searchId": 17,
            "pinned": false
          }
        ]
      }
    },
    {
      "name": "tktail_save_evidence",
      "title": "Save evidence before the logs rotate",
      "category": "Evidence",
      "description": "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).",
      "readOnly": false,
      "capability": "mcp-workspace",
      "alsoNeeds": [
        {
          "capability": "metrics",
          "when": "correlatedMetricSets"
        },
        {
          "capability": "mcp-extended",
          "when": "a destination folder below an Investigation Root"
        }
      ],
      "consent": "mcp.allowEvidenceSave",
      "window": "required",
      "sideEffects": "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",
      "annotations": {
        "title": "Save evidence before the logs rotate",
        "readOnlyHint": false,
        "destructiveHint": false,
        "idempotentHint": false,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {
          "searchId": {
            "type": "integer",
            "minimum": 1,
            "description": "A finished search: its results are the hits."
          },
          "results": {
            "type": "array",
            "maxItems": 5000,
            "items": {
              "type": "integer",
              "minimum": 0
            },
            "description": "With searchId: only these result indexes."
          },
          "evidenceRefs": {
            "type": "array",
            "maxItems": 1000,
            "items": {
              "type": "object"
            },
            "description": "evidenceRef objects as TKTail returned them."
          },
          "contextRecordsBefore": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1000
          },
          "contextRecordsAfter": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1000
          },
          "contextTimeBeforeMs": {
            "type": "integer",
            "minimum": 0,
            "maximum": 21600000
          },
          "contextTimeAfterMs": {
            "type": "integer",
            "minimum": 0,
            "maximum": 21600000
          },
          "correlatedSourceIds": {
            "type": "array",
            "maxItems": 16,
            "items": {
              "type": "string"
            },
            "description": "Open files / event logs (tktail_list_sources) for the same window."
          },
          "correlatedChannels": {
            "type": "array",
            "maxItems": 16,
            "items": {
              "type": "string"
            },
            "description": "Windows event log channels by name (\"Application\")."
          },
          "correlatedMetricSets": {
            "type": "array",
            "maxItems": 8,
            "items": {
              "type": "string"
            },
            "description": "Metric Set ids (tktail_list_metric_sets)."
          },
          "includeParsedRecords": {
            "type": "boolean",
            "description": "Also records.jsonl - each record parsed, its fields (default true)."
          },
          "note": {
            "type": "string",
            "maxLength": 2000
          },
          "linkIncidentId": {
            "type": "string",
            "description": "An incident's occurrenceId."
          },
          "destination": {
            "type": "object",
            "properties": {
              "folder": {
                "type": "string"
              }
            },
            "required": [
              "folder"
            ],
            "additionalProperties": false,
            "description": "Also copy the package into this folder below an enabled Investigation Root."
          },
          "waitMs": {
            "type": "integer",
            "minimum": 0,
            "maximum": 5000
          },
          "fullFileSourceId": {
            "type": "string",
            "description": "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."
          }
        },
        "additionalProperties": false,
        "examples": [
          {
            "searchId": 17,
            "contextRecordsBefore": 20,
            "contextRecordsAfter": 20,
            "note": "57 timeouts before the outage"
          },
          {
            "searchId": 17,
            "results": [
              0,
              3,
              9
            ],
            "contextTimeBeforeMs": 15000,
            "contextTimeAfterMs": 15000,
            "correlatedSourceIds": [
              "<sourceId>"
            ],
            "correlatedChannels": [
              "Application"
            ],
            "note": "vendor escalation"
          }
        ]
      }
    },
    {
      "name": "tktail_list_evidence",
      "title": "List saved evidence",
      "category": "Evidence",
      "description": "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.",
      "readOnly": true,
      "capability": "mcp-workspace",
      "window": "required",
      "annotations": {
        "title": "List saved evidence",
        "readOnlyHint": true,
        "destructiveHint": false,
        "idempotentHint": true,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {
          "offset": {
            "type": "integer",
            "minimum": 0
          },
          "limit": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100
          }
        },
        "additionalProperties": false
      }
    },
    {
      "name": "tktail_get_evidence",
      "title": "Read a saved evidence package",
      "category": "Evidence",
      "description": "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.",
      "readOnly": true,
      "capability": "mcp-workspace",
      "window": "required",
      "annotations": {
        "title": "Read a saved evidence package",
        "readOnlyHint": true,
        "destructiveHint": false,
        "idempotentHint": true,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {
          "packageId": {
            "type": "string"
          },
          "artifact": {
            "type": "string"
          },
          "offset": {
            "type": "integer",
            "minimum": 0
          },
          "maxBytes": {
            "type": "integer",
            "minimum": 1024,
            "maximum": 65536
          },
          "fields": {
            "type": "array",
            "maxItems": 32,
            "items": {
              "type": "string"
            }
          },
          "maxHits": {
            "type": "integer",
            "minimum": 0,
            "maximum": 200
          },
          "waitMs": {
            "type": "integer",
            "minimum": 0,
            "maximum": 5000
          }
        },
        "required": [
          "packageId"
        ],
        "additionalProperties": false
      }
    },
    {
      "name": "tktail_verify_evidence",
      "title": "Verify an evidence package",
      "category": "Evidence",
      "description": "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.",
      "readOnly": true,
      "capability": "mcp-workspace",
      "window": "required",
      "annotations": {
        "title": "Verify an evidence package",
        "readOnlyHint": true,
        "destructiveHint": false,
        "idempotentHint": true,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {
          "packageId": {
            "type": "string"
          }
        },
        "required": [
          "packageId"
        ],
        "additionalProperties": false
      }
    },
    {
      "name": "tktail_delete_evidence",
      "title": "Ask to delete an evidence package",
      "category": "Evidence",
      "description": "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.",
      "readOnly": false,
      "capability": "mcp-workspace",
      "consent": "mcp.allowEvidenceSave",
      "window": "required",
      "sideEffects": "records a deletion REQUEST in the Evidence Store's catalog and tells the user; nothing is deleted until the user confirms it in TKTail",
      "annotations": {
        "title": "Ask to delete an evidence package",
        "readOnlyHint": false,
        "destructiveHint": true,
        "idempotentHint": false,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {
          "packageId": {
            "type": "string"
          },
          "reason": {
            "type": "string",
            "maxLength": 500
          }
        },
        "required": [
          "packageId"
        ],
        "additionalProperties": false,
        "examples": [
          {
            "packageId": "<packageId>",
            "reason": "a duplicate of another package"
          }
        ]
      }
    },
    {
      "name": "tktail_list_metrics",
      "title": "List the metrics TKTail keeps",
      "category": "Metrics",
      "description": "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.",
      "readOnly": true,
      "capability": "metrics",
      "window": "required",
      "annotations": {
        "title": "List the metrics TKTail keeps",
        "readOnlyHint": true,
        "destructiveHint": false,
        "idempotentHint": true,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {},
        "additionalProperties": false
      }
    },
    {
      "name": "tktail_get_metric_current",
      "title": "Get a metric's current value",
      "category": "Metrics",
      "description": "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.",
      "readOnly": true,
      "capability": "metrics",
      "window": "required",
      "annotations": {
        "title": "Get a metric's current value",
        "readOnlyHint": true,
        "destructiveHint": false,
        "idempotentHint": true,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {
          "metricId": {
            "type": "string",
            "description": "From tktail_list_metrics."
          }
        },
        "required": [
          "metricId"
        ],
        "additionalProperties": false
      }
    },
    {
      "name": "tktail_get_metric_history",
      "title": "Get a metric's samples",
      "category": "Metrics",
      "description": "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.",
      "readOnly": true,
      "capability": "metrics",
      "window": "required",
      "annotations": {
        "title": "Get a metric's samples",
        "readOnlyHint": true,
        "destructiveHint": false,
        "idempotentHint": true,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {
          "metricId": {
            "type": "string",
            "description": "From tktail_list_metrics."
          },
          "from": {
            "type": "string",
            "description": "Interval start: \"2026-10-09T10:00:00\" (local wall clock) or with Z / an offset."
          },
          "to": {
            "type": "string",
            "description": "Interval end (default now); only with from."
          },
          "lastSeconds": {
            "type": "integer",
            "minimum": 1,
            "maximum": 86400,
            "description": "The last N seconds (default 300)."
          },
          "around": {
            "type": "object",
            "description": "{\"time\":\"2026-10-09T10:00:15\",\"seconds\":60}: N seconds on each side of a time (an error's).",
            "properties": {
              "time": {
                "type": "string"
              },
              "seconds": {
                "type": "integer",
                "minimum": 1,
                "maximum": 43200
              }
            },
            "required": [
              "time"
            ],
            "additionalProperties": false
          },
          "maxSamples": {
            "type": "integer",
            "minimum": 1,
            "maximum": 2000,
            "description": "Default 300."
          }
        },
        "required": [
          "metricId"
        ],
        "additionalProperties": false
      }
    },
    {
      "name": "tktail_get_metric_summary",
      "title": "Summarize metrics in an interval",
      "category": "Metrics",
      "description": "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.",
      "readOnly": true,
      "capability": "metrics",
      "window": "required",
      "annotations": {
        "title": "Summarize metrics in an interval",
        "readOnlyHint": true,
        "destructiveHint": false,
        "idempotentHint": true,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {
          "metricIds": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "minItems": 1,
            "maxItems": 16,
            "description": "From tktail_list_metrics (default: all kept, at most 16)."
          },
          "from": {
            "type": "string"
          },
          "to": {
            "type": "string"
          },
          "lastSeconds": {
            "type": "integer",
            "minimum": 1,
            "maximum": 86400
          },
          "around": {
            "type": "object",
            "properties": {
              "time": {
                "type": "string"
              },
              "seconds": {
                "type": "integer",
                "minimum": 1,
                "maximum": 43200
              }
            },
            "required": [
              "time"
            ],
            "additionalProperties": false
          }
        },
        "additionalProperties": false
      }
    },
    {
      "name": "tktail_list_metric_sets",
      "title": "List Metric Sets",
      "category": "Metrics",
      "description": "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.",
      "readOnly": true,
      "capability": "metrics",
      "window": "required",
      "annotations": {
        "title": "List Metric Sets",
        "readOnlyHint": true,
        "destructiveHint": false,
        "idempotentHint": true,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {},
        "additionalProperties": false
      }
    },
    {
      "name": "tktail_get_metric_set",
      "title": "Get a Metric Set",
      "category": "Metrics",
      "description": "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.",
      "readOnly": true,
      "capability": "metrics",
      "window": "required",
      "annotations": {
        "title": "Get a Metric Set",
        "readOnlyHint": true,
        "destructiveHint": false,
        "idempotentHint": true,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "A Metric Set id from tktail_list_metric_sets (\"builtin:host\", \"set-...\")."
          }
        },
        "required": [
          "id"
        ],
        "additionalProperties": false
      }
    },
    {
      "name": "tktail_save_metric_set",
      "title": "Save a Metric Set",
      "category": "Metrics",
      "description": "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.",
      "readOnly": false,
      "capability": "metrics",
      "consent": "mcp.allowSearchSave",
      "window": "required",
      "annotations": {
        "title": "Save a Metric Set",
        "readOnlyHint": false,
        "destructiveHint": true,
        "idempotentHint": false,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64
          },
          "description": {
            "type": "string"
          },
          "metrics": {
            "type": "array",
            "minItems": 1,
            "maxItems": 64,
            "items": {
              "type": "object",
              "description": "A Windows performance counter by its English names - copy a \"definition\" from tktail_list_metrics / tktail_get_metric_set.",
              "properties": {
                "object": {
                  "type": "string",
                  "minLength": 1,
                  "description": "English object name: Processor, Memory, Process, LogicalDisk, Network Interface ..."
                },
                "counter": {
                  "type": "string",
                  "minLength": 1,
                  "description": "English counter name: % Processor Time, Available Bytes ..."
                },
                "instance": {
                  "type": "string",
                  "description": "The instance (_Total, a process name, C:); leave out for an object without instances."
                },
                "provider": {
                  "type": "string",
                  "enum": [
                    "pdh"
                  ],
                  "description": "Optional: pdh (Windows Performance Counters - the only provider)."
                },
                "unit": {
                  "type": "string",
                  "enum": [
                    "count",
                    "percent",
                    "bytes",
                    "bytesPerSecond",
                    "perSecond",
                    "seconds"
                  ],
                  "description": "Optional: TKTail infers it from the counter's name as its counter picker does."
                },
                "policy": {
                  "type": "string",
                  "enum": [
                    "fixed",
                    "followName",
                    "pinPid"
                  ],
                  "description": "Process instances: followName (by name, restarts marked), fixed, pinPid (one process: with pid). Only for the Process object; default fixed."
                },
                "pid": {
                  "type": "integer",
                  "minimum": 1,
                  "description": "policy pinPid only."
                },
                "scale": {
                  "type": "number",
                  "exclusiveMinimum": 0,
                  "description": "A multiplier of the raw value (default 1)."
                },
                "normalize": {
                  "type": "string",
                  "enum": [
                    "none",
                    "machine"
                  ],
                  "description": "machine: divided by the processor count (a process's CPU)."
                },
                "name": {
                  "type": "string",
                  "maxLength": 1024,
                  "description": "A label of its own."
                },
                "counterSet": {
                  "type": "string",
                  "description": "A PerfLib V2 counter set GUID, when TKTail listed one."
                },
                "localized": {
                  "type": "boolean",
                  "description": "The names are this Windows's localized ones (as TKTail listed them)."
                }
              },
              "required": [
                "object",
                "counter"
              ],
              "additionalProperties": false
            }
          },
          "metricSetId": {
            "type": "string"
          },
          "expectedContent": {
            "type": "string",
            "description": "Changing a set: its contentId as you read it."
          }
        },
        "required": [
          "name",
          "metrics"
        ],
        "additionalProperties": false,
        "examples": [
          {
            "name": "App pressure",
            "description": "CPU and memory of the host",
            "metrics": [
              {
                "object": "Processor",
                "counter": "% Processor Time",
                "instance": "_Total"
              },
              {
                "object": "Memory",
                "counter": "Available Bytes"
              }
            ]
          },
          {
            "name": "Disk activity",
            "metrics": [
              {
                "provider": "pdh",
                "object": "LogicalDisk",
                "counter": "Disk Bytes/sec",
                "instance": "_Total",
                "unit": "bytesPerSecond"
              },
              {
                "object": "LogicalDisk",
                "counter": "% Free Space",
                "instance": "_Total",
                "unit": "percent"
              }
            ]
          }
        ]
      }
    },
    {
      "name": "tktail_delete_metric_set",
      "title": "Delete a Metric Set",
      "category": "Metrics",
      "description": "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.",
      "readOnly": false,
      "capability": "mcp-workspace",
      "consent": "mcp.allowSearchSave",
      "window": "required",
      "annotations": {
        "title": "Delete a Metric Set",
        "readOnlyHint": false,
        "destructiveHint": true,
        "idempotentHint": false,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {
          "metricSetId": {
            "type": "string"
          },
          "expectedContent": {
            "type": "string"
          }
        },
        "required": [
          "metricSetId",
          "expectedContent"
        ],
        "additionalProperties": false,
        "examples": [
          {
            "metricSetId": "<metricSetId>",
            "expectedContent": "<contentId>"
          }
        ]
      }
    },
    {
      "name": "tktail_list_formats",
      "title": "List log formats",
      "category": "Formats",
      "description": "Lists the log formats TKTail knows - favorite (and favoriteOrder) marks the user's favorites: the built-in ones (formatId \"builtin:<key>\" - 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:<id>\") with enabled, usable, state, profileVersion, framing, record types, field count and error / warning counts. kind: builtin, custom or all (default). Read-only.",
      "readOnly": true,
      "capability": "mcp-workspace",
      "window": "optional",
      "annotations": {
        "title": "List log formats",
        "readOnlyHint": true,
        "destructiveHint": false,
        "idempotentHint": true,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "builtin",
              "custom",
              "all"
            ]
          }
        },
        "additionalProperties": false
      }
    },
    {
      "name": "tktail_get_format",
      "title": "Get a log format",
      "category": "Formats",
      "description": "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.",
      "readOnly": true,
      "capability": "mcp-workspace",
      "window": "optional",
      "annotations": {
        "title": "Get a log format",
        "readOnlyHint": true,
        "destructiveHint": false,
        "idempotentHint": true,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {
          "formatId": {
            "type": "string",
            "description": "\"builtin:<key>\" or \"custom:<id>\" from tktail_list_formats."
          }
        },
        "required": [
          "formatId"
        ],
        "additionalProperties": false
      }
    },
    {
      "name": "tktail_detect_format",
      "title": "Detect a log's format",
      "category": "Formats",
      "description": "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.",
      "readOnly": true,
      "capability": "mcp-workspace",
      "window": "optional",
      "annotations": {
        "title": "Detect a log's format",
        "readOnlyHint": true,
        "destructiveHint": false,
        "idempotentHint": true,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {
          "sourceId": {
            "type": "string"
          },
          "sample": {
            "type": "object",
            "properties": {
              "text": {
                "type": "string",
                "maxLength": 32768
              },
              "fileName": {
                "type": "string",
                "description": "A file name such as orders.log (no folder)."
              }
            },
            "required": [
              "text"
            ],
            "additionalProperties": false
          },
          "definition": {
            "type": "object",
            "description": "Optional: a draft format profile whose fileMatch to test."
          }
        },
        "additionalProperties": false
      }
    },
    {
      "name": "tktail_preview_format",
      "title": "Preview a format on sample records",
      "category": "Formats",
      "description": "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:<id>) 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:<key>) 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.",
      "readOnly": true,
      "capability": "mcp-workspace",
      "window": "optional",
      "annotations": {
        "title": "Preview a format on sample records",
        "readOnlyHint": true,
        "destructiveHint": false,
        "idempotentHint": true,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {
          "definition": {
            "type": "object",
            "description": "A draft format profile (JSON)."
          },
          "formatId": {
            "type": "string",
            "description": "An installed format: builtin:<key> or custom:<id>."
          },
          "sourceId": {
            "type": "string"
          },
          "from": {
            "type": "string",
            "enum": [
              "start",
              "end"
            ]
          },
          "line": {
            "type": "integer",
            "minimum": 1
          },
          "sample": {
            "type": "object",
            "properties": {
              "text": {
                "type": "string",
                "maxLength": 32768
              },
              "fileName": {
                "type": "string"
              }
            },
            "required": [
              "text"
            ],
            "additionalProperties": false
          },
          "maxRecords": {
            "type": "integer",
            "minimum": 1,
            "maximum": 50
          },
          "maxFields": {
            "type": "integer",
            "minimum": 1,
            "maximum": 64
          },
          "maxFieldBytes": {
            "type": "integer",
            "minimum": 64,
            "maximum": 2048
          },
          "explain": {
            "type": "boolean",
            "description": "List every record type's candidate result."
          }
        },
        "additionalProperties": false
      }
    },
    {
      "name": "tktail_new_format_draft",
      "title": "Start a format profile draft",
      "category": "Formats",
      "description": "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 (?<name>...) 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.",
      "readOnly": true,
      "capability": "mcp-workspace",
      "window": "optional",
      "annotations": {
        "title": "Start a format profile draft",
        "readOnlyHint": true,
        "destructiveHint": false,
        "idempotentHint": true,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {
          "template": {
            "type": "string",
            "enum": [
              "lineBased",
              "multiline",
              "cloneAppLog",
              "delimited"
            ]
          },
          "id": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9._-]{2,63}$"
          },
          "name": {
            "type": "string",
            "maxLength": 100
          },
          "sourceId": {
            "type": "string",
            "description": "An open log the draft starts from (its detected format)."
          }
        },
        "additionalProperties": false
      }
    },
    {
      "name": "tktail_validate_format",
      "title": "Validate a format profile",
      "category": "Formats",
      "description": "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 (?<name>...) 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.",
      "readOnly": true,
      "capability": "mcp-workspace",
      "window": "optional",
      "annotations": {
        "title": "Validate a format profile",
        "readOnlyHint": true,
        "destructiveHint": false,
        "idempotentHint": true,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {
          "definition": {
            "type": "object",
            "description": "The format profile JSON."
          }
        },
        "required": [
          "definition"
        ],
        "additionalProperties": false
      }
    },
    {
      "name": "tktail_save_format",
      "title": "Save a format profile",
      "category": "Formats",
      "description": "Saves a user-defined format profile into TKTail's Custom Formats - only when the user allowed AI clients to save formats (Tools > 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.",
      "readOnly": false,
      "capability": "mcp-workspace",
      "consent": "mcp.allowFormatSave",
      "window": "required",
      "annotations": {
        "title": "Save a format profile",
        "readOnlyHint": false,
        "destructiveHint": true,
        "idempotentHint": false,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {
          "definition": {
            "type": "object",
            "description": "The format profile JSON (validated again before writing)."
          },
          "replacesVersion": {
            "type": "integer",
            "minimum": 1,
            "description": "Replacing an installed profile: its current profileVersion."
          },
          "applyToSourceId": {
            "type": "string",
            "description": "An open log file to use the saved profile for (View As, this session)."
          },
          "favorite": {
            "type": "boolean",
            "description": "Mark it as a favorite format - only when the user asked."
          }
        },
        "required": [
          "definition"
        ],
        "additionalProperties": false,
        "examples": [
          {
            "definition": {
              "schemaVersion": 1,
              "id": "demo.orders-pipe",
              "name": "Orders pipe log",
              "profileVersion": 1,
              "enabled": true,
              "fileMatch": {
                "extensions": [
                  ".pipe"
                ],
                "content": "^ORD\\|"
              },
              "framing": {
                "kind": "multiline",
                "recordStart": "^ORD\\|"
              },
              "envelope": {
                "pattern": "^ORD\\|(?<timestamp>[^|]+)\\|(?<requestId>[^|]+)\\|(?<status>[^|]+)\\|(?<elapsed>\\d+)ms\\|(?<message>.*)$"
              },
              "fields": [
                {
                  "id": "timestamp",
                  "group": "timestamp",
                  "type": "timestamp",
                  "role": "timestamp"
                },
                {
                  "id": "requestId",
                  "group": "requestId",
                  "role": "correlation"
                },
                {
                  "id": "status",
                  "group": "status",
                  "role": "severity"
                },
                {
                  "id": "elapsed",
                  "group": "elapsed",
                  "type": "durationMs",
                  "role": "duration"
                },
                {
                  "id": "message",
                  "group": "message",
                  "role": "message"
                }
              ],
              "recordTypes": [
                {
                  "id": "FAILED",
                  "match": {
                    "field": "status",
                    "pattern": "^FAIL$"
                  },
                  "severityClass": "error"
                },
                {
                  "id": "OTHER",
                  "fallback": true
                }
              ]
            }
          }
        ]
      }
    },
    {
      "name": "tktail_list_investigation_roots",
      "title": "List Investigation Roots",
      "category": "Extended Investigation",
      "description": "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 > 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.",
      "readOnly": true,
      "capability": "mcp-workspace",
      "alsoNeeds": [
        {
          "capability": "mcp-extended",
          "when": "to see the roots (without it the answer says Extended Investigation is not available)"
        }
      ],
      "window": "required",
      "annotations": {
        "title": "List Investigation Roots",
        "readOnlyHint": true,
        "destructiveHint": false,
        "idempotentHint": true,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {},
        "additionalProperties": false
      }
    },
    {
      "name": "tktail_discover_files",
      "title": "Discover log files under a root",
      "category": "Extended Investigation",
      "description": "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.",
      "readOnly": true,
      "capability": "mcp-extended",
      "window": "required",
      "annotations": {
        "title": "Discover log files under a root",
        "readOnlyHint": true,
        "destructiveHint": false,
        "idempotentHint": true,
        "openWorldHint": false
      },
      "inputSchema": {
        "type": "object",
        "properties": {
          "rootId": {
            "type": "string",
            "description": "From tktail_list_investigation_roots."
          },
          "folder": {
            "type": "string",
            "description": "An absolute folder below that root (default: the root)."
          },
          "include": {
            "type": "string"
          },
          "exclude": {
            "type": "string"
          },
          "recursive": {
            "type": "boolean"
          },
          "maxFiles": {
            "type": "integer",
            "minimum": 1,
            "maximum": 1000
          },
          "probe": {
            "type": "boolean"
          }
        },
        "required": [
          "rootId"
        ],
        "additionalProperties": false
      }
    }
  ]
}
