Labsco
berrydev-ai logo

BerryRAG

from berrydev-ai

A local RAG system with Playwright MCP integration for Claude and OpenAI embeddings, using local storage.

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedAccount requiredAdvanced setup

๐Ÿ“ BerryRAG: Local Vector Database with Playwright MCP Integration

A complete local RAG (Retrieval-Augmented Generation) system that integrates Playwright MCP web scraping with vector database storage for Claude.

โœจ Features

  • Zero-cost self-hosted vector database
  • Playwright MCP integration for automated web scraping
  • Multiple embedding providers (sentence-transformers, OpenAI, fallback)
  • Smart content processing with quality filters
  • Claude-optimized context formatting
  • MCP server for direct Claude integration
  • Command-line tools for manual operation

๐Ÿ“ Project Structure

berry-rag/
โ”œโ”€โ”€ src/                          # Python source code
โ”‚   โ”œโ”€โ”€ rag_system.py            # Core vector database system
โ”‚   โ””โ”€โ”€ playwright_integration.py # Playwright MCP integration
โ”œโ”€โ”€ mcp_servers/                  # MCP server implementations
โ”‚   โ””โ”€โ”€ vector_db_server.ts      # TypeScript MCP server
โ”œโ”€โ”€ storage/                      # Vector database storage
โ”‚   โ”œโ”€โ”€ documents.db             # SQLite metadata
โ”‚   โ””โ”€โ”€ vectors/                 # NumPy embedding files
โ”œโ”€โ”€ scraped_content/             # Playwright saves content here
โ””โ”€โ”€ dist/                        # Compiled TypeScript

๐Ÿ”ง Commands

Streamlit Web Interface

Launch the web interface for easy interaction with your RAG system:

# Start the Streamlit web interface
python run_streamlit.py

# Or directly with streamlit
streamlit run streamlit_app.py

The web interface provides:

  • ๐Ÿ” Search: Interactive document search with similarity controls
  • ๐Ÿ“„ Context: Generate formatted context for AI assistants
  • โž• Add Document: Upload files or paste content directly
  • ๐Ÿ“š List Documents: Browse your document library
  • ๐Ÿ“Š Statistics: System health and performance metrics

NPM Scripts

CommandDescription
npm run install-depsInstall all dependencies
npm run setupInitialize directories and instructions
npm run buildCompile TypeScript MCP server
npm run process-scrapedProcess scraped files into vector DB
npm run searchSearch the knowledge base
npm run list-docsList all documents

Python CLI

# RAG System Operations
python src/rag_system.py search "query"
python src/rag_system.py context "query"  # Claude-formatted
python src/rag_system.py add <url> <title> <file>
python src/rag_system.py list
python src/rag_system.py stats

# Playwright Integration
python src/playwright_integration.py process
python src/playwright_integration.py setup
python src/playwright_integration.py stats

๐Ÿ”Œ MCP Tools Available to Claude

BerryRAG provides two powerful MCP servers for Claude integration:

Vector DB Server Tools

  • add_document - Add content directly to vector DB
  • search_documents - Search for similar content
  • get_context - Get formatted context for queries
  • list_documents - List all stored documents
  • get_stats - Vector database statistics
  • process_scraped_files - Process Playwright scraped content
  • save_scraped_content - Save content for later processing

BerryExa Server Tools

  • crawl_content - Advanced web content extraction with subpage support
  • extract_links - Extract internal links for subpage discovery
  • get_content_preview - Quick content preview without full processing

๐Ÿ“– For complete MCP setup and usage guide, see BERRY_MCP.md

๐Ÿง  Embedding Providers

The system supports multiple embedding providers with automatic fallback:

  1. sentence-transformers (recommended, free, local)
  2. OpenAI embeddings (requires API key, set OPENAI_API_KEY)
  3. Simple hash-based (fallback, not recommended for production)

๐Ÿ“Š Monitoring

Check System Status

# Vector database statistics
python src/rag_system.py stats

# Processing status
python src/playwright_integration.py stats

# View recent documents
python src/rag_system.py list

Storage Information

  • Database: storage/documents.db (SQLite metadata)
  • Vectors: storage/vectors/ (NumPy arrays)
  • Scraped Content: scraped_content/ (Markdown files)

๐Ÿ” Example Workflows

Academic Research

  1. Scrape research papers with Playwright
  2. Process into vector database
  3. Query for specific concepts across all papers

Documentation Management

  1. Scrape API documentation from multiple sources
  2. Build unified searchable knowledge base
  3. Get contextual answers about implementation details

Content Aggregation

  1. Scrape blog posts and articles
  2. Create topic-based knowledge clusters
  3. Find related content across sources

๐Ÿ› ๏ธ Development

Building the MCP Server

npm run build

Running in Development Mode

npm run dev  # TypeScript watch mode

Testing

# Test RAG system
python src/rag_system.py stats

# Test integration
python src/playwright_integration.py setup

# Test MCP server
node mcp_servers/vector_db_server.js

๐Ÿ“ License

MIT License - feel free to modify and extend for your needs.

๐Ÿค Contributing

This is a personal project for Eric Berry, but feel free to fork and adapt for your own use cases.


Happy scraping and searching! ๐Ÿ•ท๏ธ๐Ÿ”โœจ