Skip to content

Quickstart, Self-Hosted

From nothing to agents that remember

Myco Brain is an open-source memory layer for AI agents, licensed Apache-2.0. Start with memory: one command sets up the database, a starter template, and every agent it finds on your machine. The document engine (ingest, knowledge graph, dynamic schema) is optional and comes second.

Before you start

  • Node.js 20 or later and a terminal
  • Claude Code, Codex, Cursor, Windsurf, or Claude Desktop
  • Postgres with pgvector, or Docker so setup can start one for you (optional: Ollama for local embeddings)
  • No API keys

Part 1

Memory, in one command

  1. Step 1

    Install and run setup

    Setup asks a few questions (database, business name, your name, template, which tools to connect), shows what it is about to change, and waits for a yes before each part. It finishes by writing one fact and recalling it.

    npm install -g @mycobrain/mcp-server
    mycobrain-setup memory

    Database: setup uses a local Postgres with pgvector if it finds one, or offers to start one in Docker. If neither is there, it prints the install commands and changes nothing.

    Templates: agency, design studio, architecture or landscape firm, solo consultant, or custom (a short guided interview).

    Claude Code and Codex get hooks: recall at session start and on each prompt, and capture of finished sessions. Cursor, Windsurf and Claude Desktop get an MCP server with the two memory tools.

    Each changed file is backed up first, nothing secret is written into it, and running setup again adds nothing twice.

  2. Step 2

    Or use Supabase, Neon, RDS, or any Postgres

    Put the connection string in an environment variable and pass a reference to it, so it never lands in your shell history. On Supabase, use the direct connection or the session pooler on port 5432.

    export MYCOBRAIN_DATABASE_URL='postgresql://...'
    mycobrain-setup memory --database url --database-url-ref env:MYCOBRAIN_DATABASE_URL
  3. Step 3

    Add your clients

    Houses keep clients apart. Entities are the people, projects and companies inside them. Only you create them, so an agent can never widen its own scope.

    mycobrain-memory house add riverton-parks "City of Riverton Parks"
    mycobrain-memory entity add "Riverside Park renovation" --kind project --house riverton-parks

    When a fact changes, the new one supersedes the old one. mycobrain-memory history <ref or id> shows both and the reason.

  4. Step 4

    Check it, any time

    The doctor reports the config, the database, each tool's credential, the hooks, the background worker and Ollama, with the fix for anything that is off.

    mycobrain-doctor --memory

Next: scoping an agent to one client, the background worker, Dream, and uninstall are in the memory quickstart and the memory CLI reference.

Part 2, optional

Add the document engine

The engine ingests files, folders and repos, builds a knowledge graph, and grows its own schema. One docker compose up boots it, with no API keys.

  1. Step 1

    Boot the stack

    Clone the repo and bring everything up with Docker Compose. Three services start: Postgres 16 + pgvector, the MCP server, and the extraction worker, with a seeded default workspace, so it works with zero configuration.

    git clone https://github.com/thegoodguysla/myco-brain.git
    cd myco-brain
    docker compose up -d

    Verify with docker compose ps.

  2. Step 2

    See it work in 30 seconds

    Ingest the bundled demo corpus, a small set of interconnected documents for a fictional agency and its client. Full-text (BM25) search and ingestion are keyless, so no API key is needed.

    npx -y -p @mycobrain/mcp-server mycobrain-ingest ./examples/demo-corpus

    After connecting your client in the next step, ask: “When does Northwind’s rebrand launch, and who owns the account?”

    Follow up with: “Show me the source for that.”

  3. Step 3

    Connect Claude Desktop

    Add Myco Brain to ~/Library/Application Support/Claude/claude_desktop_config.json, then restart Claude Desktop. Using Cursor, Windsurf, Continue, or Zed instead? Point your client’s MCP settings at the same command and env vars.

    {
      "mcpServers": {
        "myco-brain": {
          "command": "npx",
          "args": ["-y", "@mycobrain/mcp-server"],
          "env": {
            "DATABASE_URL": "postgresql://brain:brain@localhost:5432/brain",
            "BRAIN_WORKSPACE_ID": "00000000-0000-0000-0000-000000000001",
            "BRAIN_API_KEY": "brain_00000000-0000-0000-0000-000000000001_00000000-0000-0000-0000-0000000000a1_localdev"
          }
        }
      }
    }

    These exact values work for everyone, on purpose. localhost is your own machine (the Docker stack from the first engine step), and the workspace ID and API key are local-dev defaults seeded into every fresh install. Your database, on your computer; nothing is shared between installs.

    Happy-path test: save a memory in one session (“remember that the board meeting is every Wednesday at 9 AM Pacific”), open a fresh session, and ask for it back.

  4. Step 4

    Bulk ingest your own knowledge

    Point the ingest CLI at a local folder or a whole GitHub repo. It skips binaries and noise directories like node_modules and .git automatically.

    export DATABASE_URL=postgresql://brain:brain@localhost:5432/brain
    export BRAIN_WORKSPACE_ID=00000000-0000-0000-0000-000000000001
    export BRAIN_API_KEY=brain_00000000-0000-0000-0000-000000000001_00000000-0000-0000-0000-0000000000a1_localdev
    
    npx -y -p @mycobrain/mcp-server mycobrain-ingest ./docs
    npx -y -p @mycobrain/mcp-server mycobrain-ingest github:owner/repo

    Set GITHUB_TOKEN to ingest private repos.

Engine, level up

Semantic search, fully local

Set BRAIN_EMBED_PROVIDER=ollama (with BRAIN_OLLAMA_BASE_URL and the nomic-embed-text model pulled) for keyless vector search via local embeddings, auto-selected when Ollama is configured and no OpenAI key is present. Prefer hosted? BRAIN_OPENAI_API_KEY still works. Full-text search stays keyless either way.

Knowledge graph, fully local

Set BRAIN_OLLAMA_BASE_URL (e.g. http://host.docker.internal:11434) to extract entities and relationships with a local Ollama model, no API key, nothing leaves your machine. Extraction is direction-aware as of v1.1.0.

Knowledge graph, most accurate

Set BRAIN_ANTHROPIC_API_KEY to use Anthropic for extraction, it produces the most accurate graph.

Where everything lives

  • github.com/thegoodguysla/myco-brain , source, issues, and the API reference (15 MCP tools with the engine, 2 in memory-only mode) in docs/api-reference.md
  • @mycobrain/mcp-server on npm , ships mycobrain-setup, mycobrain-memory, mycobrain-doctor, the mycobrain-mcp server and the mycobrain-ingest CLI
  • Licensed Apache-2.0, the core stays self-hostable and open source.
Quickstart, Self-Hosted Myco Brain