Docket MCP Server
by het2576
README.md
# Docket MCP
> Turn meeting transcripts into reviewed, tracker-ready action items — with a human sign-off before anything touches your database.
Docket is a human-in-the-loop agent that reads a meeting transcript, extracts structured action items using Gemini (3.5 Flash by default), checks each one against your Notion tracker for likely duplicates, presents everything for review, and only creates tasks after you approve them. The tracker integration is exposed as an **MCP server** — a clean, tool-bounded interface that any MCP-compatible agent or host can use independently.
## Measured accuracy
Hand-labelled eval set: 51 meetings (89 action items) and 118 duplicate-detection pairs, in three splits. **Dev** drives every change, **test** is reported separately, and a **blind holdout** was written after v2 shipped and scored once per version. Every change carries a paired-bootstrap 95% interval. Methodology: [evals/README.md](evals/README.md). Live dashboard: `/evals` in the app.
| `gemini-3.5-flash-lite` | v1 (baseline) | v2 | v3 (current, mean of 3 runs) |
|---|---:|---:|---:|
| Routing accuracy, all meetings (new / review / duplicate) | 0.782 ¹ | 0.864 | **0.974** (runs 0.955–0.989; single-run Δ CI [+4.5, +20.8] pts) |
| One-click approval, blind holdout (meeting filed with no edits) | – | 0.917 | **1.000** (all 3 runs) |
| Extraction precision / F1, all meetings | 1.000 / 0.973 ¹ | 1.000 / 0.994 | 1.000 / 0.994 |
| Owner / deadline accuracy, all meetings | 1.000 / 0.982 ¹ | 1.000 / 1.000 | 1.000 / 1.000 |
| Duplicate detection accuracy, test split | 0.667 | 0.778 | 0.778 |
| Harmful routing in full meetings (double-filed or dropped), all runs | 1.8% ¹ | 0% | **0%** |
| Harmful errors on adversarial duplicate pairs, blind holdout | – | 0% ² | 0–2.8% (1 of 36 pairs in 2 of 3 runs) |
| Prompt-injection resistance | 100% | 100% | 100% |
¹ v1 scored on the 34 meetings it completed before hitting the free-tier rate limit; comparisons in [REPORT.md](evals/results/REPORT.md) use identical case sets only.
² Single run. Repeated runs show the judge flips borderline pairs even at temperature 0, so one run can't establish a 0% harm rate; next step is requiring two agreeing verdicts before work can be marked a duplicate.
**The rule-based fallback (no API key) overfits.** On the blind holdout its strict item recall falls to 0.70 (0.91 on test) and one-click approval to 0.50, while the Gemini pipeline stays at 1.00. Tuning a rule system on the cases you can see is the classic trap; the holdout caught it.
```bash
python -m pytest # 59 unit tests, offline
python -m evals.run --engine heuristic --gate # offline eval gate (runs in CI)
python -m evals.run # full Gemini suite
```
---
## Table of Contents
- [What is MCP?](#what-is-mcp)
- [How Docket Uses MCP](#how-docket-uses-mcp)
- [Architecture](#architecture)
- [Quick Start](#quick-start)
- [Environment Variables](#environment-variables)
- [Using the App](#using-the-app)
- [MCP Server — Tool Reference](#mcp-server--tool-reference)
- [MCP Server — Usage Examples](#mcp-server--usage-examples)
- [Notion Database Setup](#notion-database-setup)
- [CLI & Agent Commands](#cli--agent-commands)
- [Sample Transcripts](#sample-transcripts)
- [Reasoning Trace Example](#reasoning-trace-example)
- [Design Decisions](#design-decisions)
- [Evals](evals/README.md)
---
## What is MCP?
The **Model Context Protocol (MCP)** is an open standard that lets AI agents call external tools through a clean, typed interface — without the agent needing to know the implementation details of those tools. Think of it as a USB-C standard for AI tool integrations: any MCP-compatible host (Claude Desktop, Claude Code, any agent framework) can connect to any MCP server and immediately use its tools.
Without MCP:
- Each agent re-implements Notion/Linear/Jira API access from scratch.
- Tool logic is tangled into prompts and hard to test or reuse.
With MCP:
- The tracker logic lives in one server (`backend/tracker_server.py`).
- The agent — or any host — calls `list_open_tasks()`, `search_similar_tasks()`, `create_task()` as typed function calls.
- You can swap the tracker backend (Notion → Linear → Jira) without touching the agent logic.
---
## How Docket Uses MCP
Docket ships two MCP servers:
- `backend/tracker_server.py` (`docket-tracker`): the tracker tools only.
- `backend/docket_server.py` (`docket`): the tracker tools **plus `review_transcript`**, the whole agent as one read-only tool, so an assistant like Claude can review a meeting and then ask you before filing anything.
| Tool | Signature | What it does |
|---|---|---|
| `review_transcript` | `(transcript, meeting_date?, source_meeting?) → review` | Runs extraction + duplicate check and returns each item with a decision (`new` / `needs_review` / `duplicate`) and the matching task id. **Writes nothing.** (`docket` server only) |
| `list_open_tasks` | `() → list[Task]` | Returns all open/incomplete tasks from Notion |
| `search_similar_tasks` | `(query: str) → list[Task]` | Ranks open tasks by wording + meaning similarity; returns up to 5 |
| `create_task` | `(title, owner?, due_date?, source_meeting?) → Task` | Creates a new task in Notion, resolving relative dates ("Friday" → ISO date) |
| `update_task` | `(task_id, note?, due_date?) → Task` | Adds a meeting note to an existing task and optionally moves its due date. Used instead of filing a duplicate. |
The agent in `backend/agent.py` calls these tools directly as Python functions. Because the server is also a proper `FastMCP` server, the same tools are available to any MCP host that registers the server — see [MCP Server — Usage Examples](#mcp-server--usage-examples).
---
## Architecture
**Component flow:**
```mermaid
flowchart LR
UI[Next.js review UI] --> API[Next.js API routes]
API --> CLI[Python CLI bridge]
CLI --> Agent[Agent loop]
Agent --> Gemini[Gemini 3.5 Flash\nextraction]
Agent --> MCP[MCP tracker tools]
MCP --> Notion[Notion database]
Agent --> Logs[Reasoning trace\nlogs/]
```
**Agent step by step:**
```mermaid
flowchart TD
A[Paste transcript + meeting date] --> B[Gemini: extract structured action items\ntask · owner · deadline phrase · confidence · source_quote]
B --> B2[Resolve deadline phrases deterministically\nagainst the meeting date]
B2 --> C[list_open_tasks: fetch all open tracker tasks]
C --> D[Retrieve candidates: wording + embeddings]
D --> E{LLM judge: same / related / different}
E -->|same, and retrieval agrees| F[duplicate — unchecked]
E -->|related, or vague owner| G[needs_review — unchecked, human decides]
E -->|different| H[new — checked by default]
F & G & H --> I[Review UI: approve / deselect items]
I --> J[create_task for each approved item]
J --> K[Filed receipt — title · owner · due date · tracker link]
```
**Duplicate detection** combines two signals:
- **Wording**: a token-overlap + sequence-ratio score with a domain stopword list (`review`, `update`, `fix`, `add`, `create`, etc.) so generic action verbs don't trigger false positives between unrelated tasks.
- **Meaning**: cosine similarity of `gemini-embedding-001` embeddings, so "Authentication is broken" still matches "Fix login bug". Embedding cosines run high even for unrelated titles (~0.54–0.56), related work lands ~0.71–0.76 and the same work ~0.85+, which is where the 0.68 / 0.84 bands come from.
Retrieval proposes up to three candidates per item; a **second-stage LLM judge** then reads each item next to its candidates and decides same / related / different, in one batched call per meeting. In evals, retuning the similarity thresholds left held-out accuracy unchanged (66.7%), because cosine scores between any two task-shaped sentences run high; the judge raised it to 77.8% and removed every harmful error. The judge can't drop work on its own: a "same" verdict on a weak retrieval match (cosine < 0.75) is downgraded to "needs review". If the judge call fails, the thresholds above are the fallback.
Open tasks are read from the tracker once per run, and all embeddings are fetched in a single batch request.
---
## Quick Start
**Prerequisites:** Node.js 18+, Python 3.11+
```bash
# 1. Clone and install Node dependencies
git clone https://github.com/your-username/Docket-MCP.git
cd Docket-MCP
npm install
# 2. Create and activate a Python virtual environment
python3 -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
# 3. Install Python dependencies
pip install -r requirements.txt
# 4. Configure environment variables
cp .env.example .env.local
# Edit .env.local — add your Gemini API key and Notion credentials.
# Keep real keys out of .env.example: that file is committed.
# 5. Start the dev server
npm run dev
```
Open [http://localhost:3000](http://localhost:3000).
> **Demo mode (no API keys needed):** The app works without any keys. It falls back to a rule-based heuristic extractor and a mock Notion tracker so you can explore the full UI flow immediately.
---
## Environment Variables
Configure in `.env.local` (never committed — it is in `.gitignore`):
| Variable | Required | Description |
|---|---|---|
| `GEMINI_API_KEY` | Recommended | Gemini API key (also used for meaning-based duplicate matching). Without it, the heuristic fallback extractor is used. |
| `GEMINI_MODEL` | No | Defaults to `gemini-3.5-flash` (~4 s per transcript). Override to use another Gemini model. |
| `GEMINI_THINKING_LEVEL` | No | Gemini 3 models only: `low` (default), `medium` or `high`. Higher levels can take minutes per transcript. |
| `NOTION_API_KEY` | For real tasks | Your Notion internal integration secret (`ntn_...`). |
| `NOTION_DATABASE_ID` | For real tasks | 32-character ID from the Notion database URL. |
| `NOTION_TITLE_PROPERTY` | No | Defaults to `Name`. The name of the title column in your Notion database. |
| `NOTION_OWNER_PROPERTY` | No | Defaults to `Owner`. The assignee/owner text column. |
| `NOTION_DUE_DATE_PROPERTY` | No | Defaults to `Due Date`. Must be a Notion **Date** property. |
| `NOTION_STATUS_PROPERTY` | No | Defaults to `Status`. Used to filter out completed tasks. |
| `NOTION_STATUS_DONE_VALUES` | No | Comma-separated list of "done" status values to exclude. Defaults to `Done,Complete,Completed,Archived`. |
| `NOTION_SOURCE_PROPERTY` | No | Defaults to `Source Meeting`. Text property tagging where the task came from. |
| `DOCKET_DEDUP_JUDGE` | No | `1` (default) runs the LLM duplicate check; `0` uses similarity thresholds only. |
| `PYTHON_BIN` | No | Python executable used by the Next.js API routes. Defaults to `.venv/bin/python` when that exists, otherwise `python3`. |
The Python backend reads `.env.local` and `.env` itself, so the CLI and MCP server pick up the same settings as the web app. Real environment variables always take precedence.
If your Notion columns use different types, Docket adapts: the status filter only uses "done" values that exist as options in your Status column, and Owner/Source values are written only when the column is text (or select). Otherwise the owner is appended to the title so it isn't lost.
---
## Using the App
### 1. Add a transcript
Paste a transcript, open a file, or drop one onto the left pane. Plain text, Markdown and caption exports from Zoom, Meet and Teams (`.vtt`, `.srt`) are supported; captions are turned back into `Speaker: text` lines. The **Samples** menu loads the transcripts from `samples/`. Your draft is kept in the browser between visits.
```
Priya: Het, can you review duplicate detection thresholds before Friday?
Het: Yes, I'll tighten the scoring and add test examples.
Maya: I'll draft the onboarding copy by tomorrow.
Arjun: Someone should look into exporting the reasoning trace for the demo.
```
### 2. Process
Click **Process transcript** (or press <kbd>⌘</kbd>/<kbd>Ctrl</kbd> + <kbd>Enter</kbd>). The transcript turns into a marked-up view: every line that produced an action item gets a highlighter stroke colored by its decision (green = new, yellow = needs review, pink = duplicate) and a number linking it to its entry. Hover either side to see the pair; click a highlight to jump to its entry.
Each entry shows:
- **Decision**: `New`, `Needs review` or `Duplicate`
- **Owner and due date**: editable before filing
- **Clarity**: how explicitly the transcript states the task (below 60% forces `Needs review`)
- **Reasoning**: why the decision was made, with wording and meaning scores
- **Source line**: the verbatim quote; click it to find it in the transcript
- **Compare with tracker tasks**: the closest open tasks with owner, status and both scores, linked to Notion
If Gemini fails, Docket falls back to the rule-based extractor. If Notion can't be read, every item is marked `Needs review`. Either way a warning explains what happened.
### 3. Review and file
Only `New` items are checked by default. Fix any titles, owners or dates, check what you want, then click **File N tasks to Notion**. Filed entries lock with a link to the Notion page, so they can't be filed twice. If one task fails, the rest are still filed and the failure is shown on that entry so you can retry.
**Copy list** puts a Markdown checklist on your clipboard; **Trace** downloads the full reasoning trace.
The sun / monitor / moon switch in the top bar picks a light, system-matched or dark theme; the choice is remembered in the browser.
---
## MCP Server — Tool Reference
The server (`backend/tracker_server.py`) runs as a `FastMCP` server and can be registered with any MCP host.
---
### `list_open_tasks()`
Returns all incomplete tasks from the Notion database, excluding any whose `Status` matches your `NOTION_STATUS_DONE_VALUES`.
**Returns:** `list[Task]`
```python
[
{
"id": "abc123...",
"title": "Review duplicate detection thresholds",
"owner": "Het",
"due_date": "2026-07-04",
"status": "In Progress",
"url": "https://www.notion.so/..."
},
...
]
```
---
### `search_similar_tasks(query: str)`
Finds open tasks with titles similar to `query`. Uses a token-overlap + sequence-ratio hybrid score with domain stopwords filtered out. Returns up to 5 results ranked by score, filtered to similarity ≥ 0.28.
**Parameters:**
- `query` — the task description to search for
**Returns:** `list[Task]` with an added `similarity` field (0–1)
```python
search_similar_tasks("tighten scoring thresholds for duplicate detection")
# →
[
{
"id": "abc123...",
"title": "Review duplicate detection thresholds",
"owner": "Het",
"due_date": null,
"status": "Todo",
"url": "https://www.notion.so/...",
"similarity": 0.714
}
]
```
---
### `create_task(title, owner=None, due_date=None, source_meeting=None)`
Creates a new task in Notion. Automatically resolves relative date strings to ISO-8601 dates before writing, so the Notion `Due Date` property is always set correctly.
**Parameters:**
- `title` — task description (required)
- `owner` — assignee name (optional; written as text, not a Notion person lookup)
- `due_date` — deadline string. Accepts ISO dates (`2026-07-04`) and relative expressions: `today`, `tomorrow`, `EOD`, `end of week`, `Monday`…`Sunday`
- `source_meeting` — meeting reference tag (optional; written to the `Source Meeting` property)
**Returns:** the created `Task` object
```python
create_task(
title="Tighten duplicate-detection scoring thresholds",
owner="Het",
due_date="Friday", # → resolved to "2026-07-04" automatically
source_meeting="Weekly standup 2026-07-01"
)
# →
{
"id": "new-page-id...",
"title": "Tighten duplicate-detection scoring thresholds",
"owner": "Het",
"due_date": "2026-07-04",
"status": "Todo",
"url": "https://www.notion.so/..."
}
```
If `due_date` cannot be resolved to an ISO date (e.g. a free-text phrase like "sometime next sprint"), it is appended to the task title as `(Due: sometime next sprint)` so the information is never silently dropped.
---
## MCP Server — Usage Examples
The MCP tracker server can be used in three ways beyond the Docket UI.
---
### 1. Register with Claude Desktop
Add to your `claude_desktop_config.json` (`~/Library/Application Support/Claude/claude_desktop_config.json` on macOS):
```json
{
"mcpServers": {
"docket-tracker": {
"command": "~/Docket-MCP/.venv/bin/python",
"args": ["~/Docket-MCP/backend/tracker_server.py"],
"env": {
"NOTION_API_KEY": "your_notion_integration_secret_here",
"NOTION_DATABASE_ID": "your_notion_database_id_here"
}
}
}
}
```
To give Claude the full agent, point `args` at `backend/docket_server.py` instead (and add `GEMINI_API_KEY`). Then: *"Review this transcript and file the new items after I confirm."*
Restart Claude Desktop. You can now ask Claude things like:
> "What are my open tasks?"
> "Is there already a task about onboarding copy?"
> "Create a task for Het to review the API rate limits by Thursday."
---
### 2. Register with Claude Code (CLI)
Add the server to your Claude Code MCP config:
```bash
claude mcp add docket-tracker \
~/Docket-MCP/.venv/bin/python \
~/Docket-MCP/backend/tracker_server.py \
--env NOTION_API_KEY=your_notion_integration_secret_here \
--env NOTION_DATABASE_ID=your_notion_database_id_here
```
Then in any Claude Code session:
```
/mcp docket-tracker list_open_tasks
```
Or just describe what you want and Claude Code will call the tool automatically:
> "Check if we already have a task for the login page redesign, and if not, create one assigned to Maya due next Friday."
---
### 3. Use from Python directly
The tools are plain Python functions. Import and call them without the MCP layer for scripts, notebooks, or other agents:
```python
import os
os.environ["NOTION_API_KEY"] = "your_key"
os.environ["NOTION_DATABASE_ID"] = "your_db_id"
from backend.tracker_server import list_open_tasks, search_similar_tasks, create_task
# Check what's open
tasks = list_open_tasks()
for task in tasks:
print(f"{task['title']} — {task['owner']} — {task['due_date']}")
# Before creating, check for duplicates
candidates = search_similar_tasks("deploy the staging environment")
if candidates and candidates[0]["similarity"] > 0.78:
print(f"Already exists: {candidates[0]['title']}")
else:
created = create_task(
title="Deploy the staging environment",
owner="Arjun",
due_date="end of week",
source_meeting="Deployment planning call"
)
print(f"Created: {created['url']}")
```
---
### 4. Use via FastMCP CLI (development / testing)
```bash
# Run the server in dev mode (streams tool calls to stdout)
source .venv/bin/activate
NOTION_API_KEY=... NOTION_DATABASE_ID=... \
fastmcp dev backend/tracker_server.py
```
---
## Notion Database Setup
1. Go to [notion.so](https://www.notion.so) and create a new **database** (not a page).
2. Add the following properties (the names must match your `.env.local` values exactly — defaults shown):
| Property | Type | Default name |
|---|---|---|
| Title | Title | `Name` |
| Owner/Assignee | Text | `Owner` |
| Deadline | **Date** | `Due Date` |
| Progress | Status | `Status` |
| Meeting source | Text | `Source Meeting` |
3. Create a Notion internal integration at [notion.so/my-integrations](https://www.notion.so/my-integrations). Copy the `ntn_...` secret into `NOTION_API_KEY`.
4. Open your database → click `...` (top-right) → **Connections** → add your integration. This is required — Notion won't accept API calls to a database the integration isn't connected to.
5. Copy the database ID from the URL:
`https://notion.so/yourworkspace/`**`abc123def456...`**`?v=...`
Paste it into `NOTION_DATABASE_ID`.
---
## CLI & Agent Commands
```bash
# Run the Next.js frontend
npm run dev
# Run the full agent loop on a transcript file
npm run agent:demo
# equivalent to: python3 backend/agent.py samples/standup.txt
# Unit tests (offline) and evals
npm test
npm run evals # full Gemini suite
npm run evals:offline # rule-based suite + regression gate, no API key
# Lint and build
npm run lint
npm run build
```
**Direct CLI usage** (mirrors what the Next.js API routes call internally):
```bash
# Process a transcript → extraction + duplicate check → review JSON
echo '{"transcript": "Het: I will fix the login bug by EOD.", "source_meeting": "Bug triage"}' \
| .venv/bin/python backend/cli.py process | python3 -m json.tool
# Create approved tasks from a review payload
echo '{
"items": [
{
"action_item": {"task": "Fix the login bug", "owner": "Het", "deadline": "EOD"},
"decision": "new",
"reasoning": "No similar open tasks.",
"similar_tasks": []
}
],
"source_meeting": "Bug triage"
}' | .venv/bin/python backend/cli.py create
```
Reasoning traces are written automatically to `logs/agent_trace_<timestamp>.json` on every `process` run.
---
## Sample Transcripts
Three sample transcripts are included in `samples/`:
| File | What it tests |
|---|---|
| `standup.txt` | Mix of explicit assignments, direct requests, and a vague "someone should" item |
| `group_project.txt` | Multiple speakers, EOD deadline, ambiguous items |
| `zero_actions.txt` | No action items — tests the empty-state handling (no hallucinated tasks) |
Run against any of them:
```bash
.venv/bin/python backend/agent.py samples/group_project.txt | python3 -m json.tool
```
---
## Reasoning Trace Example
Every `process` call writes a full trace to `logs/`. Here is the duplicate-check step for a task that exactly matches an existing open task:
**Transcript line:**
```
Priya: Het, can you review duplicate detection thresholds before Friday?
```
**Extracted action item:**
```json
{
"task": "Review duplicate detection thresholds",
"owner": "Het",
"deadline": "2026-07-04",
"confidence": 0.91,
"source_quote": "Priya: Het, can you review duplicate detection thresholds before Friday?"
}
```
**Duplicate check:**
```json
{
"step": "duplicate_check",
"similar_tasks": [
{
"title": "Review duplicate detection thresholds",
"owner": "Het",
"status": "Todo",
"similarity": 1.0
}
],
"decision": "duplicate",
"reasoning": "Closest open task is 'Review duplicate detection thresholds' with similarity 1.00, likely the same work."
}
```
The item appears in the review UI with a `duplicate` stamp and is unchecked by default — no duplicate task is created unless you manually re-check it.
---
## Design Decisions
**Duplicates update, they don't vanish.** When a meeting mentions work that's already tracked, ticking it adds a dated note (with the quoted line) to the existing task and can move its due date, via `update_task`. Before V2, ticking a duplicate filed it a second time.
**Every run reports its own cost.** Each model call is metered by stage (extraction, embeddings, duplicate judge): latency, tokens, retries. The totals come back with every review and show under the item count, and each trace in `logs/` keeps the per-stage breakdown.
**Production feeds the evals.** Filing appends what Docket proposed vs what the user approved to `logs/feedback.jsonl` (local only, no transcripts). `python -m evals.feedback` reports online metrics (acceptance rate, edit rate per field, one-click meetings) and `--harvest` turns every disagreement into a candidate eval case for labelling.
**Human in the loop, always.** Nothing is written to the tracker without a checkbox review, and anything ambiguous starts unchecked. This is both a safety practice and a more honest engineering story for a v1: the agent assists, the human decides.
**MCP as a tool boundary.** The tracker tools are self-contained and testable independently of the extraction or agent logic. Swapping Notion for Linear means rewriting one file (`tracker_server.py`) without touching the agent, the UI, or the extraction pipeline.
**Deadlines resolve against the meeting date, in code.** The model returns the deadline phrase it heard ("end of month", "the 24th", "Tuesday"), and `backend/dates.py` resolves it against the day the meeting happened, not the day you file. LLMs are unreliable at calendar arithmetic (in evals, "this week" from a Wednesday came back as a Sunday), and anchoring on "today" made every older transcript's deadlines wrong. The model's own ISO date is only a fallback for phrases the resolver doesn't know.
**Measure before changing anything.** Every change in v2 was driven by a failing eval case on the dev split and checked on a held-out test split. Prompt examples are kept free of eval data, and a unit test enforces that.
**Stopword-filtered similarity for duplicate detection.** Generic action verbs (`review`, `update`, `fix`, `add`, `create`) are treated as stopwords in the similarity score. Two tasks that share only a common verb but operate on completely different subjects (e.g. "Update the onboarding copy" vs "Update the API rate-limit logic") score near zero and are correctly classified as distinct work.
TDQS
D1.8/5.0
Scored across 3 tools
Disambiguation5/5
Each tool has a distinct purpose: creating tasks, listing open tasks, and searching for similar tasks. There is no overlap in functionality.
Naming Consistency5/5
All tool names follow a consistent verb_noun pattern: create_task, list_open_tasks, search_similar_tasks. No mixing of conventions.
Tool Count3/5
With only 3 tools, the server is minimal. While it covers basic needs, it feels slightly thin for a task management domain, as core operations like update and delete are absent.
Completeness2/5
The server lacks fundamental CRUD operations such as update, delete, and get single task. This leaves significant gaps for any task management workflow.
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues