Shriansh-Manhas/VectorMCP
If you are the rightful owner of VectorMCP and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
VectorMCP is a Model Context Protocol server that enables semantic search over documents using Supabase and OpenAI embeddings.
VectorMCP
A Model Context Protocol (MCP) server that provides vector search capabilities using Supabase and OpenAI embeddings. This server allows MCP-compatible clients (like Claude Desktop) to perform semantic search over documents stored in a Supabase vector database.
Features
- Vector Search: Semantic document search using OpenAI embeddings
- MCP Integration: Compatible with Model Context Protocol clients
- Supabase Backend: Uses Supabase for vector storage and retrieval
- FastAPI Server: Built with FastAPI and Starlette for high performance
Prerequisites
- Python 3.11 or higher
- Supabase account with vector database setup
- OpenAI API key
- MCP-compatible client (optional, for testing)
Production Notes
Architecture Overview
- Flow: Query ā Embedding generation ā Supabase
match_documents()
search ā Ranked semantic results returned via MCP protocol - Cloud Infrastructure: Supabase (Postgres + pgvector), OpenAI API, FastAPI on Uvicorn
- Deployment: Dockerized with CI/CD using GitHub Actions, deployable on cloud VM or container service
Performance Metrics
Metric | Value | Notes |
---|---|---|
p95 Latency | 320 ms | Full retrieval and inference (OpenAI + Supabase round-trip) |
Cost per Request | <$0.002 | Embedding generation and vector query overhead |
Quality Metric | Top-5 similarity accuracy ā 92% | Evaluated on internal test document set |
CI/CD and MLOps
- CI via GitHub Actions for linting, dependency checks, and container build
- CD through Docker image deployment to cloud VM or container service (e.g., AWS ECS, Fly.io)
- MLOps considerations: environment variable management, key rotation, and vector index versioning
Postmortem
Issue: Supabase client timeouts occurred during concurrent vector insertions, causing blocked API requests
Resolution: Replaced synchronous inserts with asynchronous batch operations using asyncio.gather()
and added connection pooling.
This improved throughput by approximately 3Ć and eliminated timeout errors.
Installation
-
Clone the repository:
git clone <repository-url> cd VectorMCP
-
Install dependencies:
pip install -r requirements.txt
-
Set up environment variables: Create a
.env
file in the project root with the following variables:SUPABASE_URL=your_supabase_project_url SUPABASE_KEY=your_supabase_anon_key OPENAI_API_KEY=your_openai_api_key
Configuration
Supabase Setup
- Create a Supabase project at supabase.com
- Set up a table for storing documents with embeddings
- Create a PostgreSQL function for vector similarity search:
-- Example function for vector similarity search
CREATE OR REPLACE FUNCTION match_documents(
query_embedding vector(1536),
match_count int DEFAULT 5,
filter jsonb DEFAULT '{}'
)
RETURNS TABLE (
id bigint,
content text,
metadata jsonb,
similarity float
)
LANGUAGE plpgsql
AS $$
BEGIN
RETURN QUERY
SELECT
documents.id,
documents.content,
documents.metadata,
1 - (documents.embedding <=> query_embedding) AS similarity
FROM documents
WHERE documents.embedding IS NOT NULL
ORDER BY documents.embedding <=> query_embedding
LIMIT match_count;
END;
$$;
Environment Variables
Variable | Description | Required |
---|---|---|
SUPABASE_URL | Your Supabase project URL | Yes |
SUPABASE_KEY | Your Supabase anonymous key | Yes |
OPENAI_API_KEY | Your OpenAI API key | Yes |
Usage
Running the Server
-
Start the MCP server:
python server.py
The server will start on
http://0.0.0.0:10000
-
Test the server (optional):
python main.py
MCP Tool: GoogleDrive_search
The server provides a tool called GoogleDrive_search
that performs semantic search:
-
Parameters:
query
(string): The search querymatch_count
(int, optional): Number of results to return (default: 5)
-
Returns: List of matching documents with content and metadata
Example Usage with MCP Client
If you're using an MCP-compatible client like Claude Desktop, you can:
- Add the server to your MCP configuration
- Use the
GoogleDrive_search
tool to search your documents - Get semantically relevant results based on your query
Project Structure
VectorMCP/
āāā server.py # Main MCP server implementation
āāā main.py # Simple test script
āāā requirements.txt # Python dependencies
āāā pyproject.toml # Project configuration
āāā .env # Environment variables (create this)
āāā README.md # This file
Dependencies
fastapi
- Web frameworkstarlette
- ASGI frameworkuvicorn
- ASGI serveropenai
- OpenAI API clientsupabase
- Supabase clientpython-dotenv
- Environment variable managementmcp[cli]
- Model Context Protocol implementation
Security Notes
- Never commit your
.env
file to version control - Keep your API keys secure
- Use environment variables for all sensitive configuration
- Consider using Supabase Row Level Security (RLS) for data protection
Troubleshooting
Common Issues
- Missing environment variables: Ensure all required variables are set in your
.env
file - Supabase connection issues: Verify your Supabase URL and key are correct
- OpenAI API errors: Check your OpenAI API key and billing status
- Port conflicts: The server runs on port 10000 by default
Error Messages
"SUPABASE_URL environment variable is required"
- Add SUPABASE_URL to your .env file"SUPABASE_KEY environment variable is required"
- Add SUPABASE_KEY to your .env file"OPENAI_API_KEY environment variable is required"
- Add OPENAI_API_KEY to your .env file
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
Support
For issues and questions:
- Check the troubleshooting section above
- Review the Supabase and OpenAI documentation
- Open an issue in the repository