Open Brain System The open-source AI-integrated brain system — pgvector + MCP + Supabase

MCP and the Open Brain: Why Model Context Protocol Matters

Model Context Protocol is the TCP/IP of AI memory. An open brain without MCP support is a silo. With it, any AI client — Claude Desktop, Cursor, Zed — reads from the same store.


What MCP Is, Briefly

Standardizing LLM Connectivity

The Model Context Protocol (MCP), released by Anthropic in November 2024, is an open-source standard designed to decouple AI applications from the data sources they consume. It utilizes JSON-RPC 2.0 to create a universal interface between LLM hosts and external systems, eliminating the need for fragmented, proprietary connectors.

Architecture Components

The protocol operates on a client-server model similar to the Language Server Protocol (LSP). In this ecosystem, Hosts (such as Claude Desktop, Cursor, or Zed) initiate connections via embedded Clients. These clients communicate with Servers that expose three primary primitives:

  • Resources: Read-only data sources, such as local files or API responses, that provide static context.
  • Tools: Executable functions that allow the LLM to perform actions, such as querying a database or triggering a webhook.
  • Prompts: Pre-defined templates that guide the LLM through specific complex workflows.

By implementing an MCP open brain memory system, developers ensure that any compatible AI client can access a centralized knowledge base without rewriting integration logic for every new tool.

Why an Open Brain Needs MCP

Solving the N×M Integration Problem

Traditional AI integrations suffer from exponential complexity. If a user maintains five different memory stores (e.g., Notion, Obsidian, Postgres, Slack, and Gmail) and utilizes six different AI clients (e.g., Claude, ChatGPT, Cursor, Zed, Perplexity, and custom agents), they face an N×M problem requiring 30 distinct integrations to achieve full connectivity.

Linear Scaling via Standardization

MCP transforms this complexity into a linear N+M model. By deploying a single MCP server for each memory store, every compatible client gains immediate access to that data. The architectural shift moves the burden of integration from the client-side to a standardized server layer.

The Open Brain Architecture

An Open Brain system leveraging Supabase and pgvector benefits most from this approach. Instead of building custom plugins for every IDE or chat interface, the developer exposes one MCP server that interfaces with the Postgres vector store. This allows a unified memory state where an agent in Cursor can retrieve the same context as a prompt in Claude Desktop.

Metric Custom Integrations (N×M) MCP Standard (N+M)
Development Effort High (per client/source pair) Low (once per source)
Maintenance Fragile; breaks on API updates Stable; centralized server logic
Interoperability Siloed Universal across MCP hosts

A Working MCP Server, Complete

Implementing Vector Memory Retrieval

The following Python implementation creates an MCP server that connects to a Supabase instance. It uses pgvector for cosine similarity searches and the Nomic Embed API to vectorize incoming queries, enabling high-precision AI memory retrieval.

import asyncio
from mcp.server.fastmcp import FastMCP
import psycopg
from pgvector.psycopg2 import register_vector
import requests

# Initialize MCP Server
mcp = FastMCP("OpenBrain-Memory")

SUPABASE_DB_URL = "postgresql://postgres:[PASSWORD]@db.[REF].supabase.co:5432/postgres"
NOMIC_API_KEY = "your_nomic_key"

async def get_embedding(text):
    resp = requests.post(
        "https://api.nomic.ai/v1/embeddings",
        headers={"Authorization": f"Api-Key {NOMIC_API_KEY}"},
        json={"model": "nomic-embed-text-v1.5", "text": text}
    )
    return resp.json()["embedding"]

@mcp.tool()
async def search_memories(query: str) -> str:
    """Search the open brain memory for relevant context using vector similarity."""
    embedding = await get_embedding(query)
    
    with psycopg.connect(SUPABASE_DB_URL) as conn:
        # pgvector registration is handled via the connection
        with conn.cursor() as cur:
            cur.execute(
                "SELECT content, metadata FROM memories ORDER BY embedding <=> %s LIMIT 5",
                (embedding,)
            )
            results = cur.fetchall()
            
    if not results:
        return "No relevant memories found."
        
    formatted = "\n---\n".join([f"{r[0]} (Meta: {r[1]})" for r in results])
    return f"Top 5 matching memories:\n{formatted}"

