Vercel MCP Memory

Vercel MCP Memory

Enables semantic memory storage and retrieval with natural language queries, deployed on Vercel with PostgreSQL pgvector and OpenAI embeddings.

Category
访问服务器

README

Vercel MCP Memory

CI CodeQL Claude Code License: MIT GitHub issues GitHub stars

Custom Model Context Protocol (MCP) memory server deployed on Vercel with semantic search powered by OpenAI embeddings and PostgreSQL pgvector.

✨ Features

  • 🧠 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

🏗️ Architecture

Claude Desktop → HTTPS/JSON-RPC → Vercel Edge Function → Postgres (pgvector)
                                         ↓
                                   OpenAI Embeddings API

📋 Prerequisites

  • 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)

🚀 Quick Start

1. Install Dependencies

cd vercel-mcp-memory
npm install

2. Set Up Vercel Postgres

# 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 you

3. Configure Environment Variables

Create .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-2

Generate secure API keys:

# Generate a secure API key
openssl rand -base64 32

4. Run Database Migration

Apply 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.sql

5. Deploy to Vercel

vercel --prod

Your MCP server will be available at: https://your-project.vercel.app

6. Configure Claude Desktop

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.

🧪 Testing

Health Check

curl https://your-project.vercel.app/api/health

Should return:

{
  "status": "healthy",
  "service": "vercel-mcp-memory",
  "database": {
    "connected": true
  }
}

Test MCP Endpoint with Authentication

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
  }'

Test in Claude

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"]

📊 MCP Tools

add_memory

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
}

search_memory

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_memories

List all memories chronologically.

{
  category?: string,    // Filter by category
  limit?: number,       // Max results (default: 50, max: 100)
  offset?: number       // Pagination offset (default: 0)
}

delete_memory

Delete specific memory by UUID.

{
  id: string           // UUID of memory (validated)
}

memory_stats

Get statistics about stored memories.

{}  // No parameters

📁 Project Structure

vercel-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

🔧 Development

# Run locally
npm run dev

# Build for production
npm run build

# Lint code
npm run lint

# Migrate old data
npm run migrate

🔐 Security

See SECURITY.md for security best practices.

Important:

  • Never commit .env.local or .env.production files
  • Rotate API keys regularly
  • Enable MCP_API_KEYS authentication in production
  • Monitor API usage to prevent quota exhaustion
  • Review SECURITY.md before deploying

💰 Cost Estimation

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.

🐛 Troubleshooting

Claude can't connect

  1. Check health endpoint: curl https://your-project.vercel.app/api/health
  2. Verify API key matches in both Vercel env and Claude config
  3. Check Vercel deployment: vercel ls
  4. Verify Claude config path is correct
  5. Restart Claude Desktop

Authentication errors

  1. Verify MCP_API_KEYS is set in Vercel environment variables
  2. Check API key format (no extra spaces or newlines)
  3. Ensure Claude config includes MCP_API_KEY in env section
  4. Try without authentication first (remove MCP_API_KEYS from Vercel env)

Database errors

  1. Verify pgvector extension is enabled:

    SELECT * FROM pg_extension WHERE extname = 'vector';
    
  2. Check table exists:

    \dt memories
    
  3. View connection logs in Vercel Dashboard → Functions → Logs

Embedding errors

  1. Verify OpenAI API key is set: vercel env ls
  2. Check API key has sufficient credits
  3. Monitor usage: https://platform.openai.com/usage

📖 Resources

🤖 Claude Code Integration

This repository uses Claude Code via GitHub Actions for automated code reviews and AI assistance.

Automated PR Reviews

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

Interactive AI Assistant

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.

📝 License

MIT

🤝 Contributing

Contributions are welcome! Please read our Contributing Guidelines and Code of Conduct first.

Quick steps:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

For questions or support, see SUPPORT.md.

🙏 Acknowledgments

Built with:


Made with ❤️ using Vercel, Next.js, and Claude Code

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选