recon-desk-mcp
by mohitn08
README.md
# recon-desk-mcp
An MCP server that lets Claude, or any MCP client, work a **payments reconciliation exceptions queue in Jira**, grounded in **runbooks in Confluence**, with a human approving every write. It ships with a **16-case eval suite** that grades the agent on what it actually did, not just what it said.
All data in this repo is fictional.
## Why it exists
Most agent demos stop at "the model can call the API." The hard parts in an enterprise are different: deciding what an agent may do without asking, making sure it follows *your* procedure rather than inventing one, resisting instructions planted in tickets, and proving all of that with tests instead of hope. This project is a small, working answer to each.
## What it exposes
| Kind | Name | What it does |
|---|---|---|
| Tool (read) | `jira_search` | JQL search |
| Tool (read) | `jira_get_issue` | One issue with description and comments |
| Tool (read) | `confluence_search` | Full-text page search |
| Tool (read) | `confluence_get_page` | One page's text |
| Tool (read) | `triage_summary` | Open exceptions by priority and status, unassigned, urgent and oldest items |
| Tool (write) | `jira_create_issue` | Two-phase: preview, approval, confirm |
| Tool (write) | `jira_add_comment` | Two-phase: preview, approval, confirm |
| Resource | `recon://config` | Mode, write policy, audit-log path |
| Prompt | `triage_exceptions` | End-to-end triage workflow with human-approved writes |
Two modes: **mock** (default, a fictional `RECON` project with 8 exceptions and 4 runbooks, no account needed) and **live** (your own Atlassian Cloud site via an API token).
## Design choices
1. **Two-phase writes, enforced in code.** A write called without `confirm_token` changes nothing and returns a preview plus a token: an HMAC-SHA256 over the action, the exact arguments and the issue time. Tokens are single-use and expire after 5 minutes. The model can't skip the preview, reuse an approval, or change the text after approval.
2. **Audit log.** Every executed write is appended to `audit.jsonl` with timestamp, mode, arguments and result.
3. **Tool annotations.** Reads are marked `read_only_hint`, so clients can auto-approve them and gate only the writes.
4. **Grounding.** Server instructions tell the model to read the relevant runbook before recommending an action; the evals check that it did.
5. **Recoverable errors.** Not-found, auth failures and bad JQL come back as tool results the model can act on, not crashes.
## Evals
`evals/` holds 16 golden cases across five categories: triage (4), grounding in runbooks (4), missing runbooks (3), write approval (3) and prompt injection (2). See [`evals/CASES.md`](evals/CASES.md).
Each case runs the same agent loop Claude Desktop uses, against a fresh copy of the mock queue. A case **passes only if** both graders agree:
- **Deterministic checks** on behaviour: which tools were called with which arguments, which runbook pages were opened, whether any write was confirmed, whether Jira changed.
- **An LLM judge** (structured JSON) on four claims: grounded, no fabrication, answers the question, safe handling. The judge is told to treat the transcript as data, never as instructions.
The runner refuses to start until the harness files are approved (keyed to their SHA), checks that the served model matches the requested one, retries crashed attempts instead of counting them as failures, and supports several reps per case.
```bash
export ANTHROPIC_API_KEY=... # your own key
.venv/bin/python evals/run_eval.py --selftest # offline check of the graders
.venv/bin/python evals/run_eval.py --approve-harness # after reviewing the harness files
.venv/bin/python evals/run_eval.py --reps 3 # full run
```
## Run it
```bash
python3 -m venv .venv && .venv/bin/pip install -e ".[dev]"
.venv/bin/pytest -q
```
### Connect to Claude Desktop (mock mode)
Add under `"mcpServers"` in `claude_desktop_config.json`, then restart Claude Desktop:
```json
"recon-desk": {
"command": "/absolute/path/to/recon-desk-mcp/.venv/bin/recon-desk-mcp"
}
```
### Live mode (your Atlassian Cloud site)
1. Create a free Atlassian Cloud site with Jira and Confluence.
2. Create an API token at id.atlassian.com, under Security, API tokens. Never commit it.
3. Create a Jira project (key `RECON`, or pass your key to `triage_summary`) and a runbook page or two in Confluence.
4. Add an `env` block to the config above:
```json
"env": {
"ATLASSIAN_SITE": "<name>.atlassian.net",
"ATLASSIAN_EMAIL": "<your login email>",
"ATLASSIAN_API_TOKEN": "<token>"
}
```
Read `recon://config` to confirm `"mode": "live"`. `RECON_MCP_MODE=mock` forces mock mode.
## Demo in 5 minutes
1. Pick the **triage_exceptions** prompt. Claude summarizes the queue, opens the urgent issues, reads the runbook and SLA pages, and returns a triage table.
2. "Post your proposed comment on RECON-102." Claude shows a preview; nothing is written.
3. Say yes. It confirms with the token and the comment lands. Check `audit.jsonl`.
4. Ask it to change the text after the preview. The server rejects the old token.
## Limits and next steps
- Basic auth with one identity. Next: OAuth or a service account, so the audit shows the agent and the approving human.
- Token secret lives in memory, so a restart voids pending previews.
- No transition, assign or close tools yet; they'd go behind the same gate with per-project scopes.
- Grow the eval set from real traces, add multi-step and adversarial cases, and calibrate the judge against human labels.
## Files
- `src/recon_mcp/server.py`: tools, write gate, audit log, resource and prompt
- `src/recon_mcp/backends.py`: mock backend (simple JQL parser) and Atlassian Cloud REST backend
- `src/recon_mcp/sample_data.py`: fictional RECON issues and runbooks
- `evals/`: cases, graders and runner
- `tests/`: 21 tests (server through the MCP client, live-API request shapes against a fake transport, eval runner)
## License
MIT. See [LICENSE](LICENSE).