Skip to main content
Glama
ksh00500

Personal Brain MCP

by ksh00500
README.md
# Personal Brain MCP v0.2

A PostgreSQL-backed long-term personal-memory MCP server. It supports local Docker PostgreSQL and remote Neon PostgreSQL, and exposes a Streamable HTTP MCP endpoint for hosting on Render.

## MCP tools

- `get_personal_context`
- `save_memory`
- `query_personal_database` — model-generated read-only SQL only
- `update_context_manifest`

## Remote endpoints

- MCP: `POST /mcp` (Streamable HTTP)
- Health check: `GET /health`

## Local development with Docker PostgreSQL

```bash
cp .env.example .env
# Remove/comment DATABASE_URL in .env to use the local Docker settings.
docker compose up -d
npm install
npm run check
npm run dev
```

The server listens on `http://localhost:10000` by default.

## Neon / Render

Set these environment variables in Render:

```text
DATABASE_URL=<Neon connection string>
MCP_API_KEY=<long random secret, recommended>
USER_ID=main
USER_NAME=<your display name>
USER_LANGUAGE=ko
USER_TIMEZONE=Asia/Seoul
```

Render supplies `PORT` automatically. The app binds to `0.0.0.0:$PORT`.

Build command:

```bash
npm install && npm run build
```

Start command:

```bash
npm start
```

Health check path:

```text
/health
```

After deployment, the MCP endpoint is:

```text
https://<your-render-service>.onrender.com/mcp
```

If `MCP_API_KEY` is set, clients must send:

```text
Authorization: Bearer <MCP_API_KEY>
```

## Database initialization

On startup, the app safely creates the required tables and indexes if they do not already exist. pgvector is optional in v0.2; failure to enable it does not prevent startup.

## Security

- `.env` is ignored by Git.
- Never commit Neon connection strings, passwords, API keys, or tokens.
- `query_personal_database` accepts only one `SELECT`/`WITH` query, runs it in a read-only transaction, and caps output at 100 rows.