Skip to main content
Glama
MCP Memory Server - Supabase

MCP Memory Server - Supabase

by kaspnilsson

MCP Memory Server - Supabase

npm version License: MIT

A knowledge graph memory server for the Model Context Protocol (MCP) backed by Supabase with pgvector for semantic search.

Why This?

  • Own your AI's memory — Your knowledge graph lives in your own Supabase database, not on someone else's servers

  • Semantic search built-in — pgvector enables similarity-based retrieval, not just keyword matching

  • Works with any MCP client — Claude Desktop, TypingMind, Cursor, and more

  • Free tier friendly — Supabase's free tier works great for personal use

  • Cloud-native — Managed Postgres with automatic backups, no self-hosting required

  • Composable — Use as a standalone server or as a library in your own MCP server

Related MCP server: vector-knowledge-graph-mcp

Quick Start

1. Create a Supabase Project

Go to supabase.com and create a new project.

2. Get Your Keys

In your project dashboard, go to Settings → API:

  • Project URL: https://<project-ref>.supabase.co

  • service_role key: ⚠️ Keep this secret! Use for server-side operations.

3. Run the Schema

Go to SQL Editor in your Supabase dashboard and run the contents of supabase/schema.sql.

This creates:

  • entities, observations, and relations tables

  • Row Level Security (RLS) policies

  • Vector similarity search index (HNSW)

  • Full-text search indexes

  • Helper functions for semantic search

4. Install & Run

# Run directly with npx
SUPABASE_URL=https://your-project.supabase.co \
SUPABASE_KEY=your-service-role-key \
npx @kaspnilsson/mcp-memory-supabase

# Or install globally
npm install -g @kaspnilsson/mcp-memory-supabase
SUPABASE_URL=https://your-project.supabase.co \
SUPABASE_KEY=your-service-role-key \
mcp-memory-supabase

Configuration

Environment Variables

Variable

Required

Description

SUPABASE_URL

Yes

Your Supabase project URL

SUPABASE_KEY

Yes

Service role key (not anon key)

EMBEDDING_API_KEY

No

API key for embeddings (enables semantic search)

EMBEDDING_API_URL

No

Custom embedding API endpoint (default: OpenRouter)

EMBEDDING_MODEL

No

Model name (default: openai/text-embedding-3-small)

LOG_LEVEL

No

Log level: debug, info, warn, error (default: info)

With EMBEDDING_API_KEY set, search_nodes uses vector similarity search for semantic matching. Without it, search falls back to case-insensitive text matching.

The default setup uses OpenRouter for embeddings, but you can point to any OpenAI-compatible embedding API.

MCP Client Configuration

Add to your MCP client configuration:

Claude Desktop (~/Library/Application Support/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "memory": {
      "command": "npx",
      "args": ["-y", "@kaspnilsson/mcp-memory-supabase"],
      "env": {
        "SUPABASE_URL": "https://<project-ref>.supabase.co",
        "SUPABASE_KEY": "<service-role-key>",
        "EMBEDDING_API_KEY": "<your-embedding-api-key>"
      }
    }
  }
}

TypingMind — Use the MCP settings UI with the same configuration.

Tools

Tool

Description

create_entities

Create entities with observations

create_relations

Create relations between entities

add_observations

Add observations to existing entities

delete_entities

Delete entities by name

delete_observations

Delete specific observations

delete_relations

Delete specific relations

read_graph

Read entire knowledge graph

search_nodes

Search entities by query (semantic or text)

open_nodes

Get specific entities by name (case-insensitive)

Data Model

┌─────────────┐     ┌───────────────┐
│   Entity    │────<│  Observation  │
│             │     │               │
│ name        │     │ content       │
│ entityType  │     │ entity_id     │
│ embedding   │     └───────────────┘
└─────────────┘
       │
       │    ┌───────────────┐
       └────<│   Relation    │
            │               │
            │ from_entity_id│
            │ to_entity_id  │
            │ relation_type │
            └───────────────┘
  • Entities are nodes in your knowledge graph (people, projects, concepts, etc.)

  • Observations are facts/notes attached to entities

  • Relations connect entities with typed relationships

