Content
# trinity
A recurrent **generative / critical / synthetic (G/C/S)** reasoning loop, exposed as a [Model Context Protocol](https://modelcontextprotocol.io) server.
`trinity` is **key-less**: it makes **no LLM calls of its own**. it drives the **host agent's own model** through the reasoning loop using ordinary MCP tools. Your host (e.g. Claude Code) provides the intelligence and pays for it through its existing session — `trinity` provides the structure.
## What it does
A single reasoning run iterates three roles over a shared JSON state:
- **Generative (G)** — expands the current hypothesis and adds supporting evidence.
- **Critical (C)** — challenges the hypothesis, naming gaps and weak claims.
- **Synthetic (S)** — integrates G and C, updates confidence, and decides whether to continue, verify, or halt.
The loop carries state across iterations and stops on an explicit halt signal (gated by a confidence floor and a minimum-iteration count), an optional plateau/convergence detector, or a maximum iteration budget.
## How it works (key-less orchestration)
`trinity` exposes three tools and runs the loop as a turn-by-turn dialogue with the host:
1. **`reason_start`** `{ problem, profile?, max_iterations? }` → returns the first step: a prompt for one stream (G, C, or S) and instructions to produce a JSON state-patch.
2. You (the host model) generate that stream's output and call **`reason_submit`** `{ session_id, output }`.
3. `trinity` merges the patch, advances the loop, and returns the next step — or, when the loop halts, the final `{ answer, confidence, iterations, halt_reason }`.
4. **`reason_cancel`** `{ session_id }` discards an in-progress run.
Because every generation is produced by the host's model, the server needs **no API key and no OAuth**.
## Requirements
- Node.js ≥ 18.
- An MCP host that lets its model drive a multi-step tool sequence. **v1 targets [Claude Code](https://www.claude.com/product/claude-code).** Support for other hosts may follow.
- No API key. No OAuth. No configuration.
> Note on MCP "sampling": the MCP spec's `sampling/createMessage` (where a server requests a completion from the host) would be the obvious transport for a key-less server, but it is **not implemented by current CLI hosts** and is being deprecated. `trinity` deliberately uses the **orchestration-as-tool** approach above, which works on hosts available today.
## Install (Claude Code)
```bash
npm install
npm run build
```
Then register the server:
```bash
claude mcp add trinity -- node /absolute/path/to/trinity/dist/server.js
```
or add it to a project `.mcp.json`:
```json
{
"mcpServers": {
"trinity": {
"command": "node",
"args": ["./dist/server.js"]
}
}
}
```
## Profiles
`profile` sets the iteration budget and halt confidence floor:
| profile | max iterations | halt confidence floor |
|---|---|---|
| `fast` | 2 | 0.70 |
| `balanced` (default) | 4 | 0.80 |
| `deep` | 16 | 0.85 |
| `max` | 32 | 0.90 |
`max_iterations` overrides the budget for a single run.
## Development
```bash
npm run typecheck # tsc --noEmit
npm run build # bundle to dist/server.js
node test/smoke.mjs # end-to-end smoke test with a scripted host
```
## License
MIT. See [LICENSE](./LICENSE).