RagLit MCP Server

RagLit MCP Server

Enables AI agents to ingest documents, generate embeddings, and perform semantic search via PostgREST APIs.

Category
访问服务器

README

RagLit MCP Server

Status TypeScript Node.js PostgreSQL

Model Context Protocol server enabling AI agents to query and interact with PostgREST APIs


Overview

RagLit is a Model Context Protocol (MCP) server that bridges AI agents like Claude Desktop with PostgREST-compatible backends for RAG (Retrieval-Augmented Generation) pipelines. The server implements the MCP specification to expose document chunking, embedding generation, and semantic search capabilities, enabling AI agents to ingest documents into PostgreSQL databases and query them using vector similarity search. Built with TypeScript using repository pattern for database abstraction, demonstrating understanding of emerging AI agent architectures and standardized tool protocols.


Tech Stack

Runtime: Node.js · TypeScript <br> AI/ML: OpenAI API (text-embedding-3-small) · pgvector <br> Database: PostgreSQL · PostgREST <br> Architecture: Model Context Protocol (MCP) · Repository Pattern <br> Tools: Zod (validation) · ESLint


Features

  • MCP-compliant server implementing standardized tool protocol for AI agent communication
  • Document ingestion pipeline with fixed-size word-based chunking and configurable overlap
  • OpenAI embedding generation service with text-embedding-3-small model integration
  • Semantic search using PostgreSQL pgvector extension via PostgREST RPC functions
  • Metadata filtering with JSONB containment queries for exact-match document retrieval
  • Repository pattern abstraction layer for PostgREST API with interface-based design
  • Three MCP tools exposed: chunk_document, search_chunks, filter_metadata
  • Environment-based configuration supporting Supabase and self-hosted PostgREST instances
  • Schema validation using Zod for type-safe request/response handling

Architecture & Tech Decisions

Built using the Model Context Protocol (MCP) specification, an emerging standard for AI agent tool integration pioneered by Anthropic. Implements stdio-based communication pattern where Claude Desktop launches the Node process and communicates via standard input/output. Chose repository pattern with abstract ChunkRepository interface to decouple business logic from PostgREST implementation details, enabling future adapter implementations for different backends. PostgREST integration leverages PostgreSQL's pgvector extension through RPC function calls (match_chunks, filter_chunks_by_meta) rather than direct SQL, providing API-level abstraction. Document chunking uses fixed-size word-count strategy with overlap to maintain semantic context across chunk boundaries. OpenAI embedding service encapsulates API calls with error handling and retry logic. Environment configuration validation using Zod ensures runtime type safety for required variables (EXTERNAL_API_URL, OPENAI_API_KEY).


Learnings & Challenges

Key Learnings:

  • Implementing Model Context Protocol (MCP) specification for AI agent tool integration
  • Designing repository pattern abstractions for REST API interactions with type-safe interfaces
  • Understanding pgvector cosine similarity search with PostgreSQL RPC function integration
  • Building document chunking strategies balancing semantic coherence with embedding costs
  • Using Zod for runtime schema validation and environment configuration

Challenges Overcome:

  • Debugging PostgREST schema cache issues requiring exact column name matching (camelCase)
  • Designing MCP tool schemas that balance flexibility with type safety using Zod
  • Implementing proper error handling for cascading failures (OpenAI → PostgreSQL → PostgREST)
  • Structuring repository interface to support both Supabase and self-hosted PostgREST
  • Understanding MCP stdio communication pattern and Claude Desktop integration requirements

Quick Start

npm install
npm run build
npm run start
# Server communicates via stdio for MCP clients

Claude Desktop Integration: Add to claude_desktop_config.json:

{
  "mcpServers": {
    "raglit-postgrest": {
      "command": "node",
      "args": ["/absolute/path/to/raglit-fixed-mcp/dist/index.js"],
      "env": {
        "EXTERNAL_API_URL": "https://your-project.supabase.co",
        "OPENAI_API_KEY": "sk-your-key",
        "EXTERNAL_API_KEY": "your-postgrest-key"
      }
    }
  }
}

PostgreSQL Setup:

-- Enable pgvector extension
CREATE EXTENSION IF NOT EXISTS vector;

-- Create chunks table
CREATE TABLE public.chunks (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    "documentId" TEXT NOT NULL,
    content TEXT NOT NULL,
    "chunkIndex" INTEGER NOT NULL,
    "chunkSize" INTEGER NOT NULL,
    "chunkOverlap" INTEGER NOT NULL,
    "chunkStrategy" TEXT DEFAULT 'fixed-size' NOT NULL,
    metadata JSONB DEFAULT '{}',
    embedding VECTOR(1536)
);

-- Create RPC functions for search and filter
-- (See full README for complete SQL)

Environment Variables:

EXTERNAL_API_URL=https://your-postgrest-url
OPENAI_API_KEY=sk-your-openai-key
EXTERNAL_API_KEY=your-postgrest-api-key
EMBEDDING_MODEL=text-embedding-3-small

推荐服务器

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

官方
精选