Using as a Library

This package exports a composable API for building custom MCP servers:

import { createMemoryServer } from "@kaspnilsson/mcp-memory-supabase";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";

// Create server with custom options
const { server, manager } = createMemoryServer({
  supabaseUrl: process.env.SUPABASE_URL,
  supabaseKey: process.env.SUPABASE_KEY,
  embeddingApiKey: process.env.EMBEDDING_API_KEY,
  serverName: "my-custom-memory-server",
  serverVersion: "1.0.0",
  // Custom logger (any object with debug/info/warn/error methods)
  logger: {
    debug: (msg, data) => console.debug(msg, data),
    info: (msg, data) => console.info(msg, data),
    warn: (msg, data) => console.warn(msg, data),
    error: (msg, data) => console.error(msg, data),
  },
});

// Optionally add your own tools
server.tool("my_custom_tool", { /* schema */ }, async (args) => {
  // Use manager to interact with the knowledge graph
  const graph = await manager.searchNodes(args.query);
  return { content: [{ type: "text", text: JSON.stringify(graph) }] };
});

// Connect
await server.connect(new StdioServerTransport());

Import Paths

Import

Exports

@kaspnilsson/mcp-memory-supabase

createMemoryServer()

@kaspnilsson/mcp-memory-supabase/manager

KnowledgeGraphManager class

@kaspnilsson/mcp-memory-supabase/types

Entity, Relation, KnowledgeGraph, Logger, etc.

Troubleshooting

Empty results after enabling RLS

Make sure you ran the RLS policies from schema.sql. The service role key bypasses RLS, but Supabase requires policies to exist.

Vector search not working

  1. Ensure the vector extension is enabled in Supabase

  2. Check that EMBEDDING_API_KEY is set correctly

  3. Verify embeddings are being generated:

    SELECT name, embedding IS NOT NULL AS has_embedding FROM entities LIMIT 10;

Using anon key instead of service_role

If you use the anon key, you'll need stricter RLS policies. The service_role key bypasses RLS entirely.

Developing

# Install dependencies
npm install

# Build
npm run build

# Run tests
npm test

# Lint
npm run lint

License

MIT © Kasper Nilsson

Available Tools

9 tools
add_observationsD

Inputs: observations (required).

create_entitiesD

Inputs: entities (required).

create_relationsD

Inputs: relations (required).

delete_entitiesD

Inputs: entityNames (required).

delete_observationsD

Inputs: deletions (required).

delete_relationsD

Inputs: relations (required).

open_nodesD

Inputs: names (required).

read_graphD

Inputs: no named parameters.

search_nodesD

Inputs: query (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    D1.9/5.0

    Scored across 9 tools

    Disambiguation3/5

    The mutation tools (create_entities, create_relations, add_observations, delete_*) each target a clearly distinct resource, so writes are unambiguous. The read side is muddier: read_graph, search_nodes, and open_nodes all retrieve graph data, and with zero descriptions an agent must guess whether open_nodes takes names/IDs versus a query like search_nodes. A short description per tool would resolve this, but as-is there is real risk of miselection among the three readers.

    Naming Consistency4/5

    Names follow a predictable verb_noun pattern (create_*, delete_*, read_graph, search_nodes, open_nodes) in consistent snake_case. The only deviation is add_observations, which uses 'add' instead of 'create' — sensible since observations attach to an existing entity rather than being standalone. Minor and readable.

    Tool Count5/5

    Nine tools is well within the ideal range and maps cleanly onto the knowledge-graph model: three noun types (entities, relations, observations) times create/delete plus three read operations. Every tool earns its place; no filler or redundant variants.

    Completeness4/5

    The surface covers the full lifecycle for entities, relations, and observations, plus whole-graph read, query search, and direct node access — no obvious dead ends for core memory operations. The gap is update/mutation of entity identity: there is no update_entities to rename an entity or change its type, so corrections require delete-and-recreate.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers