Skip to main content
Glama
README.md
# chat-audit-mcp

A local-only MCP scaffold for auditable chat export parsing. It supports QQ
CSV, JSON arrays/objects, and JSONL, including the `qq-bak-chat-history-export`
record layout, as well as the original mock CSV. Select the format with
`CHAT_PARSER=mock_csv`, `qq_csv`, or `qq_json`. It exposes
list_allowed_chats and get_messages_by_range tools plus a summarize_chat_range
MCP Prompt over stdio.

QQ field compatibility follows the public `qq-bak-chat-history-export`
[README](https://github.com/zywstudy123/qq-bak-chat-history-export) and
[export script](https://github.com/zywstudy123/qq-bak-chat-history-export/blob/main/skills/qq-bak-chat-history-export/scripts/export_ntqq_chat.py).
This project only parses the resulting export files; it does not run that tool.

> **Disclaimer:** This is an experimental scaffold, not production-ready
> software. It has no official platform integration. The source release does
> not bundle real chat data; it only parses user-provided exports. Local files
> under `imports/` are ignored by Git.

## What's different

Most chat MCP servers compete on *coverage* — how many platforms they can pull
messages from. This project competes on *trust* — how honestly it tells you
whether the data it returned is complete, and whether each claim traces back to
a source record.

### Completeness honesty (the core)

One counterintuitive but correct insight drives the whole design: *reaching EOF
does not prove a file covers the requested time window, and observing the first
and last messages does not prove nothing is missing in between.*

Commercial AI-summary tools do not admit "I only read the first 50 messages" or
"three days are missing" — it makes them look weak. This project makes it the
whole point.

The standalone, dependency-free [`evidence-mcp`](packages/evidence-mcp)
library evaluates five gates before calling any result complete: source
exhausted, zero record errors, proven scope coverage, results exhausted, and no
result cap. The verdict is always explicit — `fetch_status`,
`complete_for_requested_scope`, `completeness_category`. When the result is
incomplete, the Agent is forced to warn before it summarizes.

### Evidence traceability

Every conclusion is `fact` or `inference`, and every conclusion carries
`message_id` / `timestamp` / `speaker`. Hallucination is fluent output without
evidence; this protocol inverts that — every sentence points back to a record.

### Untrusted-input defense and local privacy

Message text is never executed as instructions, derived IDs avoid content
hashing, attachment paths are redacted, and the server performs zero network
egress.

### Why it is hard to copy

The code is small (`completeness.py` is ~140 lines); the judgment is not. The
five-gate protocol must constrain the data layer and the Agent layer at the
same time — and shipping it means admitting the tool was not being honest about
incomplete data before. Existing vendors do not make that admission lightly.

Positioning, in one line: **"Others help you get more data. This tells you
whether the data you have can be trusted."**

## Run

Install in a virtual environment:

```powershell
python -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install -e .
```

Put the export at `imports/messages.csv`, then set CHAT_IMPORT_ROOT and the
source metadata variables before running `chat-audit-mcp`. The MCP server uses
stdio; it does not start an HTTP listener. For example, in PowerShell:

```powershell
$env:CHAT_IMPORT_ROOT = "./imports"
$env:CHAT_FILE_NAME = "messages.csv"
$env:CHAT_SOURCE_ID = "local-import-01"
$env:CHAT_PARSER = "qq_csv"
$env:CHAT_PLATFORM = "manual-export"
$env:CHAT_ID = "local:chat-01"
$env:CHAT_NAME = "Imported conversation"
$env:CHAT_SOURCE_TIMEZONE = "Asia/Shanghai"
chat-audit-mcp
```

Install with `pip install -e ".[dev]"` if you also want the MCP CLI/Inspector.

Configure CHAT_FILE_NAME, CHAT_SOURCE_ID, CHAT_PARSER, CHAT_PLATFORM, CHAT_ID,
CHAT_NAME, and CHAT_SOURCE_TIMEZONE. QQ parsers prefer Unix `timestamp` fields
when available; otherwise naive time strings use `Asia/Shanghai`. The CSV
parser accepts the simple headers 时间, 发送人, 内容 and the exporter columns
time, timestamp, sender, msg_id, text, attachments. Column names, encoding,
and delimiter can be changed in its constructor. Set
SOURCE_COVERAGE_START and SOURCE_COVERAGE_END together if the export provides a
known interval. Invalid configured intervals fail at startup. Without a
declared interval, file_time_coverage_partial is returned.

## Privacy boundary

The scaffold contains no HTTP client or platform API adapter. It only parses
user-exported CSV/JSON files; it contains no `.bak` decryption, process
injection, or client-memory access. It reads the configured file and never
accepts an arbitrary path from a tool argument.
Message data may exist transiently in process memory for up to 120 seconds to
support pagination; it is not persisted by this scaffold. Metadata-only audit
logs go to stderr.

QQ message IDs use the opaque import `source_id` and CSV row index, never the
message body or a body hash. Separately, pagination computes a SHA-256 digest
of the whole source file locally to detect changes between pages. The raw file
digest is not logged or returned; the continuation token contains a keyed
binding. If your privacy policy forbids any local hashing of chat-file bytes,
replace this source-change check with a weaker file-metadata fingerprint.

plugin_network_requests: 0 is the runtime code-path declaration. Enforce it
independently with an OS firewall or sandbox. A remote Agent host may transmit
the returned message text to its configured model; this server cannot control
that behavior.

The first/last observed message timestamps are only necessary boundary checks.
They do not prove the file has no missing records between them. For that reason
the implementation also requires a declared export coverage interval and keeps
source_history_completeness as unknown_export_coverage.

See docs/contract.md and prompts/summarize_chat_range.md for the synchronized
contract and Agent guidance. The domain-neutral completeness assessment is
also shipped as a separately installable `evidence-mcp` distribution under
`packages/evidence-mcp/`. From this repository, install it independently with
`python -m pip install ./packages/evidence-mcp`; other MCP projects can depend
on the `evidence-mcp` distribution after confirming the PyPI name is available
and publishing it. Its protocol and
portable schema are documented in `docs/evidence-mcp-protocol.md` and
`docs/evidence-mcp.schema.json`.

Run the synthetic parser, completeness-protocol, and local pagination coverage
with `python -m unittest discover tests`. This uses Python's standard-library
`unittest`; no pytest installation is needed. Fixtures use invented messages
only. On Windows, `tzdata` supplies IANA timezone definitions such as
`Asia/Shanghai`.

## License

This project is licensed under the MIT License. See [LICENSE](LICENSE).

TDQS

C2.9/5.0

Scored across 2 tools

Disambiguation4/5

The two tools target different actions: listing allowed chats/imports vs retrieving messages in a range. There is minor ambiguity because list_allowed_chats mentions 'its conversation,' which could be confused with message retrieval, but the core distinction remains clear.

Naming Consistency5/5

Both names use consistent snake_case and follow a clear verb_noun pattern: list_allowed_chats and get_messages_by_range. The verbs and resource nouns are predictable and readable.

Tool Count3/5

Only two tools are provided, which is thin for a chat-audit server that likely needs browsing, filtering, and inspection operations. The scope is narrow enough that it is not absurd, but the surface feels underpowered.

Completeness3/5

The tools cover basic listing and range-based message retrieval, but there are notable gaps such as searching message content, fetching chat metadata, or handling pagination. Agents can perform minimal auditing but may encounter dead ends for common audit workflows.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues