Metadata-Version: 2.5
Name: membannk
Version: 0.1.1
Summary: One local memory shared by all your AI assistants (Claude, ChatGPT, Gemini, Grok) over MCP.
Project-URL: Homepage, https://github.com/BharanitharanR/membannk
License-Expression: MIT
License-File: LICENSE
Keywords: chatgpt,claude,gemini,knowledge-base,llm,mcp,memory,txtai
Classifier: Operating System :: MacOS
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.10
Requires-Dist: docling>=2.0
Requires-Dist: fastapi>=0.115
Requires-Dist: mcp>=2.3
Requires-Dist: ngrok>=1.4
Requires-Dist: pyside6>=6.7
Requires-Dist: txtai[pipeline-audio,pipeline-data,workflow]>=9.0
Requires-Dist: uvicorn>=0.30
Description-Content-Type: text/markdown

# MemBannk

**One memory shared by all your AI assistants.** Start a thread in Claude, pick it up in ChatGPT, then finish it in Gemini, without pasting the history across.

MemBannk is a small desktop app that runs on your Mac. It keeps:

- **Conversation checkpoints.** An assistant saves a structured snapshot (topic, summary, decisions, open questions, next steps). Any other assistant can `resume` it later, by exact topic name or just by describing it ("where was I with the launch plan?").
- **A personal knowledge base.** Drop in Markdown, text, PDFs, folders, `.zip` archives, or even video and audio (transcribed locally with Whisper). Everything is searchable by meaning.

Assistants reach it over the [Model Context Protocol (MCP)](https://modelcontextprotocol.io). Data stays on your machine in SQLite and a txtai vector index. The optional ngrok tunnel only lets web assistants talk to your machine; nothing is stored in the cloud.

## Install

```bash
pip install membannk
```

Python 3.10+ is required, and a virtual environment is recommended. The first launch downloads about 500 MB of models (MiniLM embeddings, Docling, Whisper base).

## Run

```bash
membannk
```

A window opens and the MCP server starts at `http://127.0.0.1:8000/mcp`. Leave the window open while you work.

### Make it reachable from ChatGPT, Gemini and claude.ai (ngrok)

Web assistants can't see `127.0.0.1`, so they need a public HTTPS URL. The ngrok tunnel is built in, with no separate binary to install:

```bash
membannk --set-ngrok-token <your-ngrok-authtoken>   # once; free at dashboard.ngrok.com
membannk --tunnel --domain <your-static-domain>.ngrok-free.app
```

The window shows a **public MCP URL** like `https://<domain>/<secret>/mcp`. The secret path is generated once and saved in `~/.membannk/path_token`. Every other path returns 404, so **treat the whole URL like a password**. To rotate it, run `membannk --new-secret`. `membannk --show-url` prints the URL again.

### Already have a reverse proxy and tunnel?

If one ngrok domain already fronts nginx (or Caddy) for other apps, run `membannk --behind-proxy` instead. It enforces the same secret path but opens no tunnel of its own. In nginx, pass `/<secret>/` to MemBannk unchanged:

```nginx
location ~ "^/[A-Za-z0-9_-]{32}/" {
    proxy_pass http://127.0.0.1:8000;   # no trailing slash: MemBannk checks and strips the secret
    proxy_http_version 1.1;
    proxy_set_header Connection "";
    proxy_buffering off;                # needed for MCP streaming
    proxy_read_timeout 3600s;
}
```

MemBannk returns 404 for any path without the right secret, so `membannk --new-secret` never needs an nginx change.

## Connect your assistants

| Assistant | How |
|---|---|
| Claude Code | `claude mcp add --transport http membannk http://127.0.0.1:8000/mcp` |
| Cursor / VS Code | Add an MCP server with URL `http://127.0.0.1:8000/mcp` |
| Claude (desktop / claude.ai) | Settings → Connectors → Add custom connector → paste the public URL |
| ChatGPT | Settings → Apps & Connectors → Advanced → Developer mode → Create connector → paste the public URL |
| Gemini | Settings → Connectors / MCP servers → Connect to an MCP server → paste the public URL |

Menu names move around as these apps update. Look for "custom connector" or "MCP server".

## Use it

Just talk normally:

- *"Save this as **MemBannk launch plan**."* The assistant calls `save_context`.
- In another assistant: *"Resume the MemBannk launch plan"* or *"where was I with the launch?"* The assistant calls `resume` and continues from the latest checkpoint, with earlier checkpoints and related KB material attached.
- *"What did my notes say about pricing?"* The assistant calls `search_kb`.

### Tools

| Tool | What it does |
|---|---|
| `save_context(topic, summary, decisions, open_questions, next_steps, source)` | Save a checkpoint |
| `resume(query, history=3, include_kb=True)` | Load the latest checkpoint(s) for a topic, matched by name, meaning or keyword |
| `list_topics()` | List saved threads |
| `search_kb(query, limit=3)` | Semantic search over ingested files |
| `ingest_paths(paths)` | Ingest files, folders or `.zip` archives from disk |
| `kb_stats()` | Count indexed chunks |

REST endpoints are also available: `POST /ingest`, `GET /search?query=`, `GET /health`.

### Claude Code: pull memory at session start (optional)

`hooks/membannk-session-start.sh` is a SessionStart hook that tells Claude to check MemBannk for the current project before it starts work. Add it to `~/.claude/settings.json`:

```json
{
  "hooks": {
    "SessionStart": [
      { "hooks": [{ "type": "command", "command": "/path/to/membannk/hooks/membannk-session-start.sh" }] }
    ]
  }
}
```

## Configuration

| Env var | Default | Meaning |
|---|---|---|
| `MEMBANNK_PORT` | `8000` | Port (`--port` overrides it) |
| `MEMBANNK_HOST` | `127.0.0.1` | Listen address |
| `MEMBANNK_DATA_DIR` | `~/Library/Application Support/LocalKB` | Where the index and `contexts.db` live |
| `MEMBANNK_PATH_TOKEN` | *(auto with `--tunnel`)* | Secret path prefix |
| `NGROK_AUTHTOKEN` | `~/.membannk/ngrok_auth` | ngrok authtoken |
| `MEMBANNK_NGROK_DOMAIN` | `~/.membannk/ngrok_domain` | Static ngrok domain |

## Security notes

- Without `--tunnel`, the server only listens on `127.0.0.1`.
- With `--tunnel`, anyone who has the full URL can read your checkpoints and KB. They can also call `ingest_paths` to index files from your disk. Keep the URL private, rotate it with `--new-secret` if it leaks, and stop the app when you don't need remote access.

## License

MIT
