# Connect any MCP client

This page is for people who connect TKTail to an AI client, an agent framework or their own script - and for the
model on the other side. It lists what a client needs to know; [AI integration](https://tktail.dev/help/mcp/) is the user's view, the
[MCP tool reference](https://tktail.dev/help/mcp-tools/) the exact tools, and the developer reference (docs/MCP.md) every
detail.

## Connection

| | stdio | Streamable HTTP |
|---|---|---|
| Who starts what | the client starts `TKTail.exe mcp --stdio` | the client connects to the running TKTail |
| Edition | every edition | Trial, Pro, Developer |
| Turned on by | the user: Allow AI access | the user: Allow AI access + Accept AI clients over HTTP |
| Address | standard input / output, one JSON-RPC message per line | `POST http://127.0.0.1:47711/mcp` (the port is a setting; the legacy network mode - plain HTTP, not encrypted - listens on every interface) |
| Authentication | your Windows user (the per-user pipe) | `Authorization: Bearer <token>` on every request - also on this computer |
| Configuration | Settings > AI Access > Copy Client Configuration | Settings > AI Access > Copy HTTP Client Configuration |

**Protocol revisions**: `2026-07-28` (stateless: `_meta` `io.modelcontextprotocol/protocolVersion` and
`io.modelcontextprotocol/clientCapabilities` on every request) and `2025-11-25`, `2025-06-18`, `2025-03-26`,
`2024-11-05` (an `initialize` handshake). Capabilities: `tools` only - no resources, prompts or sampling.

**HTTP specifics**:

- `Content-Type: application/json`; `Accept` must include `application/json` (`application/json,
  text/event-stream` is fine). Replies are single JSON objects - TKTail opens no event stream (`GET` is 405).
- One message per POST; notifications are answered with 202, batches are refused.
- Handshake revisions: `initialize` returns `Mcp-Session-Id`; send it with every later request and `DELETE /mcp`
  with it to end the session. 404 means the session is gone (TKTail restarted, the token was regenerated, or 30
  idle minutes) - initialize again.
- `2026-07-28`: send `MCP-Protocol-Version`, `Mcp-Method` and, for `tools/call`, `Mcp-Name` - they must equal the
  body (400 otherwise).
- 401: the token is missing or replaced; 403: a `Host` other than a loopback name (when TKTail listens on this
  computer only - the legacy network mode checks no host name) or a browser `Origin`; 503: more than 8 connections
  at once.

## ChatGPT and other cloud clients

The connections above are local: the client runs on this computer (or, with the legacy unencrypted network mode,
reaches its HTTP address). ChatGPT runs at OpenAI: it **cannot connect to TKTail on your computer directly**, and it cannot send TKTail's
HTTP token (it signs in to an MCP server with OAuth, or not at all).

OpenAI's path for a private MCP server is **Secure MCP Tunnel**: `tunnel-client`, a program from OpenAI that **you** run
on this computer, polls OpenAI over outbound HTTPS and starts `TKTail.exe mcp --stdio` for ChatGPT's requests. TKTail
does not start it, contacts no OpenAI service and stores no OpenAI key.

- **Not tested end-to-end by TKTail.** The tunnel-client side was verified with the 1.3.0-rc.6 Preview over stdio; a
  real ChatGPT conversation through the tunnel was not.
- It needs an OpenAI product and workspace that allow custom MCP servers and Secure MCP Tunnel, with the permissions
  OpenAI's [Secure MCP Tunnel guide](https://developers.openai.com/api/docs/guides/secure-mcp-tunnels) lists - they
  change; check them there.
- Give tunnel-client the path to TKTail.exe with forward slashes - it reads its MCP command like a Unix shell, where
  `\` is an escape character: `"C:/Program Files/TKTail/TKTail.exe mcp --stdio"`.
- What the assistant reads leaves this computer for OpenAI - in this version records as the log has them
  ([Can it see passwords?](https://tktail.dev/help/ai-assistance/#questions)). Whoever your ChatGPT workspace lets use the connector reaches
  TKTail as the Windows user running tunnel-client; Allow AI access and your folders decide what they get, as for any
  client.

## First calls and refusals

Start with `tktail_status`, `tktail_list_sources` and `tktail_get_current_context` - the [Agent
quickstart](https://tktail.dev/help/ai-agents-quickstart/) is the whole loop, with complete calls. Source ids (`src-...`) and evidence
references are valid while that TKTail runs: list again after a restart; pass references back unchanged.

Every refusal is a tool result with `isError: true` and `structuredContent.error {category, message}` - the message
says what the user can do; tell the user instead of retrying. What decides access and what each category means:
[Agent permissions](https://tktail.dev/help/ai-agents-permissions/).

## What TKTail reads and writes

| Object | Shape | Check it with |
|---|---|---|
| Format profile | the profile file's JSON - JSON Schema, docs/CUSTOM_FORMATS.md | `tktail_validate_format`, `tktail_preview_format` |
| Search | a `SearchDefinition`: `sources` + `predicate` (text, regex, fields, time), optionally a `sequence` - docs/SEARCH.md "Schema" | `tktail_search` (it says what ran in `definition`) |
| Metric Set | `name`, `metrics`: `{object, counter, instance}` in English, as `tktail_list_metrics` shows them | `tktail_save_metric_set` refuses an unknown counter |
| Alert | the alert file's JSON - `name`, `severity`, `condition` (a search definition), `trigger`, `actions`, `capture` - docs/ALERTS.md; `tktail_get_alert` shows a saved one as `alert` | `tktail_validate_alert` |
| Evidence | `evidenceRef` objects from records, results and contexts; incidents and their evidence pages | `tktail_get_record`, `tktail_get_occurrence_evidence` |

The authoritative check is always TKTail's own: the JSON Schema helps an editor or a generator, the validation tools
also check patterns, conditions and references.

## Paging and partial results

- Long lists come in pages: `offset` / `maxResults` (or `limit`), `nextOffset`, `hasMore`; metric history with
  `nextFrom`. Every answer stays within 256 KiB of structured content.
- Cut values say so (`truncated`, the original length). A search that could not look at everything has
  `evidenceMayBeMissing: true` and its state (`incomplete`, `cancelled`, `failed`) with the reason - report it,
  never present such a result as complete.
- An incident's evidence item has its own state (`complete`, `partial`, `failed`) and reason.

## Recipes

Explaining an error, tracing a request across logs, reading an incident and setting up monitoring, writing a format
profile for an unknown log, and reading metrics around a time: [Investigation playbooks](https://tktail.dev/help/ai-agents-playbooks/). To
change a saved alert, search or Metric Set, read it first (`tktail_get_alert`, `tktail_get_saved_search`,
`tktail_get_metric_set`) and pass its `version` as `expectedVersion` (a Metric Set: its `contentId` as
`expectedContent`).

Agents that read documentation before they connect: [AI agents](https://tktail.dev/help/ai-agents/) - `llms.txt`, `llms-full.txt`, the AI
manifest, the machine-readable tool reference and the AI Agent Harness of each release. The authority stays the server
itself: `tools/list` (every tool with its description and input schema) and the `instructions` of `initialize`.

---

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