Vector Search Service MCP Provider
A clean architecture backend API that registers and semantically searches data using vector embeddings, acting as an MCP context provider to connect AI models to external data.
README
Vector Search Service (MCP Provider)
Backend API for data registration and semantic search, acting as an MCP (Model Context Protocol) context provider.
Tech Stack
- Node.js + TypeScript (Strict mode)
- NestJS (HTTP Framework and Dependency Injection)
- PostgreSQL + pgvector (Vector Database)
- Prisma (ORM)
- OpenAI / Gemini / Claude (Voyage AI) (Interchangeable Embedding Adapters)
- Helmet + Throttler (Security headers and Rate Limiting)
Architecture
The project follows Clean Architecture and Hexagonal Architecture:
- Domain: Framework-agnostic Entities and Interfaces (Ports).
- Application: Use Cases containing business rules.
- Infrastructure: Concrete implementations (Prisma, AI Adapters).
- Interface: HTTP Controllers (REST).
Configuration
1. Installation and Environment
-
Install dependencies:
npm install -
Configure environment variables: Copy
.env.exampleto.envand fill in the keys.cp .env.example .envSupported Adapters (
EMBEDDING_PROVIDER):openai: RequiresOPENAI_API_KEY(Model:text-embedding-3-small) (Recommended)gemini: RequiresGOOGLE_GENAI_API_KEY(Model:gemini-embedding-001)claude: RequiresANTHROPIC_API_KEYandVOYAGE_API_KEY(Model:voyage-large-2).
Security Configuration:
MAX_CONTENT_ITEMS: Maximum number of items allowed in thedataarray (Default: 100).
2. Database with Docker
You can start the PostgreSQL database with pgvector extension using Docker Compose:
docker compose up -d
This will start the database on port 5432. Default credentials are in docker-compose.yml.
3. Database Migration
Run the Prisma migrations to create the database schema:
npx prisma migrate dev
4. Execution
To start the application in development mode:
npm run start:dev
The application will be available at http://localhost:3000.
5. Swagger Documentation
Interactive API documentation (Swagger UI) is available at:
http://localhost:3000/api
API Endpoints
1. Register Data (Upsert)
POST /data/register
Registers data for a project and content ID. Replaces existing data (idempotent).
Payload:
{
"projectId": "project-alpha",
"contentId": "doc-123",
"data": [
"MCP allows connecting AIs to external data.",
"Vector search uses embeddings for similarity."
]
}
Response (201):
{
"message": "Data registered successfully"
}
2. Search Data
POST /data/search
Semantic search on registered data.
Payload:
{
"search": "how does vector search work?",
"projectId": "project-alpha",
"limit": 3
}
Response (200):
{
"results": [
{
"projectId": "project-alpha",
"contentId": "doc-123",
"data": [
"Vector search uses embeddings for similarity."
]
}
]
}
3. List Data (Grouped)
GET /data
Lists stored data, grouped by project and content, returning item counts. Supports pagination.
Query Params:
projectId(optional): Filter by project.contentId(optional): Filter by content ID.page(default: 1): Page number.limit(default: 10): Items per page.
Response (200):
{
"results": [
{
"projectId": "project-alpha",
"contents": [
{
"contentId": "doc-123",
"items": 2
}
]
}
],
"page": 1,
"limit": 10
}
4. Remove Data
DELETE /data
Removes data filtering by project or content ID. At least one filter is required.
Query Params:
projectId: Project ID.contentId: Content ID.
Response (200):
{
"message": "Data removed successfully"
}
Security Features
- Input Validation: Strict DTO validation with
class-validator(whitelist enabled). - Rate Limiting: Global rate limiting (100 requests/minute) using
@nestjs/throttler. - HTTP Headers: Secure HTTP headers via
helmet. - CORS: Enabled with default settings.
- SQL Injection Protection: Uses Prisma's parameterized queries and raw SQL template literals for vector operations.
- Payload Limits: Configurable limit for input array size (
MAX_CONTENT_ITEMS).
Tests
E2E Tests
npm run test:e2e
Unit Tests
npm run test
Folder Structure
src/
├── application/ # Business Rules (Use Cases)
├── domain/ # Entities and Interfaces
├── infrastructure/ # Implementations (DB, Adapters)
├── interface/ # Controllers and DTOs
└── main.ts # Entrypoint
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.