fwegener83/crawl4ai-mcp-server
If you are the rightful owner of crawl4ai-mcp-server 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.
Crawl4AI MCP Server is a Model Context Protocol server designed for web content extraction using the Crawl4AI library.
Crawl4AI MCP Server
MCP Server für Web-Content-Extraktion mit Crawl4AI und RAG Knowledge Base Funktionalität.
Installation
Basis Installation
git clone <repository-url>
cd crawl4ai-mcp-server
uv install
playwright install
RAG Knowledge Base (Optional)
Für erweiterte Funktionalität mit semantischer Suche und Wissensspeicherung:
# RAG Dependencies installieren
pip install chromadb sentence-transformers langchain-text-splitters numpy
# Oder mit uv
uv add chromadb sentence-transformers langchain-text-splitters numpy
Hinweis: Ohne RAG Dependencies sind nur die 3 Basis-Tools verfügbar. Mit RAG Dependencies erweitert sich die Funktionalität auf 7 Tools.
MCP Inspector Setup
npm install -g @modelcontextprotocol/inspector
mcp-inspector --config mcp-inspector-config.json --server crawl4ai
Öffnet Browser auf http://localhost:3000
Claude Desktop Integration
Konfiguration in ~/Library/Application Support/Claude/claude_desktop_config.json
:
{
"mcpServers": {
"crawl4ai": {
"command": "/absolute/path/to/crawl4ai-mcp-server/.venv/bin/python",
"args": ["/absolute/path/to/crawl4ai-mcp-server/server.py"]
}
}
}
Alternative mit uv (falls global installiert):
{
"mcpServers": {
"crawl4ai": {
"command": "uv",
"args": ["run", "--directory", "/absolute/path/to/crawl4ai-mcp-server", "python", "server.py"]
}
}
}
Verfügbare Tools
🌐 Basis Web-Crawling Tools (immer verfügbar)
web_content_extract
Extrahiert Content von einzelnen Webseiten als Markdown.
Parameter:
url
(string, required): URL der zu crawlenden Webseite
Beispiel:
{
"name": "web_content_extract",
"arguments": {
"url": "https://example.com"
}
}
domain_deep_crawl_tool
Tiefes Crawling einer ganzen Domain mit konfigurierbaren Strategien.
Parameter:
domain_url
(string, required): Basis-URL/Domain zum Crawlenmax_depth
(int, default: 1): Maximale Crawl-Tiefe (0-10)crawl_strategy
(string, default: "bfs"): Crawling-Strategie (bfs, dfs, best_first)max_pages
(int, default: 10): Maximale Anzahl Seiten (1-1000)include_external
(bool, default: false): Externe Links einschließenurl_patterns
(list, optional): URL-Patterns zum Einschließenexclude_patterns
(list, optional): URL-Patterns zum Ausschließenkeywords
(list, optional): Keywords für BestFirst-Scoring
domain_link_preview_tool
Schnelle Link-Vorschau einer Domain ohne vollständiges Crawling.
Parameter:
domain_url
(string, required): Basis-URL/Domain zum Analysiereninclude_external
(bool, default: false): Externe Links einschließen
🧠 RAG Knowledge Base Tools (erfordert optionale Dependencies)
Hinweis: Diese Tools sind nur verfügbar wenn RAG Dependencies installiert sind (siehe Installation).
store_crawl_results
Speichert Crawl-Ergebnisse in der vektorbasierten Knowledge Base für spätere semantische Suche.
Parameter:
crawl_result
(string, required): Crawl-Ergebnis (String oder JSON)collection_name
(string, default: "default"): Name der Collection
Beispiel:
{
"name": "store_crawl_results",
"arguments": {
"crawl_result": "Content text or JSON from crawling",
"collection_name": "my_docs"
}
}
search_knowledge_base
Semantische Suche in der gespeicherten Knowledge Base mit Similarity-Scoring.
Parameter:
query
(string, required): Suchanfragecollection_name
(string, default: "default"): Collection zum Durchsuchenn_results
(int, default: 5): Maximale Anzahl Ergebnisse (1-20)similarity_threshold
(float, optional): Minimaler Similarity Score (0.0-1.0)
Beispiel:
{
"name": "search_knowledge_base",
"arguments": {
"query": "machine learning algorithms",
"collection_name": "tech_docs",
"n_results": 3
}
}
list_collections
Listet alle verfügbaren Collections in der Knowledge Base mit Statistiken auf.
Parameter: Keine
Beispiel:
{
"name": "list_collections",
"arguments": {}
}
delete_collection
Löscht eine Collection permanent aus der Knowledge Base.
Parameter:
collection_name
(string, required): Name der zu löschenden Collection
Beispiel:
{
"name": "delete_collection",
"arguments": {
"collection_name": "old_docs"
}
}
RAG Knowledge Base - Quick Start
Grundlegende Konfiguration
Erstelle optional eine .env
Datei für Konfiguration:
# RAG Knowledge Base Konfiguration
RAG_DB_PATH=./my_knowledge_base # Pfad zur ChromaDB Datenbank
RAG_MODEL_NAME=distiluse-base-multilingual-cased-v1 # Embedding Model
RAG_CHUNK_SIZE=1000 # Text Chunk Größe
RAG_CHUNK_OVERLAP=200 # Overlap zwischen Chunks
RAG_DEVICE=cpu # cpu oder cuda
Typische Workflows
1. Content Crawlen und Speichern
// 1. Webseite crawlen
{
"name": "web_content_extract",
"arguments": {
"url": "https://docs.python.org/3/tutorial/"
}
}
// 2. Ergebnis in Knowledge Base speichern
{
"name": "store_crawl_results",
"arguments": {
"crawl_result": "[crawl output from step 1]",
"collection_name": "python_docs"
}
}
2. Domain Crawlen und Batch-Speichern
// 1. Ganze Domain crawlen
{
"name": "domain_deep_crawl_tool",
"arguments": {
"domain_url": "https://fastapi.tiangolo.com",
"max_depth": 2,
"max_pages": 20
}
}
// 2. Alle Ergebnisse speichern
{
"name": "store_crawl_results",
"arguments": {
"crawl_result": "[domain crawl JSON output]",
"collection_name": "fastapi_docs"
}
}
3. Semantische Suche
// Nach relevantem Content suchen
{
"name": "search_knowledge_base",
"arguments": {
"query": "async database connections",
"collection_name": "fastapi_docs",
"n_results": 5
}
}
4. Collection Management
// Alle Collections anzeigen
{
"name": "list_collections",
"arguments": {}
}
// Collection löschen
{
"name": "delete_collection",
"arguments": {
"collection_name": "old_collection"
}
}
Integration mit Claude/ChatGPT
Beispiel-Prompt:
Bitte crawle die FastAPI Dokumentation und speichere sie in einer Knowledge Base:
1. Nutze domain_deep_crawl_tool für https://fastapi.tiangolo.com
2. Speichere die Ergebnisse mit store_crawl_results in Collection "fastapi"
3. Suche dann nach "authentication" in der Collection
4. Fasse die gefundenen Informationen zusammen
Tests
# Alle Tests
pytest
# Nur schnelle Tests (empfohlen für Entwicklung)
pytest -m "not slow"
# Mit Coverage
pytest --cov=. --cov-report=html
# RAG Tests (erfordern Dependencies)
pytest tests/test_rag_integration.py tests/test_knowledge_base.py
Entwicklung
Server direkt starten:
uv run python server.py
Troubleshooting
Allgemeine Probleme
- Module not found: Stelle sicher, dass alle Dependencies installiert sind:
uv install
- Playwright fehlt: Browser installieren:
playwright install
- MCP Inspector verbindet nicht: Prüfe ob Server läuft und Config korrekt ist
RAG-spezifische Probleme
- "RAG tools not available": RAG Dependencies installieren (siehe Installation)
- ChromaDB Fehler: Prüfe
RAG_DB_PATH
Berechtigung und Speicherplatz - Embedding Model lädt nicht: Internetverbindung prüfen (Model wird bei erstem Start heruntergeladen)
- Speicher-Probleme bei großen Dokumenten:
RAG_CHUNK_SIZE
reduzieren oderRAG_DEVICE=cpu
setzen - Suche liefert keine Ergebnisse:
similarity_threshold
reduzieren oder Collection mitlist_collections
prüfen
RAG Tools Test
# Prüfen ob RAG Dependencies verfügbar sind
python3 -c "from tools.knowledge_base.dependencies import is_rag_available; print('RAG available:', is_rag_available())"
# RAG funktionalität testen
pytest tests/test_knowledge_base.py -v