Vector Search Service MCP Provider

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.

Category
访问服务器

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

  1. Install dependencies:

    npm install
    
  2. Configure environment variables: Copy .env.example to .env and fill in the keys.

    cp .env.example .env
    

    Supported Adapters (EMBEDDING_PROVIDER):

    • openai: Requires OPENAI_API_KEY (Model: text-embedding-3-small) (Recommended)
    • gemini: Requires GOOGLE_GENAI_API_KEY (Model: gemini-embedding-001)
    • claude: Requires ANTHROPIC_API_KEY and VOYAGE_API_KEY (Model: voyage-large-2).

Security Configuration:

  • MAX_CONTENT_ITEMS: Maximum number of items allowed in the data array (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

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选