if __name__ == "__main__":
    mcp.run()

Client Configuration

To register this server in Claude Desktop, add the following entry to the claude_desktop_config.json file located in the application support folder:

{
  "mcpServers": {
    "open-brain": {
      "command": "python",
      "args": ["/path/to/your/server.py"]
    }
  }
}

Where to Go From Here

Expanding Memory Capabilities

The basic retrieval tool is a starting point. To build a fully autonomous MCP open brain memory, developers should implement bidirectional tools. Adding insert_memory and update_memory functions allows the LLM to not only read from its history but actively curate its own knowledge base in real-time.

Implementing Static Resources

Beyond tools, MCP supports resources. By exposing the entire memory index as a browsable resource, users can allow an AI to scan the structure of their knowledge graph or list all available memory categories without performing a vector search first.

Implementing a 'get_related' tool that recursively fetches linked memories allows for multi-hop reasoning, moving beyond simple RAG into complex cognitive retrieval.

Technical Documentation

For the full protocol specification, refer to modelcontextprotocol.io. For a production-ready reference implementation of these concepts, the NovCog Brain starter repository on GitHub provides maintained templates for Supabase and pgvector integration.

Questions answered

What readers usually ask next.

What is Model Context Protocol (MCP)?
Introduced by Anthropic in November 2024, the Model Context Protocol is an open-source standard that uses JSON-RPC 2.0 to connect LLMs to external data and tools. It replaces fragmented custom integrations with a universal client-server architecture, allowing AI hosts to access files, databases, and APIs through a standardized interface.
How do I write an MCP server in Python?
You can build a server using the official MCP Python SDK available on GitHub. By implementing JSON-RPC handlers, you define 'tools' for actions, 'resources' for data, and 'prompts' for workflows; these are typically served over stdio or HTTP to be consumed by an MCP-compliant host.
Can Claude Desktop use MCP with Supabase?
Yes. Since Supabase is built on PostgreSQL, you can run an MCP server that connects to your Supabase instance via a connection string. This allows Claude Desktop to execute SQL queries or vector searches directly against your Supabase tables using the MCP tool-calling framework.
What's the difference between MCP and OpenAI function calling?
While function calling is a model capability to output structured arguments, MCP is a full architectural standard for how those functions are hosted and discovered. MCP decouples the tool implementation from the LLM application, enabling one server to work across multiple different AI clients without rewriting the integration.
Is MCP open source?
Yes, the Model Context Protocol is an open-source standard. Anthropic has released the specifications and SDKs publicly to encourage a broad ecosystem of servers and clients, preventing vendor lock-in for AI data integrations.
Which AI clients support MCP?
Claude Desktop was the primary launch partner, but the standard is being adopted by other major players including OpenAI, Google DeepMind, Replit, and Sourcegraph. Any LLM application that implements the MCP client specification can connect to any MCP-compliant server.
How do I add pgvector search to an MCP server?
Integrate the pgvector Python library with your MCP server's tool definitions. Create a specific `@method` (tool) that accepts a query embedding, executes a cosine similarity search in Postgres using `pgvector`, and returns the most relevant document chunks as context for the LLM.
Does Supermemory use MCP?
Supermemory focuses on personal knowledge management; while it shares goals with MCP regarding AI memory, you should check their latest documentation to see if they have implemented the specific Anthropic MCP standard for external connectivity.
What is the MCP claude_desktop_config.json?
This is the configuration file used by Claude Desktop to identify and launch MCP servers. It contains a JSON object where you specify the runtime (e.g., node or python) and the environment variables needed for the server to connect to your local data sources.
Can I use MCP with Cursor?
Cursor is rapidly evolving its AI context features; while it has native indexing, adding MCP support would allow it to query external databases and tools using the same standardized protocol used by Claude Desktop. Check your current version's settings for 'MCP' or 'External Tools'.
How fast is MCP over a local Postgres?
Latency is minimal because MCP typically communicates via stdio or local HTTP, and Postgres handles indexed vector searches in milliseconds. The primary bottleneck is usually the LLM's inference time rather than the JSON-RPC overhead of the MCP server fetching data from a local database.