Skip to main content
Glama
renota-mcp
by colin4k
README.md
# renota-mcp

A local [MCP](https://modelcontextprotocol.io) server that lets an AI agent read **your own Renota knowledge base** — the clips you saved from the web, Zotero and the Android app — without anything leaving your computer.

Renota's cloud MCP (`https://api.renota.app/mcp`) is for subscribers and only sees what has been synced. This one is the free path: it talks to the Chrome extension over the loopback interface, so it works with a local-only library and needs no account, no API key and no upload.

```
AI client  ──stdio/HTTP──▶  renota-mcp  ──127.0.0.1──▶  Chrome extension  ──▶  IndexedDB
                            (your machine)
```

## Requirements

- Node.js 20 or newer
- Renota Chrome extension 1.1.0 or newer, with **Local agent access** turned on

## Quick start

1. Build it from source and install it as a local command. It is not on npm, so compile it once (Node 20+):

   ```bash
   git clone https://github.com/colin4k/renota-mcp ~/renota-mcp
   cd ~/renota-mcp
   npm install
   npm run build
   npm install -g .          # puts `renota-mcp` on your PATH
   ```

   Then run the setup once — it creates `~/.renota-mcp/config.json` and prints a pairing token:

   ```bash
   renota-mcp init
   ```

   > Prefer not to install globally? Run `node ~/renota-mcp/dist/cli.js init`, and use
   > `"command": "node"` with `"/Users/you/renota-mcp/dist/cli.js"` in every client config below.

   You will see something like:

   ```
   [renota-mcp] pairing token (paste into the extension): rmk_2Fq...
   [renota-mcp] bridge listening on http://127.0.0.1:9320
   ```

2. Open the extension's settings, turn on **Local agent access**, paste the token, keep the port at `9320`, and press **Test connection**. It should say *Connected*.

3. Add the server to your AI client (next section) and ask it something about your library:

   > What did I save about retrieval-augmented generation last month?

## Connect your AI client

### Claude Desktop

`~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows):

```json
{
  "mcpServers": {
    "renota": {
      "command": "renota-mcp",
      "args": []
    }
  }
}
```

### Claude Code

```bash
claude mcp add renota -- renota-mcp
```

### Cursor

`~/.cursor/mcp.json`:

```json
{
  "mcpServers": {
    "renota": {
      "command": "renota-mcp",
      "args": []
    }
  }
}
```

### Codex

`~/.codex/config.toml`:

```toml
[mcp_servers.renota]
command = "renota-mcp"
args = []
```

### Anything that speaks Streamable HTTP

```bash
renota-mcp --http --port 9320
# MCP endpoint: http://127.0.0.1:9320/mcp
```

## Tools

| Tool | What it does |
| --- | --- |
| `search_knowledge` | Full-text search (BM25 + RRF, Chinese-aware) over your clips. Filters: `type`, `origin`, `since`, `until`. |
| `get_clip` | Read one clip in full, including its surrounding context and tags. |
| `list_recent` | Most recently saved clips, newest first. |
| `knowledge_overview` | Totals by type, origin and domain, plus the time range of your library. |
| `bridge_status` | Diagnose the connection when something looks wrong. |

The server never generates answers itself — it returns your own material and lets the agent reason over it, so citations point at real clips.

## Security & privacy

- **Loopback only.** The server binds `127.0.0.1`. Nothing is reachable from your network.
- **Two independent checks.** Every request needs the pairing token (`Authorization: Bearer`), *and* an `Origin` header that is either absent or starts with `chrome-extension://`. Browsers set `Origin` themselves, so a random web page cannot reach the port even if it guesses the token.
- **Outbound, not inbound.** The extension polls the server; the server has no way to reach into the browser. Turning the switch off in settings stops all traffic immediately.
- **No telemetry, no account, no upload.** The server only reads what the extension hands it. Your knowledge base stays in your browser profile.

The token lives in `~/.renota-mcp/config.json`, readable only by your user (mode `0600`). Delete that file to unpair; the extension then shows *offline* until you paste a new token.

## Options

| Flag | Meaning |
| --- | --- |
| `--http` | Also serve MCP over Streamable HTTP on `--port` |
| `--port <n>` | Preferred port (default `9320`; falls back to the next 9 ports if taken) |
| `--token <t>` | Use this pairing token instead of the one in the config file |
| `renota-mcp token` | Print the current pairing token |

Environment variables: `RENOTA_MCP_HOME` (config directory), `RENOTA_MCP_PORT`, `RENOTA_MCP_TOKEN`.

## Troubleshooting

**The extension says "offline".** The server is not running, or the port does not match. Start it and press *Test connection* again. `curl http://127.0.0.1:9320/bridge/health` answers without a token and tells you whether the server is up and whether the extension has attached.

**`extension_offline` from a tool call.** The MCP server is running but the extension is not polling. Check the switch in the extension settings, and that the token matches the one the server printed.

**Nothing comes back from search.** Searches are lexical. If the wording in your clips is very different from the query, try the key terms instead of a full sentence; `knowledge_overview` tells you whether the library is empty.

**Port already in use.** The server tries `9320`–`9329` in order and logs the port it settled on. If it moves, set the same port in the extension settings.

## Development

```bash
npm install
npm run build
npm test          # bridge protocol tests
node scripts/smoke.mjs   # end-to-end: fake extension + real MCP handshake
```

The wire protocol lives in `src/bridge/protocol.ts` and is mirrored in the extension at `contextflow/src/background/local-agent-protocol.ts`. Change both together and bump `BRIDGE_PROTOCOL_VERSION`.

## License

MIT