Metadata-Version: 2.4
Name: logseq-2-mcp
Version: 0.7
Summary: MCP server for semantic search over Logseq journal entries
Author-email: DL <v49t9zpqd@mozmail.com>
License: MIT
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: fastmcp>=3.2.4
Requires-Dist: boto3
Requires-Dist: gunicorn>=22.0.0
Requires-Dist: python-dotenv
Requires-Dist: logseq-retriever>=0.5.1
Requires-Dist: psycopg[binary]>=3.0.0
Provides-Extra: dev
Requires-Dist: ruff>=0.15.0; extra == "dev"
Requires-Dist: ty>=0.0.34; extra == "dev"
Requires-Dist: boto3-stubs; extra == "dev"
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
Dynamic: license-file

# Bestie MCP

MCP server for semantic search over Logseq journal entries, backed by PGVector and Amazon Bedrock embeddings.

## Requirements

- Python 3.11+
- PostgreSQL with the `pgvector` extension
- AWS credentials with Bedrock access (Titan Embed v2 + Claude)

## Setup

```bash
pip install -e .
cp .env.example .env  # edit with your values
```

**Environment variables:**

| Variable | Default | Description |
|---|---|---|
| `PGVECTOR_DB_URL` | `postgresql+psycopg://postgres:postgres@localhost:5432/postgres` | Postgres connection string |
| `BEDROCK_AWS_PROFILE` | — | AWS profile name (takes precedence over key/secret) |
| `BEDROCK_IAM_ACCESS_KEY` | — | AWS access key ID |
| `BEDROCK_IAM_SECRET_KEY` | — | AWS secret access key |

## Transports

### Streamable HTTP (recommended — for LibreChat, Claude Code, remote use)

The server runs on port `9999` by default and exposes the MCP endpoint at `/mcp`.

```bash
# direct
python -m logseq_mcp.main

# with options
python -m logseq_mcp.main --host 0.0.0.0 --port 9999

# via env var
MCP_TRANSPORT=http python -m logseq_mcp.main
```

**Claude Code** — add to `.mcp.json` in your project root:

```json
{
  "mcpServers": {
    "logseq": {
      "type": "http",
      "url": "http://localhost:9999/mcp"
    }
  }
}
```

**LibreChat** — add to `librechat.yaml`:

```yaml
mcpServers:
  logseq:
    type: streamable-http
    url: http://localhost:9999/mcp
```

### stdio (for local Claude Desktop / CLI use)

```bash
python -m logseq_mcp.main --transport stdio

# via env var
MCP_TRANSPORT=stdio python -m logseq_mcp.main
```

**Claude Code** — add to `.mcp.json`:

```json
{
  "mcpServers": {
    "logseq": {
      "type": "stdio",
      "command": "python",
      "args": ["-m", "logseq_mcp.main", "--transport", "stdio"],
      "env": {
        "PGVECTOR_DB_URL": "postgresql+psycopg://postgres:postgres@localhost:5432/postgres",
        "BEDROCK_AWS_PROFILE": "your-profile"
      }
    }
  }
}
```

## Docker

Runs streamable HTTP on port `9999` via gunicorn + UvicornWorker (4 workers by default).

```bash
docker build -t logseq-mcp .
docker run -p 9999:9999 \
  -e PGVECTOR_DB_URL=postgresql+psycopg://user:pass@host:5432/db \
  -e BEDROCK_IAM_ACCESS_KEY=... \
  -e BEDROCK_IAM_SECRET_KEY=... \
  logseq-mcp
```

To tune the worker count:
```bash
docker run -p 9999:9999 ... logseq-mcp \
  gunicorn logseq_mcp.main:app \
  --worker-class uvicorn.workers.UvicornWorker \
  --workers 2 \
  --bind 0.0.0.0:9999
```

Health check: `GET /health`

## Tools

### `search_journal_entries`

Semantic search over Logseq journal entries using vector similarity.
