Custom Model Context Protocol (MCP) memory server deployed on Vercel with semantic search powered by OpenAI embeddings and PostgreSQL pgvector.
- π§ Semantic Search - Find memories by meaning, not just keywords
- π Secure API - Optional API key authentication for production
- βοΈ Cloud-Hosted - Deployed on Vercel Edge Functions (zero-infrastructure)
- π Cross-Device Sync - Access your memory from any device with Claude
- π OpenAI Embeddings - Using text-embedding-3-small model
- ποΈ PostgreSQL + pgvector - Efficient vector similarity search
- β Input Validation - Zod schemas for robust data validation
- π Structured Logging - Production-ready error tracking
- π Multi-language - Supports Russian, English and more
- π€ Claude Code Integration - Automated PR reviews and AI assistant via GitHub Actions
Claude Desktop β HTTPS/JSON-RPC β Vercel Edge Function β Postgres (pgvector)
β
OpenAI Embeddings API
- Node.js 20.x
- Vercel account (free tier works)
- OpenAI API key (for embeddings, ~$0.10/1M tokens)
- PostgreSQL database with pgvector extension (Vercel Postgres or Neon)
cd vercel-mcp-memory
npm install# Install Vercel CLI
npm i -g vercel
# Login to Vercel
vercel login
# Link project
vercel link
# Create Postgres database (via Vercel Dashboard)
# 1. Go to https://vercel.com/dashboard
# 2. Navigate to Storage β Create Database β Postgres
# 3. Name: mcp-memory-db
# 4. Region: Select closest to youCreate .env.local file:
# Required: OpenAI API key for embeddings
OPENAI_API_KEY=sk-...
# Required: PostgreSQL connection (auto-configured by Vercel)
POSTGRES_URL=postgresql://...
# Optional: API keys for authentication (comma-separated)
# Leave empty for development without auth
MCP_API_KEYS=your-secret-key-1,your-secret-key-2Generate secure API keys:
# Generate a secure API key
openssl rand -base64 32Apply the SQL schema with pgvector extension:
# Option 1: Via Vercel Dashboard
# 1. Go to Storage β mcp-memory-db β SQL Editor
# 2. Copy contents of migrations/001_init.sql
# 3. Execute
# Option 2: Via psql (if you have local connection)
psql $POSTGRES_URL < migrations/001_init.sqlvercel --prodYour MCP server will be available at: https://your-project.vercel.app
Edit ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or ~/.config/claude-desktop/claude_desktop_config.json (Linux):
With authentication (recommended for production):
{
"mcpServers": {
"vercel-memory": {
"command": "npx",
"args": [
"-y",
"mcp-remote",
"https://your-project.vercel.app/api/mcp/sse"
],
"env": {
"MCP_API_KEY": "your-secret-key-here"
}
}
}
}Without authentication (development only):
{
"mcpServers": {
"vercel-memory": {
"command": "npx",
"args": [
"-y",
"mcp-remote",
"https://your-project.vercel.app/api/mcp/sse"
]
}
}
}Restart Claude Desktop.
curl https://your-project.vercel.app/api/healthShould return:
{
"status": "healthy",
"service": "vercel-mcp-memory",
"database": {
"connected": true
}
}curl -X POST https://your-project.vercel.app/api/mcp/sse \
-H "Content-Type: application/json" \
-H "X-API-Key: your-secret-key" \
-d '{
"jsonrpc": "2.0",
"method": "tools/list",
"id": 1
}'User: Remember: I prefer Python for backend development
Claude: [Uses add_memory tool]
User: What programming languages do I prefer?
Claude: [Uses search_memory tool and finds "Python"]Store new memory with semantic embeddings.
{
content: string, // Required (1-10000 chars)
category?: string, // Optional (max 100 chars)
metadata?: object // Optional custom key-value pairs
}Semantic search across memories.
{
query: string, // Required: natural language query (1-1000 chars)
category?: string, // Filter by category
limit?: number, // Max results (default: 10, max: 50)
threshold?: number // Min similarity 0-1 (default: 0.5)
}List all memories chronologically.
{
category?: string, // Filter by category
limit?: number, // Max results (default: 50, max: 100)
offset?: number // Pagination offset (default: 0)
}Delete specific memory by UUID.
{
id: string // UUID of memory (validated)
}Get statistics about stored memories.
{} // No parametersvercel-mcp-memory/
βββ app/
β βββ api/
β β βββ health/route.ts # Health check endpoint
β β βββ mcp/sse/route.ts # MCP JSON-RPC endpoint
β βββ layout.tsx # Next.js layout
β βββ page.tsx # Landing page
βββ lib/
β βββ auth.ts # API authentication
β βββ db.ts # Postgres + pgvector queries
β βββ embeddings.ts # OpenAI embeddings client
β βββ logger.ts # Structured logging
β βββ mcp-handlers.ts # Centralized tool handlers
β βββ mcp-server.ts # MCP SDK integration
β βββ types.ts # TypeScript definitions
β βββ validation.ts # Zod input validation
βββ migrations/
β βββ 001_init.sql # Database schema
βββ scripts/
β βββ insert-test-data.ts # Test data seeding
β βββ migrate-old-data.ts # Legacy data migration
βββ .env.example # Environment variables template
βββ .eslintrc.json # ESLint configuration
βββ .gitignore # Git ignore rules
βββ SECURITY.md # Security guidelines
βββ next.config.js # Next.js configuration
βββ package.json # Dependencies
βββ tsconfig.json # TypeScript configuration
βββ vercel.json # Vercel deployment config
# Run locally
npm run dev
# Build for production
npm run build
# Lint code
npm run lint
# Migrate old data
npm run migrateSee SECURITY.md for security best practices.
Important:
- Never commit
.env.localor.env.productionfiles - Rotate API keys regularly
- Enable
MCP_API_KEYSauthentication in production - Monitor API usage to prevent quota exhaustion
- Review SECURITY.md before deploying
Vercel Free Tier (sufficient for personal use):
- β Functions: 100 GB-hours/month
- β Postgres: 256 MB storage
- β Bandwidth: 100 GB
After free tier:
- Postgres: ~$0.20/GB/month
- OpenAI Embeddings:
$0.10/1M tokens ($0.02/month for typical usage) - Functions: ~$40/100 GB-hours
Expected cost: $0-5/month for moderate personal use.
- Check health endpoint:
curl https://your-project.vercel.app/api/health - Verify API key matches in both Vercel env and Claude config
- Check Vercel deployment:
vercel ls - Verify Claude config path is correct
- Restart Claude Desktop
- Verify
MCP_API_KEYSis set in Vercel environment variables - Check API key format (no extra spaces or newlines)
- Ensure Claude config includes
MCP_API_KEYin env section - Try without authentication first (remove
MCP_API_KEYSfrom Vercel env)
-
Verify pgvector extension is enabled:
SELECT * FROM pg_extension WHERE extname = 'vector';
-
Check table exists:
\dt memories
-
View connection logs in Vercel Dashboard β Functions β Logs
- Verify OpenAI API key is set:
vercel env ls - Check API key has sufficient credits
- Monitor usage: https://platform.openai.com/usage
This repository uses Claude Code via GitHub Actions for automated code reviews and AI assistance.
Every pull request automatically receives a comprehensive code review from Claude, focusing on:
- Code quality and best practices
- Potential bugs and security issues
- Performance considerations
- Test coverage
Mention @claude in any issue or PR comment to get help:
@claude Please review the security implications of these auth changes.
@claude Help me fix the TypeScript errors in lib/db.ts.
@claude Update CLAUDE.md to reflect the new architecture.For detailed setup and troubleshooting, see .github/CLAUDE_CODE_SETUP.md.
MIT
Contributions are welcome! Please read our Contributing Guidelines and Code of Conduct first.
Quick steps:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
For questions or support, see SUPPORT.md.
Built with:
- Vercel - Hosting and Postgres
- Next.js - React framework
- OpenAI - Embeddings API
- MCP SDK - Protocol implementation
- pgvector - Vector similarity search
Made with β€οΈ using Vercel, Next.js, and Claude Code