Skip to main content

Local MCP Server

Hindsight provides a local MCP server that runs entirely on your machine with an embedded PostgreSQL database. No external server or database setup required.

This is ideal for:

  • Personal use with Claude Code / Claude Desktop — Give Claude long-term memory across conversations
  • Development and testing — Quick setup without infrastructure
  • Privacy-focused setups — All data stays on your machine

How It Works

Running hindsight-local-mcp starts the full Hindsight API on localhost:8888 with an embedded PostgreSQL database (pg0). You then connect your MCP client to it over HTTP.

  • Starts an embedded PostgreSQL (pg0) automatically
  • Runs database migrations on startup
  • Exposes the full MCP endpoint at http://localhost:8888/mcp/
  • Data persists in ~/.pg0/hindsight-mcp/ across restarts

Setup

1. Start the server

HINDSIGHT_API_LLM_API_KEY=sk-... uvx --from hindsight-api hindsight-local-mcp

Or with Ollama (no API key needed):

HINDSIGHT_API_LLM_PROVIDER=ollama HINDSIGHT_API_LLM_MODEL=llama3.2 uvx --from hindsight-api hindsight-local-mcp

2. Configure your MCP client

Claude Code:

claude mcp add --transport http hindsight http://localhost:8888/mcp/

Other MCP clients — add an HTTP transport entry pointing to http://localhost:8888/mcp/.

Bank Modes

The local server supports the same two modes as the hosted API:

Multi-bank mode (default)

Use http://localhost:8888/mcp/ — exposes all tools including bank management. Bank is selected per-request via the bank_id tool parameter or the X-Bank-Id header.

claude mcp add --transport http hindsight http://localhost:8888/mcp/

Single-bank mode

Use http://localhost:8888/mcp/<bank-id>/ — pins all tools to one bank, no bank_id parameter needed. This replaces the old HINDSIGHT_API_MCP_LOCAL_BANK_ID env var.

claude mcp add --transport http hindsight http://localhost:8888/mcp/my-bank/

Available Tools

The local server exposes the full tool set (29 tools in multi-bank mode, 26 in single-bank mode):

Core Memory

ToolDescription
retainStore information to long-term memory with optional tags, metadata, and document association
recallSearch memories with natural language, configurable budget, type filters, and tag filters
reflectSynthesize memories into a reasoned answer with optional structured output

Mental Models

ToolDescription
list_mental_modelsList pinned reflections for a bank
get_mental_modelGet a specific mental model
create_mental_modelCreate a new mental model with optional auto-refresh trigger
update_mental_modelUpdate a mental model's metadata
delete_mental_modelDelete a mental model
refresh_mental_modelRegenerate a mental model's content

Directives

ToolDescription
list_directivesList directives that guide memory processing
create_directiveCreate a new directive
delete_directiveDelete a directive

Memory Browsing

ToolDescription
list_memoriesBrowse memories with filtering and pagination
get_memoryGet a specific memory by ID
delete_memoryDelete a specific memory

Documents

ToolDescription
list_documentsList ingested documents
get_documentGet a specific document
delete_documentDelete a document and its linked memories

Operations

ToolDescription
list_operationsList async operations with status filtering
get_operationCheck operation status and progress
cancel_operationCancel a pending or running operation

Tags & Bank Management

ToolDescription
list_tagsList unique tags used in a bank
get_bankGet bank profile (name, mission, disposition)
get_bank_statsGet bank statistics (multi-bank only)
update_bankUpdate bank name or mission
delete_bankDelete an entire bank and all its data
clear_memoriesClear memories without deleting the bank
list_banksList all memory banks (multi-bank only)
create_bankCreate or configure a memory bank (multi-bank only)

For detailed parameter documentation, see the MCP Server reference.

Environment Variables

All standard Hindsight configuration variables are supported. Key ones for local use:

VariableRequiredDefaultDescription
HINDSIGHT_API_LLM_API_KEYYes*API key for your LLM provider
HINDSIGHT_API_LLM_PROVIDERNoopenaiLLM provider (openai, anthropic, ollama, etc.)
HINDSIGHT_API_LLM_MODELNogpt-4o-miniModel name
HINDSIGHT_API_DATABASE_URLNopg0://hindsight-mcpOverride the database URL
HINDSIGHT_API_PORTNo8888Port to listen on
HINDSIGHT_API_LOG_LEVELNoinfoLog level

*Not required when using a local provider like Ollama.

Troubleshooting

Slow first startup

The first startup downloads the local embedding model (~100MB) and initializes the database. Subsequent starts are faster.

Port already in use

Set a different port:

HINDSIGHT_API_LLM_API_KEY=sk-... HINDSIGHT_API_PORT=9000 uvx --from hindsight-api hindsight-local-mcp

Then update your MCP client URL to http://localhost:9000/mcp/.

Checking logs

Set HINDSIGHT_API_LOG_LEVEL=debug for verbose output:

HINDSIGHT_API_LLM_API_KEY=sk-... HINDSIGHT_API_LOG_LEVEL=debug uvx --from hindsight-api hindsight-local-mcp