MCP Servers

A collection of Model Context Protocol servers, templates, tools and more.

This repository contains edge functions designed to run on Supabase, serving as the backend for a personal "Open Brain" knowledge base. It allows you to capture thoughts directly through Discord slash commands and interact with those captured thoughts via a Model Context Protocol (MCP) server that can be integrated with various AI clients.

Created 3/4/2026
Updated about 4 hours ago
Repository documentation and setup instructions

Supabase Open Brain MCP & Ingestion

This repository contains edge functions designed to run on Supabase, serving as the backend for a personal "Open Brain" knowledge base. It allows you to capture thoughts directly through Discord slash commands and interact with those captured thoughts via a Model Context Protocol (MCP) server that can be integrated with various AI clients. From Nate Jone's "Open Brain" concept.

Features

This project utilizes two Supabase Edge Functions:

1. ingest-thought (Discord Webhook Integration)

This edge function accepts incoming Discord interactions (slash commands).

  • Functionality: Captures text from a /capture <thought> slash command.
  • Workflow:
    • Verifies the incoming Discord request signature to ensure authenticity.
    • Automatically fetches text embeddings for the thought using OpenAI (text-embedding-3-small) via OpenRouter.
    • Uses an LLM (gpt-4o-mini) via OpenRouter to extract structured metadata (people mentioned, action items, dates, topics, and thought type).
    • Inserts the thought, its vector embedding, and extracted metadata into a Supabase PostgreSQL database.
    • Responds to the Discord user confirming what was captured.

2. open-brain-mcp (Model Context Protocol Server)

This edge function exposes a Model Context Protocol (MCP) server endpoint for AI assistants to talk to your brain.

  • Functionality: Allows connected AI clients to read from, search, and write to your "thoughts" database directly.
  • Tools Provided:
    • search_thoughts: Perform vector similarity search on past thoughts.
    • list_thoughts: List recently captured thoughts with optional filtering by type, topic, person, or date limit.
    • thought_stats: Get aggregate statistics about the database (total counts, top topics, people).
    • capture_thought: Capture new thoughts instantly through the MCP client, generating embeddings and extracting metadata on the fly.
  • Security: Protected endpoint requiring either an x-brain-key header or a ?key= URL parameter.

Prerequisites

  1. A created project on Supabase with pgvector enabled.
  2. A Discord Developer Application (for the /capture bot).
  3. An OpenRouter Account (for AI models/embeddings).
  4. Supabase CLI installed locally to deploy Edge Functions.

Database Setup

Before deploying the functions, you must configure your Supabase SQL database. Run the following SQL commands in your Supabase SQL Editor:

-- Create the vector extension if not already enabled
create extension if not exists vector;

-- Create the thoughts table
create table thoughts (
  id uuid primary key default gen_random_uuid(),
  created_at timestamp with time zone default now(),
  content text not null,
  embedding vector(1536), -- Dimension corresponds to text-embedding-3-small
  metadata jsonb default '{}'::jsonb
);

-- Recommended: Index for faster similarity search
create index on thoughts using hnsw (embedding vector_ip_ops);

-- Create the RPC function used by the MCP server for vector search
create or replace function match_thoughts (
  query_embedding vector(1536),
  match_threshold float,
  match_count int,
  filter jsonb default '{}'::jsonb
) returns table (
  id uuid,
  content text,
  metadata jsonb,
  similarity float,
  created_at timestamp with time zone
)
language plpgsql
as $$
begin
  return query
  select
    thoughts.id,
    thoughts.content,
    thoughts.metadata,
    1 - (thoughts.embedding <=> query_embedding) as similarity,
    thoughts.created_at
  from thoughts
  where thoughts.metadata @> filter
  and 1 - (thoughts.embedding <=> query_embedding) > match_threshold
  order by thoughts.embedding <=> query_embedding
  limit match_count;
end;
$$;

Environment Variables

Your Supabase project will need the following secrets set. You can set them using the Supabase CLI:

supabase secrets set SUPABASE_URL="https://your-project.supabase.co"
supabase secrets set SUPABASE_SERVICE_ROLE_KEY="your-service-role-key"
supabase secrets set OPENROUTER_API_KEY="sk-or-v1-..."
supabase secrets set DISCORD_PUBLIC_KEY="your-discord-app-public-key"
supabase secrets set MCP_ACCESS_KEY="a-secure-random-string-you-generate"

Note: Ensure you treat SUPABASE_SERVICE_ROLE_KEY and MCP_ACCESS_KEY carefully to prevent unauthorized access.

Deployment

With the Supabase CLI securely linked to your project (supabase link --project-ref your-ref), execute the following command to deploy both edge functions:

supabase functions deploy ingest-thought --no-verify-jwt
supabase functions deploy open-brain-mcp --no-verify-jwt

The Edge functions handles authentication themselves based on your keys and Discord's signed headers.

Getting It Up And Running

Connecting Discord

  1. In your Discord Developer portal, navigate to your App's General Information page to get your Public Key (DISCORD_PUBLIC_KEY).
  2. Navigate to the Installation and OAuth2 pages to install the App into your Discord Server with applications.commands scope.
  3. In the General Information page, set the Interactions Endpoint URL to your deployed edge function URL (e.g., https://<YOUR-PROJECT-REF>.supabase.co/functions/v1/ingest-thought).
  4. Register a global or guild slash command /capture for your application so you can begin sending thoughts.

Connecting an MCP Client

In your preferred AI assistant or tool with standard MCP support (e.g. Claude Desktop app if building an overarching context, or similar setups):

Connection Details:

  • URL: https://<YOUR-PROJECT-REF>.supabase.co/functions/v1/open-brain-mcp
  • Either add via URL query params (.../open-brain-mcp?key=YOUR_MCP_KEY) or by passing the x-brain-key HTTP Header during setup.

You can now natively search past captures, see database stats, and store new thoughts directly into the vector database!

Quick Setup
Installation guide for this server

Install Package (if required)

npx @modelcontextprotocol/server-openbrain

Cursor configuration (mcp.json)

{ "mcpServers": { "itsmattshull-openbrain": { "command": "npx", "args": [ "itsmattshull-openbrain" ] } } }