Spaces:
Running
Running
Abdullah Meda
commited on
Commit
Β·
c6fe03c
1
Parent(s):
0955e72
refactoring edits
Browse files- README.md +35 -111
- Relevant README 1.md +0 -311
- Relevant README 2.md +0 -618
- app.py +20 -14
- schemas.py +1 -1
- make_docs.py β scripts/make_docs.py +0 -0
- make_rag_db.py β scripts/make_rag_db.py +0 -0
- utils.py +6 -6
README.md
CHANGED
@@ -14,39 +14,19 @@ license: apache-2.0
|
|
14 |
short_description: Latest π€ documentation for LLMs and AI code editors
|
15 |
---
|
16 |
|
17 |
-
#
|
18 |
|
19 |
-
|
20 |
-
<em>Real-time HuggingFace Documentation for AI Coding Assistants and LLMs</em>
|
21 |
-
</p>
|
22 |
|
|
|
23 |
|
24 |
-
|
25 |
-
---
|
26 |
-
**HfContext7** is a specialized Model Context Protocol (MCP) server designed to provide AI coding assistants and Large Language Models (LLMs) with **real-time, up-to-date documentation** from the HuggingFace ecosystem.
|
27 |
-
|
28 |
-
Inspired by the groundbreaking [Context7 MCP Server](https://github.com/upstash/context7), HfContext7 specifically targets the rapidly evolving HuggingFace libraries, ensuring your AI assistant always has the latest and most accurate information.
|
29 |
-
|
30 |
-
---
|
31 |
-
|
32 |
-
## β The Problem We Solve
|
33 |
-
|
34 |
-
The HuggingFace ecosystem evolves at lightning speed. New APIs, features, and best practices emerge constantly, making it challenging for LLMs trained on static datasets to keep up. This leads to:
|
35 |
-
|
36 |
-
- β Outdated code examples based on old training data
|
37 |
-
- β Hallucinated APIs that no longer exist or never existed
|
38 |
-
- β Generic answers that don't reflect current HuggingFace best practices
|
39 |
-
- β Confusion between similar HuggingFace libraries (Transformers, Diffusers, PEFT, etc.)
|
40 |
-
|
41 |
-
---
|
42 |
|
43 |
-
|
44 |
|
45 |
-
|
46 |
|
47 |
-
-
|
48 |
-
- **Semantic Search**: Leveraging advanced embeddings and vector search (powered by Milvus and OpenAI embeddings) to retrieve highly relevant documentation snippets.
|
49 |
-
- **Seamless Integration**: Easily integrates with popular AI coding assistants (Cursor, Claude Desktop, Windsurf, etc.) via MCP.
|
50 |
|
51 |
Simply add `use hfcontext7` to your prompt:
|
52 |
|
@@ -62,108 +42,52 @@ HfContext7 instantly provides your AI assistant with accurate, up-to-date Huggin
|
|
62 |
|
63 |
---
|
64 |
|
65 |
-
|
66 |
-
|
67 |
-
HfContext7 supports a wide range of HuggingFace libraries, including:
|
68 |
|
69 |
-
-
|
70 |
-
- **Diffusers** β Diffusion models for image/audio generation
|
71 |
-
- **PEFT** β Parameter-Efficient Fine-Tuning (LoRA, etc.)
|
72 |
-
- **TRL** β Transformer Reinforcement Learning
|
73 |
-
- **Datasets** β Access and share datasets
|
74 |
-
- **Accelerate** β Simplified distributed training
|
75 |
-
- **Text Generation Inference (TGI)** β High-performance inference
|
76 |
-
- **Optimum** β Hardware-optimized transformers
|
77 |
-
- **AutoTrain** β No-code training platform
|
78 |
-
- **bitsandbytes** β 8-bit optimizers and quantization
|
79 |
|
80 |
-
|
81 |
|
82 |
-
|
83 |
|
84 |
-
|
85 |
|
86 |
-
|
|
|
|
|
87 |
|
88 |
-
|
89 |
-
- **`get_huggingface_documentation`**: Retrieves relevant documentation for a specific topic, optionally filtered by resource names.
|
90 |
|
91 |
---
|
92 |
|
93 |
-
|
94 |
-
|
95 |
-
### 1. Clone and Install
|
96 |
|
97 |
-
|
98 |
-
git clone <repo-url>
|
99 |
-
cd hfcontext7
|
100 |
-
pip install -r requirements.txt
|
101 |
-
```
|
102 |
-
|
103 |
-
### 2. Set OpenAI API Key
|
104 |
-
|
105 |
-
```bash
|
106 |
-
echo "OPENAI_API_KEY=your_key_here" > .env
|
107 |
-
```
|
108 |
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
```
|
115 |
-
|
116 |
-
### 4. Run the Server
|
117 |
-
|
118 |
-
```bash
|
119 |
-
python app.py
|
120 |
-
```
|
121 |
|
122 |
---
|
123 |
|
124 |
-
|
125 |
-
|
126 |
-
### Cursor & Claude Desktop Example
|
127 |
-
|
128 |
-
```json
|
129 |
-
{
|
130 |
-
"mcpServers": {
|
131 |
-
"hfcontext7": {
|
132 |
-
"command": "python",
|
133 |
-
"args": ["/path/to/hfcontext7/app.py"],
|
134 |
-
"env": {
|
135 |
-
"OPENAI_API_KEY": "your_openai_api_key"
|
136 |
-
}
|
137 |
-
}
|
138 |
-
}
|
139 |
-
}
|
140 |
-
```
|
141 |
-
|
142 |
-
---
|
143 |
|
144 |
-
|
145 |
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
|
153 |
---
|
154 |
|
155 |
-
|
156 |
-
|
157 |
-
This project was heavily inspired by the incredible [Context7 MCP Server](https://github.com/upstash/context7) by Upstash, which revolutionized how LLMs access general development documentation. While Context7 provides broad coverage across many frameworks, HfContext7 focuses specifically on the HuggingFace ecosystem, providing deeper, more specialized knowledge for AI/ML development.
|
158 |
-
|
159 |
-
---
|
160 |
|
161 |
-
|
162 |
-
|
163 |
-
Apache 2.0
|
164 |
-
|
165 |
-
---
|
166 |
|
167 |
-
|
168 |
-
|
169 |
-
</p>
|
|
|
14 |
short_description: Latest π€ documentation for LLMs and AI code editors
|
15 |
---
|
16 |
|
17 |
+
# HFContext7: Up-to-date π€ Docs for your LLM
|
18 |
|
19 |
+
### The Problem: Your LLM is stuck in the past
|
|
|
|
|
20 |
|
21 |
+
You ask your AI assistant for a code snippet using the latest `diffusers` feature, and it confidently spits out code that was deprecated six months ago. You're trying to debug a `transformers` pipeline, and the LLM hallucinates parameters that don't exist. Sound familiar?
|
22 |
|
23 |
+
Large Language Models are powerful, but their knowledge is frozen in time. The Hugging Face ecosystem, however, moves at lightning speed. This knowledge gap leads to wasted time, frustrating debugging sessions, and a reliance on constant tab-switching to find the right documentation page.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
+
### The Solution: Fresh Docs, Right in Your Prompt
|
26 |
|
27 |
+
**HFContext7** is a Model Context Protocol (MCP) server that acts as a bridge between your AI assistant and the ever-evolving Hugging Face documentation. It provides your LLM with the ability to fetch the **single most relevant** documentation page for your query, ensuring the context it uses is fresh, accurate, and directly from the source.
|
28 |
|
29 |
+
**Inspired by the (unfortunately closed-source) `Context7` project**, we wanted to build an open-source alternative focused specifically on the rich, complex, and rapidly changing Hugging Face ecosystem.
|
|
|
|
|
30 |
|
31 |
Simply add `use hfcontext7` to your prompt:
|
32 |
|
|
|
42 |
|
43 |
---
|
44 |
|
45 |
+
### Under the Hood: A Smarter RAG Pipeline
|
|
|
|
|
46 |
|
47 |
+
Traditional RAG (Retrieval-Augmented Generation) on large documentation sets can be slow, expensive, and imprecise. Embedding entire libraries' worth of content leads to massive vector databases and often returns noisy, irrelevant chunks.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
|
49 |
+
We took a different, more surgical approach:
|
50 |
|
51 |
+
1. **Structural Pre-processing:** We first clone the official documentation for major Hugging Face libraries. We parse their structure (`_toctree.yml`) and organize the content into a clean, hierarchical file tree. This preserves the logical layout created by the library authors.
|
52 |
|
53 |
+
2. **Indexing Paths, Not Pages:** Instead of embedding the full text of each page (which can be huge), we only embed the **file paths**. A path like `Transformers/Main Classes/Trainer.md` contains a wealth of semantic information about the content. This keeps our vector index small, fast, and surprisingly effective.
|
54 |
|
55 |
+
3. **Two-Step Retrieval Magic:** This is where the magic happens.
|
56 |
+
* **Step 1: Candidate Search:** When you ask a question, we embed your query and perform a semantic search against our index of *file paths*. This instantly gives us the top 50 most likely documentation pages.
|
57 |
+
* **Step 2: LLM-Powered Selection:** We don't just dump all 50 files into the context. Instead, we generate a `tree`-like view of their file structure and present it to a powerful LLM (GPT-4o) along with your original question. The LLM's only job is to analyze this structure and choose the **one file** that is the most likely to contain the answer.
|
58 |
|
59 |
+
This approach is fast, cheap, and highly precise. It leverages the inherent structure of good documentation and uses a powerful reasoning engine for the final selection, ensuring you get the whole, relevant page, not just a random chunk.
|
|
|
60 |
|
61 |
---
|
62 |
|
63 |
+
### Challenges along the way
|
|
|
|
|
64 |
|
65 |
+
Building HFContext7 wasn't straightforward. We faced a few key challenges:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
|
67 |
+
* **The "Needle in a Haystack" Problem:** The HF ecosystem is massive. A simple keyword or vector search often returns dozens of tangentially related results. Our two-step retrieval pipeline was born from the need to drastically improve precision and find that one perfect document.
|
68 |
+
* **Scalability & Cost:** The idea of embedding the entirety of the HF docs was daunting. It would be slow to process and expensive to host. The path-embedding strategy was our answer to create a system that is both performant and cost-effective.
|
69 |
+
* **Taming Diverse Structures:** Not all documentation is created equal. We had to write a robust parser to handle the different ways various HF projects structure their `_toctree.yml` files, creating a unified and navigable database. Some libraries like Hugging Face.js and Sentence Transformers use completely different documentation structures that don't follow the standard `_toctree.yml` format.
|
70 |
+
* **Content Overflow Issues:** Raw markdown files often contain excessive comments, metadata, and navigation links that bloat the LLM's context window without adding value. Cleaning this content while preserving the essential information proved to be a delicate balance.
|
71 |
+
* **Infrastructure Limitations:** We initially planned to transition to Hugging Face Inference Providers for a more integrated experience, but couldn't access the $25 HF credits during development due to credit card requirements, forcing us to stick with OpenAI's APIs for now.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
|
73 |
---
|
74 |
|
75 |
+
### Roadmap for the Future
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
|
77 |
+
HFContext7 is just getting started. Here's where we're headed:
|
78 |
|
79 |
+
- πΊοΈ **Expanded Coverage:** Integrating more libraries from the Hugging Face ecosystem, including support for frameworks with non-standard documentation structures like Hugging Face.js and Sentence Transformers.
|
80 |
+
- π― **Enhanced Precision:** Moving beyond single-file retrieval to identify and return the most relevant *sections* within a document.
|
81 |
+
- π§βπ» **Enhanced Agentic Retrieval:** Building more sophisticated retrieval mechanisms that can provide broader documentation context while maintaining high accuracy, allowing for multi-document synthesis and cross-reference capabilities.
|
82 |
+
- π§Ή **Content Optimization:** Implementing smart content cleaning to remove unnecessary markdown comments, metadata, and navigation elements that waste context window space without losing critical information.
|
83 |
+
- π€ **HF Native Integration:** Transitioning to Hugging Face Inference Providers for embeddings and LLM calls, creating a fully integrated experience within the HF ecosystem.
|
84 |
+
- π§© **Enhanced Chunking Strategy:** Implementing a Context 7-inspired chunking approach that focuses on examples and creates distinct, semantically meaningful sections for each chunk, improving retrieval precision.
|
85 |
|
86 |
---
|
87 |
|
88 |
+
### Available Tools
|
|
|
|
|
|
|
|
|
89 |
|
90 |
+
This server exposes the following tools to an MCP client:
|
|
|
|
|
|
|
|
|
91 |
|
92 |
+
* `list_huggingface_resources_names()`: Returns a list of all the HF libraries and resources available for querying.
|
93 |
+
* `get_huggingface_documentation(topic: str, resource_names: list[str] = [])`: The main workhorse. Takes a topic (your question) and an optional list of resource names to search within, and returns the content of the most relevant documentation page.
|
|
Relevant README 1.md
DELETED
@@ -1,311 +0,0 @@
|
|
1 |
-
<h1 align="center">Crawl4AI RAG MCP Server</h1>
|
2 |
-
|
3 |
-
<p align="center">
|
4 |
-
<em>Web Crawling and RAG Capabilities for AI Agents and AI Coding Assistants</em>
|
5 |
-
</p>
|
6 |
-
|
7 |
-
A powerful implementation of the [Model Context Protocol (MCP)](https://modelcontextprotocol.io) integrated with [Crawl4AI](https://crawl4ai.com) and [Supabase](https://supabase.com/) for providing AI agents and AI coding assistants with advanced web crawling and RAG capabilities.
|
8 |
-
|
9 |
-
With this MCP server, you can <b>scrape anything</b> and then <b>use that knowledge anywhere</b> for RAG.
|
10 |
-
|
11 |
-
The primary goal is to bring this MCP server into [Archon](https://github.com/coleam00/Archon) as I evolve it to be more of a knowledge engine for AI coding assistants to build AI agents. This first version of the Crawl4AI/RAG MCP server will be improved upon greatly soon, especially making it more configurable so you can use different embedding models and run everything locally with Ollama.
|
12 |
-
|
13 |
-
## Overview
|
14 |
-
|
15 |
-
This MCP server provides tools that enable AI agents to crawl websites, store content in a vector database (Supabase), and perform RAG over the crawled content. It follows the best practices for building MCP servers based on the [Mem0 MCP server template](https://github.com/coleam00/mcp-mem0/) I provided on my channel previously.
|
16 |
-
|
17 |
-
The server includes several advanced RAG strategies that can be enabled to enhance retrieval quality:
|
18 |
-
- **Contextual Embeddings** for enriched semantic understanding
|
19 |
-
- **Hybrid Search** combining vector and keyword search
|
20 |
-
- **Agentic RAG** for specialized code example extraction
|
21 |
-
- **Reranking** for improved result relevance using cross-encoder models
|
22 |
-
|
23 |
-
See the [Configuration section](#configuration) below for details on how to enable and configure these strategies.
|
24 |
-
|
25 |
-
## Vision
|
26 |
-
|
27 |
-
The Crawl4AI RAG MCP server is just the beginning. Here's where we're headed:
|
28 |
-
|
29 |
-
1. **Integration with Archon**: Building this system directly into [Archon](https://github.com/coleam00/Archon) to create a comprehensive knowledge engine for AI coding assistants to build better AI agents.
|
30 |
-
|
31 |
-
2. **Multiple Embedding Models**: Expanding beyond OpenAI to support a variety of embedding models, including the ability to run everything locally with Ollama for complete control and privacy.
|
32 |
-
|
33 |
-
3. **Advanced RAG Strategies**: Implementing sophisticated retrieval techniques like contextual retrieval, late chunking, and others to move beyond basic "naive lookups" and significantly enhance the power and precision of the RAG system, especially as it integrates with Archon.
|
34 |
-
|
35 |
-
4. **Enhanced Chunking Strategy**: Implementing a Context 7-inspired chunking approach that focuses on examples and creates distinct, semantically meaningful sections for each chunk, improving retrieval precision.
|
36 |
-
|
37 |
-
5. **Performance Optimization**: Increasing crawling and indexing speed to make it more realistic to "quickly" index new documentation to then leverage it within the same prompt in an AI coding assistant.
|
38 |
-
|
39 |
-
## Features
|
40 |
-
|
41 |
-
- **Smart URL Detection**: Automatically detects and handles different URL types (regular webpages, sitemaps, text files)
|
42 |
-
- **Recursive Crawling**: Follows internal links to discover content
|
43 |
-
- **Parallel Processing**: Efficiently crawls multiple pages simultaneously
|
44 |
-
- **Content Chunking**: Intelligently splits content by headers and size for better processing
|
45 |
-
- **Vector Search**: Performs RAG over crawled content, optionally filtering by data source for precision
|
46 |
-
- **Source Retrieval**: Retrieve sources available for filtering to guide the RAG process
|
47 |
-
|
48 |
-
## Tools
|
49 |
-
|
50 |
-
The server provides essential web crawling and search tools:
|
51 |
-
|
52 |
-
### Core Tools (Always Available)
|
53 |
-
|
54 |
-
1. **`crawl_single_page`**: Quickly crawl a single web page and store its content in the vector database
|
55 |
-
2. **`smart_crawl_url`**: Intelligently crawl a full website based on the type of URL provided (sitemap, llms-full.txt, or a regular webpage that needs to be crawled recursively)
|
56 |
-
3. **`get_available_sources`**: Get a list of all available sources (domains) in the database
|
57 |
-
4. **`perform_rag_query`**: Search for relevant content using semantic search with optional source filtering
|
58 |
-
|
59 |
-
### Conditional Tools
|
60 |
-
|
61 |
-
5. **`search_code_examples`** (requires `USE_AGENTIC_RAG=true`): Search specifically for code examples and their summaries from crawled documentation. This tool provides targeted code snippet retrieval for AI coding assistants.
|
62 |
-
|
63 |
-
## Prerequisites
|
64 |
-
|
65 |
-
- [Docker/Docker Desktop](https://www.docker.com/products/docker-desktop/) if running the MCP server as a container (recommended)
|
66 |
-
- [Python 3.12+](https://www.python.org/downloads/) if running the MCP server directly through uv
|
67 |
-
- [Supabase](https://supabase.com/) (database for RAG)
|
68 |
-
- [OpenAI API key](https://platform.openai.com/api-keys) (for generating embeddings)
|
69 |
-
|
70 |
-
## Installation
|
71 |
-
|
72 |
-
### Using Docker (Recommended)
|
73 |
-
|
74 |
-
1. Clone this repository:
|
75 |
-
```bash
|
76 |
-
git clone https://github.com/coleam00/mcp-crawl4ai-rag.git
|
77 |
-
cd mcp-crawl4ai-rag
|
78 |
-
```
|
79 |
-
|
80 |
-
2. Build the Docker image:
|
81 |
-
```bash
|
82 |
-
docker build -t mcp/crawl4ai-rag --build-arg PORT=8051 .
|
83 |
-
```
|
84 |
-
|
85 |
-
3. Create a `.env` file based on the configuration section below
|
86 |
-
|
87 |
-
### Using uv directly (no Docker)
|
88 |
-
|
89 |
-
1. Clone this repository:
|
90 |
-
```bash
|
91 |
-
git clone https://github.com/coleam00/mcp-crawl4ai-rag.git
|
92 |
-
cd mcp-crawl4ai-rag
|
93 |
-
```
|
94 |
-
|
95 |
-
2. Install uv if you don't have it:
|
96 |
-
```bash
|
97 |
-
pip install uv
|
98 |
-
```
|
99 |
-
|
100 |
-
3. Create and activate a virtual environment:
|
101 |
-
```bash
|
102 |
-
uv venv
|
103 |
-
.venv\Scripts\activate
|
104 |
-
# on Mac/Linux: source .venv/bin/activate
|
105 |
-
```
|
106 |
-
|
107 |
-
4. Install dependencies:
|
108 |
-
```bash
|
109 |
-
uv pip install -e .
|
110 |
-
crawl4ai-setup
|
111 |
-
```
|
112 |
-
|
113 |
-
5. Create a `.env` file based on the configuration section below
|
114 |
-
|
115 |
-
## Database Setup
|
116 |
-
|
117 |
-
Before running the server, you need to set up the database with the pgvector extension:
|
118 |
-
|
119 |
-
1. Go to the SQL Editor in your Supabase dashboard (create a new project first if necessary)
|
120 |
-
|
121 |
-
2. Create a new query and paste the contents of `crawled_pages.sql`
|
122 |
-
|
123 |
-
3. Run the query to create the necessary tables and functions
|
124 |
-
|
125 |
-
## Configuration
|
126 |
-
|
127 |
-
Create a `.env` file in the project root with the following variables:
|
128 |
-
|
129 |
-
```
|
130 |
-
# MCP Server Configuration
|
131 |
-
HOST=0.0.0.0
|
132 |
-
PORT=8051
|
133 |
-
TRANSPORT=sse
|
134 |
-
|
135 |
-
# OpenAI API Configuration
|
136 |
-
OPENAI_API_KEY=your_openai_api_key
|
137 |
-
|
138 |
-
# LLM for summaries and contextual embeddings
|
139 |
-
MODEL_CHOICE=gpt-4.1-nano
|
140 |
-
|
141 |
-
# RAG Strategies (set to "true" or "false", default to "false")
|
142 |
-
USE_CONTEXTUAL_EMBEDDINGS=false
|
143 |
-
USE_HYBRID_SEARCH=false
|
144 |
-
USE_AGENTIC_RAG=false
|
145 |
-
USE_RERANKING=false
|
146 |
-
|
147 |
-
# Supabase Configuration
|
148 |
-
SUPABASE_URL=your_supabase_project_url
|
149 |
-
SUPABASE_SERVICE_KEY=your_supabase_service_key
|
150 |
-
```
|
151 |
-
|
152 |
-
### RAG Strategy Options
|
153 |
-
|
154 |
-
The Crawl4AI RAG MCP server supports four powerful RAG strategies that can be enabled independently:
|
155 |
-
|
156 |
-
#### 1. **USE_CONTEXTUAL_EMBEDDINGS**
|
157 |
-
When enabled, this strategy enhances each chunk's embedding with additional context from the entire document. The system passes both the full document and the specific chunk to an LLM (configured via `MODEL_CHOICE`) to generate enriched context that gets embedded alongside the chunk content.
|
158 |
-
|
159 |
-
- **When to use**: Enable this when you need high-precision retrieval where context matters, such as technical documentation where terms might have different meanings in different sections.
|
160 |
-
- **Trade-offs**: Slower indexing due to LLM calls for each chunk, but significantly better retrieval accuracy.
|
161 |
-
- **Cost**: Additional LLM API calls during indexing.
|
162 |
-
|
163 |
-
#### 2. **USE_HYBRID_SEARCH**
|
164 |
-
Combines traditional keyword search with semantic vector search to provide more comprehensive results. The system performs both searches in parallel and intelligently merges results, prioritizing documents that appear in both result sets.
|
165 |
-
|
166 |
-
- **When to use**: Enable this when users might search using specific technical terms, function names, or when exact keyword matches are important alongside semantic understanding.
|
167 |
-
- **Trade-offs**: Slightly slower search queries but more robust results, especially for technical content.
|
168 |
-
- **Cost**: No additional API costs, just computational overhead.
|
169 |
-
|
170 |
-
#### 3. **USE_AGENTIC_RAG**
|
171 |
-
Enables specialized code example extraction and storage. When crawling documentation, the system identifies code blocks (β₯300 characters), extracts them with surrounding context, generates summaries, and stores them in a separate vector database table specifically designed for code search.
|
172 |
-
|
173 |
-
- **When to use**: Essential for AI coding assistants that need to find specific code examples, implementation patterns, or usage examples from documentation.
|
174 |
-
- **Trade-offs**: Significantly slower crawling due to code extraction and summarization, requires more storage space.
|
175 |
-
- **Cost**: Additional LLM API calls for summarizing each code example.
|
176 |
-
- **Benefits**: Provides a dedicated `search_code_examples` tool that AI agents can use to find specific code implementations.
|
177 |
-
|
178 |
-
#### 4. **USE_RERANKING**
|
179 |
-
Applies cross-encoder reranking to search results after initial retrieval. Uses a lightweight cross-encoder model (`cross-encoder/ms-marco-MiniLM-L-6-v2`) to score each result against the original query, then reorders results by relevance.
|
180 |
-
|
181 |
-
- **When to use**: Enable this when search precision is critical and you need the most relevant results at the top. Particularly useful for complex queries where semantic similarity alone might not capture query intent.
|
182 |
-
- **Trade-offs**: Adds ~100-200ms to search queries depending on result count, but significantly improves result ordering.
|
183 |
-
- **Cost**: No additional API costs - uses a local model that runs on CPU.
|
184 |
-
- **Benefits**: Better result relevance, especially for complex queries. Works with both regular RAG search and code example search.
|
185 |
-
|
186 |
-
### Recommended Configurations
|
187 |
-
|
188 |
-
**For general documentation RAG:**
|
189 |
-
```
|
190 |
-
USE_CONTEXTUAL_EMBEDDINGS=false
|
191 |
-
USE_HYBRID_SEARCH=true
|
192 |
-
USE_AGENTIC_RAG=false
|
193 |
-
USE_RERANKING=true
|
194 |
-
```
|
195 |
-
|
196 |
-
**For AI coding assistant with code examples:**
|
197 |
-
```
|
198 |
-
USE_CONTEXTUAL_EMBEDDINGS=true
|
199 |
-
USE_HYBRID_SEARCH=true
|
200 |
-
USE_AGENTIC_RAG=true
|
201 |
-
USE_RERANKING=true
|
202 |
-
```
|
203 |
-
|
204 |
-
**For fast, basic RAG:**
|
205 |
-
```
|
206 |
-
USE_CONTEXTUAL_EMBEDDINGS=false
|
207 |
-
USE_HYBRID_SEARCH=true
|
208 |
-
USE_AGENTIC_RAG=false
|
209 |
-
USE_RERANKING=false
|
210 |
-
```
|
211 |
-
|
212 |
-
## Running the Server
|
213 |
-
|
214 |
-
### Using Docker
|
215 |
-
|
216 |
-
```bash
|
217 |
-
docker run --env-file .env -p 8051:8051 mcp/crawl4ai-rag
|
218 |
-
```
|
219 |
-
|
220 |
-
### Using Python
|
221 |
-
|
222 |
-
```bash
|
223 |
-
uv run src/crawl4ai_mcp.py
|
224 |
-
```
|
225 |
-
|
226 |
-
The server will start and listen on the configured host and port.
|
227 |
-
|
228 |
-
## Integration with MCP Clients
|
229 |
-
|
230 |
-
### SSE Configuration
|
231 |
-
|
232 |
-
Once you have the server running with SSE transport, you can connect to it using this configuration:
|
233 |
-
|
234 |
-
```json
|
235 |
-
{
|
236 |
-
"mcpServers": {
|
237 |
-
"crawl4ai-rag": {
|
238 |
-
"transport": "sse",
|
239 |
-
"url": "http://localhost:8051/sse"
|
240 |
-
}
|
241 |
-
}
|
242 |
-
}
|
243 |
-
```
|
244 |
-
|
245 |
-
> **Note for Windsurf users**: Use `serverUrl` instead of `url` in your configuration:
|
246 |
-
> ```json
|
247 |
-
> {
|
248 |
-
> "mcpServers": {
|
249 |
-
> "crawl4ai-rag": {
|
250 |
-
> "transport": "sse",
|
251 |
-
> "serverUrl": "http://localhost:8051/sse"
|
252 |
-
> }
|
253 |
-
> }
|
254 |
-
> }
|
255 |
-
> ```
|
256 |
-
>
|
257 |
-
> **Note for Docker users**: Use `host.docker.internal` instead of `localhost` if your client is running in a different container. This will apply if you are using this MCP server within n8n!
|
258 |
-
|
259 |
-
### Stdio Configuration
|
260 |
-
|
261 |
-
Add this server to your MCP configuration for Claude Desktop, Windsurf, or any other MCP client:
|
262 |
-
|
263 |
-
```json
|
264 |
-
{
|
265 |
-
"mcpServers": {
|
266 |
-
"crawl4ai-rag": {
|
267 |
-
"command": "python",
|
268 |
-
"args": ["path/to/crawl4ai-mcp/src/crawl4ai_mcp.py"],
|
269 |
-
"env": {
|
270 |
-
"TRANSPORT": "stdio",
|
271 |
-
"OPENAI_API_KEY": "your_openai_api_key",
|
272 |
-
"SUPABASE_URL": "your_supabase_url",
|
273 |
-
"SUPABASE_SERVICE_KEY": "your_supabase_service_key"
|
274 |
-
}
|
275 |
-
}
|
276 |
-
}
|
277 |
-
}
|
278 |
-
```
|
279 |
-
|
280 |
-
### Docker with Stdio Configuration
|
281 |
-
|
282 |
-
```json
|
283 |
-
{
|
284 |
-
"mcpServers": {
|
285 |
-
"crawl4ai-rag": {
|
286 |
-
"command": "docker",
|
287 |
-
"args": ["run", "--rm", "-i",
|
288 |
-
"-e", "TRANSPORT",
|
289 |
-
"-e", "OPENAI_API_KEY",
|
290 |
-
"-e", "SUPABASE_URL",
|
291 |
-
"-e", "SUPABASE_SERVICE_KEY",
|
292 |
-
"mcp/crawl4ai"],
|
293 |
-
"env": {
|
294 |
-
"TRANSPORT": "stdio",
|
295 |
-
"OPENAI_API_KEY": "your_openai_api_key",
|
296 |
-
"SUPABASE_URL": "your_supabase_url",
|
297 |
-
"SUPABASE_SERVICE_KEY": "your_supabase_service_key"
|
298 |
-
}
|
299 |
-
}
|
300 |
-
}
|
301 |
-
}
|
302 |
-
```
|
303 |
-
|
304 |
-
## Building Your Own Server
|
305 |
-
|
306 |
-
This implementation provides a foundation for building more complex MCP servers with web crawling capabilities. To build your own:
|
307 |
-
|
308 |
-
1. Add your own tools by creating methods with the `@mcp.tool()` decorator
|
309 |
-
2. Create your own lifespan function to add your own dependencies
|
310 |
-
3. Modify the `utils.py` file for any helper functions you need
|
311 |
-
4. Extend the crawling capabilities by adding more specialized crawlers
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Relevant README 2.md
DELETED
@@ -1,618 +0,0 @@
|
|
1 |
-
# Context7 MCP - Up-to-date Code Docs For Any Prompt
|
2 |
-
|
3 |
-
[](https://context7.com) [](https://smithery.ai/server/@upstash/context7-mcp) [<img alt="Install in VS Code (npx)" src="https://img.shields.io/badge/VS_Code-VS_Code?style=flat-square&label=Install%20Context7%20MCP&color=0098FF">](https://insiders.vscode.dev/redirect?url=vscode%3Amcp%2Finstall%3F%7B%22name%22%3A%22context7%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40upstash%2Fcontext7-mcp%40latest%22%5D%7D)
|
4 |
-
|
5 |
-
[](./docs/README.zh-TW.md) [](./docs/README.zh-CN.md) [](./docs/README.ko.md) [](./docs/README.es.md) [](./docs/README.fr.md) [-purple>)](./docs/README.pt-BR.md) [](./docs/README.it.md) [](./docs/README.id-ID.md) [](./docs/README.de.md) [](./docs/README.ru.md) [](./docs/README.tr.md) [](./docs/README.ar.md)
|
6 |
-
|
7 |
-
## β Without Context7
|
8 |
-
|
9 |
-
LLMs rely on outdated or generic information about the libraries you use. You get:
|
10 |
-
|
11 |
-
- β Code examples are outdated and based on year-old training data
|
12 |
-
- β Hallucinated APIs don't even exist
|
13 |
-
- β Generic answers for old package versions
|
14 |
-
|
15 |
-
## β
With Context7
|
16 |
-
|
17 |
-
Context7 MCP pulls up-to-date, version-specific documentation and code examples straight from the source β and places them directly into your prompt.
|
18 |
-
|
19 |
-
Add `use context7` to your prompt in Cursor:
|
20 |
-
|
21 |
-
```txt
|
22 |
-
Create a basic Next.js project with app router. use context7
|
23 |
-
```
|
24 |
-
|
25 |
-
```txt
|
26 |
-
Create a script to delete the rows where the city is "" given PostgreSQL credentials. use context7
|
27 |
-
```
|
28 |
-
|
29 |
-
Context7 fetches up-to-date code examples and documentation right into your LLM's context.
|
30 |
-
|
31 |
-
- 1οΈβ£ Write your prompt naturally
|
32 |
-
- 2οΈβ£ Tell the LLM to `use context7`
|
33 |
-
- 3οΈβ£ Get working code answers
|
34 |
-
|
35 |
-
No tab-switching, no hallucinated APIs that don't exist, no outdated code generations.
|
36 |
-
|
37 |
-
## π Adding Projects
|
38 |
-
|
39 |
-
Check out our [project addition guide](./docs/adding-projects.md) to learn how to add (or update) your favorite libraries to Context7.
|
40 |
-
|
41 |
-
## π οΈ Installation
|
42 |
-
|
43 |
-
### Requirements
|
44 |
-
|
45 |
-
- Node.js >= v18.0.0
|
46 |
-
- Cursor, Windsurf, Claude Desktop or another MCP Client
|
47 |
-
|
48 |
-
<details>
|
49 |
-
<summary><b>Installing via Smithery</b></summary>
|
50 |
-
|
51 |
-
To install Context7 MCP Server for any client automatically via [Smithery](https://smithery.ai/server/@upstash/context7-mcp):
|
52 |
-
|
53 |
-
```bash
|
54 |
-
npx -y @smithery/cli@latest install @upstash/context7-mcp --client <CLIENT_NAME> --key <YOUR_SMITHERY_KEY>
|
55 |
-
```
|
56 |
-
|
57 |
-
You can find your Smithery key in the [Smithery.ai webpage](https://smithery.ai/server/@upstash/context7-mcp).
|
58 |
-
|
59 |
-
</details>
|
60 |
-
|
61 |
-
<details>
|
62 |
-
<summary><b>Install in Cursor</b></summary>
|
63 |
-
|
64 |
-
Go to: `Settings` -> `Cursor Settings` -> `MCP` -> `Add new global MCP server`
|
65 |
-
|
66 |
-
Pasting the following configuration into your Cursor `~/.cursor/mcp.json` file is the recommended approach. You may also install in a specific project by creating `.cursor/mcp.json` in your project folder. See [Cursor MCP docs](https://docs.cursor.com/context/model-context-protocol) for more info.
|
67 |
-
|
68 |
-
> Since Cursor 1.0, you can click the install button below for instant one-click installation.
|
69 |
-
|
70 |
-
#### Cursor Remote Server Connection
|
71 |
-
|
72 |
-
[](https://cursor.com/install-mcp?name=context7&config=eyJ1cmwiOiJodHRwczovL21jcC5jb250ZXh0Ny5jb20vbWNwIn0%3D)
|
73 |
-
|
74 |
-
```json
|
75 |
-
{
|
76 |
-
"mcpServers": {
|
77 |
-
"context7": {
|
78 |
-
"url": "https://mcp.context7.com/mcp"
|
79 |
-
}
|
80 |
-
}
|
81 |
-
}
|
82 |
-
```
|
83 |
-
|
84 |
-
#### Cursor Local Server Connection
|
85 |
-
|
86 |
-
[](https://cursor.com/install-mcp?name=context7&config=eyJjb21tYW5kIjoibnB4IC15IEB1cHN0YXNoL2NvbnRleHQ3LW1jcCJ9)
|
87 |
-
|
88 |
-
```json
|
89 |
-
{
|
90 |
-
"mcpServers": {
|
91 |
-
"context7": {
|
92 |
-
"command": "npx",
|
93 |
-
"args": ["-y", "@upstash/context7-mcp"]
|
94 |
-
}
|
95 |
-
}
|
96 |
-
}
|
97 |
-
```
|
98 |
-
|
99 |
-
<details>
|
100 |
-
<summary>Alternative: Use Bun</summary>
|
101 |
-
|
102 |
-
[](https://cursor.com/install-mcp?name=context7&config=eyJjb21tYW5kIjoiYnVueCAteSBAdXBzdGFzaC9jb250ZXh0Ny1tY3AifQ%3D%3D)
|
103 |
-
|
104 |
-
```json
|
105 |
-
{
|
106 |
-
"mcpServers": {
|
107 |
-
"context7": {
|
108 |
-
"command": "bunx",
|
109 |
-
"args": ["-y", "@upstash/context7-mcp"]
|
110 |
-
}
|
111 |
-
}
|
112 |
-
}
|
113 |
-
```
|
114 |
-
|
115 |
-
</details>
|
116 |
-
|
117 |
-
<details>
|
118 |
-
<summary>Alternative: Use Deno</summary>
|
119 |
-
|
120 |
-
[](https://cursor.com/install-mcp?name=context7&config=eyJjb21tYW5kIjoiZGVubyBydW4gLS1hbGxvdy1lbnYgLS1hbGxvdy1uZXQgbnBtOkB1cHN0YXNoL2NvbnRleHQ3LW1jcCJ9)
|
121 |
-
|
122 |
-
```json
|
123 |
-
{
|
124 |
-
"mcpServers": {
|
125 |
-
"context7": {
|
126 |
-
"command": "deno",
|
127 |
-
"args": ["run", "--allow-env", "--allow-net", "npm:@upstash/context7-mcp"]
|
128 |
-
}
|
129 |
-
}
|
130 |
-
}
|
131 |
-
```
|
132 |
-
|
133 |
-
</details>
|
134 |
-
|
135 |
-
</details>
|
136 |
-
|
137 |
-
<details>
|
138 |
-
<summary><b>Install in Windsurf</b></summary>
|
139 |
-
|
140 |
-
Add this to your Windsurf MCP config file. See [Windsurf MCP docs](https://docs.windsurf.com/windsurf/mcp) for more info.
|
141 |
-
|
142 |
-
#### Windsurf Remote Server Connection
|
143 |
-
|
144 |
-
```json
|
145 |
-
{
|
146 |
-
"mcpServers": {
|
147 |
-
"context7": {
|
148 |
-
"serverUrl": "https://mcp.context7.com/sse"
|
149 |
-
}
|
150 |
-
}
|
151 |
-
}
|
152 |
-
```
|
153 |
-
|
154 |
-
#### Windsurf Local Server Connection
|
155 |
-
|
156 |
-
```json
|
157 |
-
{
|
158 |
-
"mcpServers": {
|
159 |
-
"context7": {
|
160 |
-
"command": "npx",
|
161 |
-
"args": ["-y", "@upstash/context7-mcp"]
|
162 |
-
}
|
163 |
-
}
|
164 |
-
}
|
165 |
-
```
|
166 |
-
|
167 |
-
</details>
|
168 |
-
|
169 |
-
<details>
|
170 |
-
<summary><b>Install in VS Code</b></summary>
|
171 |
-
|
172 |
-
[<img alt="Install in VS Code (npx)" src="https://img.shields.io/badge/VS_Code-VS_Code?style=flat-square&label=Install%20Context7%20MCP&color=0098FF">](https://insiders.vscode.dev/redirect?url=vscode%3Amcp%2Finstall%3F%7B%22name%22%3A%22context7%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40upstash%2Fcontext7-mcp%40latest%22%5D%7D)
|
173 |
-
[<img alt="Install in VS Code Insiders (npx)" src="https://img.shields.io/badge/VS_Code_Insiders-VS_Code_Insiders?style=flat-square&label=Install%20Context7%20MCP&color=24bfa5">](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Amcp%2Finstall%3F%7B%22name%22%3A%22context7%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40upstash%2Fcontext7-mcp%40latest%22%5D%7D)
|
174 |
-
|
175 |
-
Add this to your VS Code MCP config file. See [VS Code MCP docs](https://code.visualstudio.com/docs/copilot/chat/mcp-servers) for more info.
|
176 |
-
|
177 |
-
#### VS Code Remote Server Connection
|
178 |
-
|
179 |
-
```json
|
180 |
-
"mcp": {
|
181 |
-
"servers": {
|
182 |
-
"context7": {
|
183 |
-
"type": "http",
|
184 |
-
"url": "https://mcp.context7.com/mcp"
|
185 |
-
}
|
186 |
-
}
|
187 |
-
}
|
188 |
-
```
|
189 |
-
|
190 |
-
#### VS Code Local Server Connection
|
191 |
-
|
192 |
-
```json
|
193 |
-
"mcp": {
|
194 |
-
"servers": {
|
195 |
-
"context7": {
|
196 |
-
"type": "stdio",
|
197 |
-
"command": "npx",
|
198 |
-
"args": ["-y", "@upstash/context7-mcp"]
|
199 |
-
}
|
200 |
-
}
|
201 |
-
}
|
202 |
-
```
|
203 |
-
|
204 |
-
</details>
|
205 |
-
|
206 |
-
<details>
|
207 |
-
<summary><b>Install in Zed</b></summary>
|
208 |
-
|
209 |
-
It can be installed via [Zed Extensions](https://zed.dev/extensions?query=Context7) or you can add this to your Zed `settings.json`. See [Zed Context Server docs](https://zed.dev/docs/assistant/context-servers) for more info.
|
210 |
-
|
211 |
-
```json
|
212 |
-
{
|
213 |
-
"context_servers": {
|
214 |
-
"Context7": {
|
215 |
-
"command": {
|
216 |
-
"path": "npx",
|
217 |
-
"args": ["-y", "@upstash/context7-mcp"]
|
218 |
-
},
|
219 |
-
"settings": {}
|
220 |
-
}
|
221 |
-
}
|
222 |
-
}
|
223 |
-
```
|
224 |
-
|
225 |
-
</details>
|
226 |
-
|
227 |
-
<details>
|
228 |
-
<summary><b>Install in Claude Code</b></summary>
|
229 |
-
|
230 |
-
Run this command. See [Claude Code MCP docs](https://docs.anthropic.com/en/docs/agents-and-tools/claude-code/tutorials#set-up-model-context-protocol-mcp) for more info.
|
231 |
-
|
232 |
-
#### Claude Code Remote Server Connection
|
233 |
-
|
234 |
-
```sh
|
235 |
-
claude mcp add --transport sse context7 https://mcp.context7.com/sse
|
236 |
-
```
|
237 |
-
|
238 |
-
#### Claude Code Local Server Connection
|
239 |
-
|
240 |
-
```sh
|
241 |
-
claude mcp add context7 -- npx -y @upstash/context7-mcp
|
242 |
-
```
|
243 |
-
|
244 |
-
</details>
|
245 |
-
|
246 |
-
<details>
|
247 |
-
<summary><b>Install in Claude Desktop</b></summary>
|
248 |
-
|
249 |
-
Add this to your Claude Desktop `claude_desktop_config.json` file. See [Claude Desktop MCP docs](https://modelcontextprotocol.io/quickstart/user) for more info.
|
250 |
-
|
251 |
-
```json
|
252 |
-
{
|
253 |
-
"mcpServers": {
|
254 |
-
"Context7": {
|
255 |
-
"command": "npx",
|
256 |
-
"args": ["-y", "@upstash/context7-mcp"]
|
257 |
-
}
|
258 |
-
}
|
259 |
-
}
|
260 |
-
```
|
261 |
-
|
262 |
-
</details>
|
263 |
-
|
264 |
-
<details>
|
265 |
-
<summary><b>Install in BoltAI</b></summary>
|
266 |
-
|
267 |
-
Open the "Settings" page of the app, navigate to "Plugins," and enter the following JSON:
|
268 |
-
|
269 |
-
```json
|
270 |
-
{
|
271 |
-
"mcpServers": {
|
272 |
-
"context7": {
|
273 |
-
"command": "npx",
|
274 |
-
"args": ["-y", "@upstash/context7-mcp"]
|
275 |
-
}
|
276 |
-
}
|
277 |
-
}
|
278 |
-
```
|
279 |
-
|
280 |
-
Once saved, enter in the chat `get-library-docs` followed by your Context7 documentation ID (e.g., `get-library-docs /nuxt/ui`). More information is available on [BoltAI's Documentation site](https://docs.boltai.com/docs/plugins/mcp-servers). For BoltAI on iOS, [see this guide](https://docs.boltai.com/docs/boltai-mobile/mcp-servers).
|
281 |
-
|
282 |
-
</details>
|
283 |
-
|
284 |
-
<details>
|
285 |
-
<summary><b>Using Docker</b></summary>
|
286 |
-
|
287 |
-
If you prefer to run the MCP server in a Docker container:
|
288 |
-
|
289 |
-
1. **Build the Docker Image:**
|
290 |
-
|
291 |
-
First, create a `Dockerfile` in the project root (or anywhere you prefer):
|
292 |
-
|
293 |
-
<details>
|
294 |
-
<summary>Click to see Dockerfile content</summary>
|
295 |
-
|
296 |
-
```Dockerfile
|
297 |
-
FROM node:18-alpine
|
298 |
-
|
299 |
-
WORKDIR /app
|
300 |
-
|
301 |
-
# Install the latest version globally
|
302 |
-
RUN npm install -g @upstash/context7-mcp
|
303 |
-
|
304 |
-
# Expose default port if needed (optional, depends on MCP client interaction)
|
305 |
-
# EXPOSE 3000
|
306 |
-
|
307 |
-
# Default command to run the server
|
308 |
-
CMD ["context7-mcp"]
|
309 |
-
```
|
310 |
-
|
311 |
-
</details>
|
312 |
-
|
313 |
-
Then, build the image using a tag (e.g., `context7-mcp`). **Make sure Docker Desktop (or the Docker daemon) is running.** Run the following command in the same directory where you saved the `Dockerfile`:
|
314 |
-
|
315 |
-
```bash
|
316 |
-
docker build -t context7-mcp .
|
317 |
-
```
|
318 |
-
|
319 |
-
2. **Configure Your MCP Client:**
|
320 |
-
|
321 |
-
Update your MCP client's configuration to use the Docker command.
|
322 |
-
|
323 |
-
_Example for a cline_mcp_settings.json:_
|
324 |
-
|
325 |
-
```json
|
326 |
-
{
|
327 |
-
"mcpServers": {
|
328 |
-
"Π‘ontext7": {
|
329 |
-
"autoApprove": [],
|
330 |
-
"disabled": false,
|
331 |
-
"timeout": 60,
|
332 |
-
"command": "docker",
|
333 |
-
"args": ["run", "-i", "--rm", "context7-mcp"],
|
334 |
-
"transportType": "stdio"
|
335 |
-
}
|
336 |
-
}
|
337 |
-
}
|
338 |
-
```
|
339 |
-
|
340 |
-
_Note: This is an example configuration. Please refer to the specific examples for your MCP client (like Cursor, VS Code, etc.) earlier in this README to adapt the structure (e.g., `mcpServers` vs `servers`). Also, ensure the image name in `args` matches the tag used during the `docker build` command._
|
341 |
-
|
342 |
-
</details>
|
343 |
-
|
344 |
-
<details>
|
345 |
-
<summary><b>Install in Windows</b></summary>
|
346 |
-
|
347 |
-
The configuration on Windows is slightly different compared to Linux or macOS (_`Cline` is used in the example_). The same principle applies to other editors; refer to the configuration of `command` and `args`.
|
348 |
-
|
349 |
-
```json
|
350 |
-
{
|
351 |
-
"mcpServers": {
|
352 |
-
"github.com/upstash/context7-mcp": {
|
353 |
-
"command": "cmd",
|
354 |
-
"args": ["/c", "npx", "-y", "@upstash/context7-mcp@latest"],
|
355 |
-
"disabled": false,
|
356 |
-
"autoApprove": []
|
357 |
-
}
|
358 |
-
}
|
359 |
-
}
|
360 |
-
```
|
361 |
-
|
362 |
-
</details>
|
363 |
-
|
364 |
-
<details>
|
365 |
-
<summary><b>Install in Augment Code</b></summary>
|
366 |
-
|
367 |
-
To configure Context7 MCP in Augment Code, follow these steps:
|
368 |
-
|
369 |
-
1. Press Cmd/Ctrl Shift P or go to the hamburger menu in the Augment panel
|
370 |
-
2. Select Edit Settings
|
371 |
-
3. Under Advanced, click Edit in settings.json
|
372 |
-
4. Add the server configuration to the `mcpServers` array in the `augment.advanced` object
|
373 |
-
|
374 |
-
```json
|
375 |
-
"augment.advanced": {
|
376 |
-
"mcpServers": [
|
377 |
-
{
|
378 |
-
"name": "context7",
|
379 |
-
"command": "npx",
|
380 |
-
"args": ["-y", "@upstash/context7-mcp"]
|
381 |
-
}
|
382 |
-
]
|
383 |
-
}
|
384 |
-
```
|
385 |
-
|
386 |
-
Once the MCP server is added, restart your editor. If you receive any errors, check the syntax to make sure closing brackets or commas are not missing.
|
387 |
-
|
388 |
-
</details>
|
389 |
-
|
390 |
-
<details>
|
391 |
-
<summary><b>Install in Roo Code</b></summary>
|
392 |
-
|
393 |
-
Add this to your Roo Code MCP configuration file. See [Roo Code MCP docs](https://docs.roocode.com/features/mcp/using-mcp-in-roo) for more info.
|
394 |
-
|
395 |
-
#### Roo Code Remote Server Connection
|
396 |
-
|
397 |
-
```json
|
398 |
-
{
|
399 |
-
"mcpServers": {
|
400 |
-
"context7": {
|
401 |
-
"type": "streamable-http",
|
402 |
-
"url": "https://mcp.context7.com/mcp"
|
403 |
-
}
|
404 |
-
}
|
405 |
-
}
|
406 |
-
```
|
407 |
-
|
408 |
-
#### Roo Code Local Server Connection
|
409 |
-
|
410 |
-
```json
|
411 |
-
{
|
412 |
-
"mcpServers": {
|
413 |
-
"context7": {
|
414 |
-
"command": "npx",
|
415 |
-
"args": ["-y", "@upstash/context7-mcp"]
|
416 |
-
}
|
417 |
-
}
|
418 |
-
}
|
419 |
-
```
|
420 |
-
|
421 |
-
</details>
|
422 |
-
|
423 |
-
<details>
|
424 |
-
<summary><b>Install in Zencoder</b></summary>
|
425 |
-
|
426 |
-
To configure Context7 MCP in Zencoder, follow these steps:
|
427 |
-
|
428 |
-
1. Go to the Zencoder menu (...)
|
429 |
-
2. From the dropdown menu, select Agent tools
|
430 |
-
3. Click on the Add custom MCP
|
431 |
-
4. Add the name and server configuration from below, and make sure to hit the Install button
|
432 |
-
|
433 |
-
```json
|
434 |
-
{
|
435 |
-
"command": "npx",
|
436 |
-
"args": [
|
437 |
-
"-y",
|
438 |
-
"@upstash/context7-mcp@latest"
|
439 |
-
]
|
440 |
-
}
|
441 |
-
```
|
442 |
-
|
443 |
-
Once the MCP server is added, you can easily continue using it.
|
444 |
-
|
445 |
-
</details>
|
446 |
-
|
447 |
-
## π§ Environment Variables
|
448 |
-
|
449 |
-
The Context7 MCP server supports the following environment variables:
|
450 |
-
|
451 |
-
- `DEFAULT_MINIMUM_TOKENS`: Set the minimum token count for documentation retrieval (default: 10000)
|
452 |
-
|
453 |
-
Example configuration with environment variables:
|
454 |
-
|
455 |
-
```json
|
456 |
-
{
|
457 |
-
"mcpServers": {
|
458 |
-
"context7": {
|
459 |
-
"command": "npx",
|
460 |
-
"args": ["-y", "@upstash/context7-mcp"],
|
461 |
-
"env": {
|
462 |
-
"DEFAULT_MINIMUM_TOKENS": "6000"
|
463 |
-
}
|
464 |
-
}
|
465 |
-
}
|
466 |
-
}
|
467 |
-
```
|
468 |
-
|
469 |
-
## π¨ Available Tools
|
470 |
-
|
471 |
-
Context7 MCP provides the following tools that LLMs can use:
|
472 |
-
|
473 |
-
- `resolve-library-id`: Resolves a general library name into a Context7-compatible library ID.
|
474 |
-
|
475 |
-
- `libraryName` (required): The name of the library to search for
|
476 |
-
|
477 |
-
- `get-library-docs`: Fetches documentation for a library using a Context7-compatible library ID.
|
478 |
-
- `context7CompatibleLibraryID` (required): Exact Context7-compatible library ID (e.g., `/mongodb/docs`, `/vercel/next.js`)
|
479 |
-
- `topic` (optional): Focus the docs on a specific topic (e.g., "routing", "hooks")
|
480 |
-
- `tokens` (optional, default 10000): Max number of tokens to return. Values less than the configured `DEFAULT_MINIMUM_TOKENS` value or the default value of 10000 are automatically increased to that value.
|
481 |
-
|
482 |
-
## π» Development
|
483 |
-
|
484 |
-
Clone the project and install dependencies:
|
485 |
-
|
486 |
-
```bash
|
487 |
-
bun i
|
488 |
-
```
|
489 |
-
|
490 |
-
Build:
|
491 |
-
|
492 |
-
```bash
|
493 |
-
bun run build
|
494 |
-
```
|
495 |
-
|
496 |
-
<details>
|
497 |
-
<summary><b>Local Configuration Example</b></summary>
|
498 |
-
|
499 |
-
```json
|
500 |
-
{
|
501 |
-
"mcpServers": {
|
502 |
-
"context7": {
|
503 |
-
"command": "npx",
|
504 |
-
"args": ["tsx", "/path/to/folder/context7-mcp/src/index.ts"]
|
505 |
-
}
|
506 |
-
}
|
507 |
-
}
|
508 |
-
```
|
509 |
-
|
510 |
-
</details>
|
511 |
-
|
512 |
-
<details>
|
513 |
-
<summary><b>Testing with MCP Inspector</b></summary>
|
514 |
-
|
515 |
-
```bash
|
516 |
-
npx -y @modelcontextprotocol/inspector npx @upstash/context7-mcp
|
517 |
-
```
|
518 |
-
|
519 |
-
</details>
|
520 |
-
|
521 |
-
## π¨ Troubleshooting
|
522 |
-
|
523 |
-
<details>
|
524 |
-
<summary><b>Module Not Found Errors</b></summary>
|
525 |
-
|
526 |
-
If you encounter `ERR_MODULE_NOT_FOUND`, try using `bunx` instead of `npx`:
|
527 |
-
|
528 |
-
```json
|
529 |
-
{
|
530 |
-
"mcpServers": {
|
531 |
-
"context7": {
|
532 |
-
"command": "bunx",
|
533 |
-
"args": ["-y", "@upstash/context7-mcp"]
|
534 |
-
}
|
535 |
-
}
|
536 |
-
}
|
537 |
-
```
|
538 |
-
|
539 |
-
This often resolves module resolution issues in environments where `npx` doesn't properly install or resolve packages.
|
540 |
-
|
541 |
-
</details>
|
542 |
-
|
543 |
-
<details>
|
544 |
-
<summary><b>ESM Resolution Issues</b></summary>
|
545 |
-
|
546 |
-
For errors like `Error: Cannot find module 'uriTemplate.js'`, try the `--experimental-vm-modules` flag:
|
547 |
-
|
548 |
-
```json
|
549 |
-
{
|
550 |
-
"mcpServers": {
|
551 |
-
"context7": {
|
552 |
-
"command": "npx",
|
553 |
-
"args": ["-y", "--node-options=--experimental-vm-modules", "@upstash/[email protected]"]
|
554 |
-
}
|
555 |
-
}
|
556 |
-
}
|
557 |
-
```
|
558 |
-
|
559 |
-
</details>
|
560 |
-
|
561 |
-
<details>
|
562 |
-
<summary><b>TLS/Certificate Issues</b></summary>
|
563 |
-
|
564 |
-
Use the `--experimental-fetch` flag to bypass TLS-related problems:
|
565 |
-
|
566 |
-
```json
|
567 |
-
{
|
568 |
-
"mcpServers": {
|
569 |
-
"context7": {
|
570 |
-
"command": "npx",
|
571 |
-
"args": ["-y", "--node-options=--experimental-fetch", "@upstash/context7-mcp"]
|
572 |
-
}
|
573 |
-
}
|
574 |
-
}
|
575 |
-
```
|
576 |
-
|
577 |
-
</details>
|
578 |
-
|
579 |
-
<details>
|
580 |
-
<summary><b>General MCP Client Errors</b></summary>
|
581 |
-
|
582 |
-
1. Try adding `@latest` to the package name
|
583 |
-
2. Use `bunx` as an alternative to `npx`
|
584 |
-
3. Consider using `deno` as another alternative
|
585 |
-
4. Ensure you're using Node.js v18 or higher for native fetch support
|
586 |
-
|
587 |
-
</details>
|
588 |
-
|
589 |
-
## β οΈ Disclaimer
|
590 |
-
|
591 |
-
Context7 projects are community-contributed and while we strive to maintain high quality, we cannot guarantee the accuracy, completeness, or security of all library documentation. Projects listed in Context7 are developed and maintained by their respective owners, not by Context7. If you encounter any suspicious, inappropriate, or potentially harmful content, please use the "Report" button on the project page to notify us immediately. We take all reports seriously and will review flagged content promptly to maintain the integrity and safety of our platform. By using Context7, you acknowledge that you do so at your own discretion and risk.
|
592 |
-
|
593 |
-
## π€ Connect with Us
|
594 |
-
|
595 |
-
Stay updated and join our community:
|
596 |
-
|
597 |
-
- π’ Follow us on [X](https://x.com/contextai) for the latest news and updates
|
598 |
-
- π Visit our [Website](https://context7.com)
|
599 |
-
- π¬ Join our [Discord Community](https://upstash.com/discord)
|
600 |
-
|
601 |
-
## πΊ Context7 In Media
|
602 |
-
|
603 |
-
- [Better Stack: "Free Tool Makes Cursor 10x Smarter"](https://youtu.be/52FC3qObp9E)
|
604 |
-
- [Cole Medin: "This is Hands Down the BEST MCP Server for AI Coding Assistants"](https://www.youtube.com/watch?v=G7gK8H6u7Rs)
|
605 |
-
- [Income Stream Surfers: "Context7 + SequentialThinking MCPs: Is This AGI?"](https://www.youtube.com/watch?v=-ggvzyLpK6o)
|
606 |
-
- [Julian Goldie SEO: "Context7: New MCP AI Agent Update"](https://www.youtube.com/watch?v=CTZm6fBYisc)
|
607 |
-
- [JeredBlu: "Context 7 MCP: Get Documentation Instantly + VS Code Setup"](https://www.youtube.com/watch?v=-ls0D-rtET4)
|
608 |
-
- [Income Stream Surfers: "Context7: The New MCP Server That Will CHANGE AI Coding"](https://www.youtube.com/watch?v=PS-2Azb-C3M)
|
609 |
-
- [AICodeKing: "Context7 + Cline & RooCode: This MCP Server Makes CLINE 100X MORE EFFECTIVE!"](https://www.youtube.com/watch?v=qZfENAPMnyo)
|
610 |
-
- [Sean Kochel: "5 MCP Servers For Vibe Coding Glory (Just Plug-In & Go)"](https://www.youtube.com/watch?v=LqTQi8qexJM)
|
611 |
-
|
612 |
-
## β Star History
|
613 |
-
|
614 |
-
[](https://www.star-history.com/#upstash/context7&Date)
|
615 |
-
|
616 |
-
## π License
|
617 |
-
|
618 |
-
MIT
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.py
CHANGED
@@ -15,8 +15,8 @@ from utils import copy_search_results, create_documentation_string, choice_promp
|
|
15 |
|
16 |
_ = dotenv.load_dotenv()
|
17 |
|
18 |
-
subprocess.run(["python3", "make_docs.py"])
|
19 |
-
subprocess.run(["python3", "make_rag_db.py"])
|
20 |
|
21 |
client = MilvusClient("milvus.db")
|
22 |
embedding_fn = model.dense.OpenAIEmbeddingFunction(
|
@@ -37,8 +37,6 @@ def list_huggingface_resources_names() -> list[str]:
|
|
37 |
with open("repos_config.json", "r") as f:
|
38 |
repos = json.load(f)
|
39 |
|
40 |
-
print([repo["title"] for repo in repos])
|
41 |
-
|
42 |
return [repo["title"] for repo in repos]
|
43 |
|
44 |
|
@@ -114,10 +112,12 @@ def get_huggingface_documentation(topic: str, resource_names: list[str] = []) ->
|
|
114 |
text_format=Response,
|
115 |
)
|
116 |
|
117 |
-
|
|
|
|
|
118 |
|
119 |
# Create the documentation string using the file IDs and template
|
120 |
-
documentation_string = create_documentation_string(
|
121 |
|
122 |
# Clean up temporary folder
|
123 |
shutil.rmtree(temp_folder, ignore_errors=True)
|
@@ -135,23 +135,29 @@ def load_readme() -> str:
|
|
135 |
content = f.read()
|
136 |
|
137 |
# Skip YAML frontmatter if it exists
|
|
|
|
|
|
|
138 |
if content.startswith("---"):
|
139 |
-
# Find the second '---' line
|
140 |
-
lines = content.split("\n")
|
141 |
-
start_index = 0
|
142 |
dash_count = 0
|
143 |
-
|
144 |
for i, line in enumerate(lines):
|
145 |
if line.strip() == "---":
|
146 |
dash_count += 1
|
147 |
if dash_count == 2:
|
148 |
start_index = i + 1
|
149 |
break
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
|
|
|
|
|
|
|
|
|
|
154 |
return content
|
|
|
155 |
except FileNotFoundError:
|
156 |
return "README.md not found"
|
157 |
|
|
|
15 |
|
16 |
_ = dotenv.load_dotenv()
|
17 |
|
18 |
+
subprocess.run(["python3", "scripts/make_docs.py"])
|
19 |
+
subprocess.run(["python3", "scripts/make_rag_db.py"])
|
20 |
|
21 |
client = MilvusClient("milvus.db")
|
22 |
embedding_fn = model.dense.OpenAIEmbeddingFunction(
|
|
|
37 |
with open("repos_config.json", "r") as f:
|
38 |
repos = json.load(f)
|
39 |
|
|
|
|
|
40 |
return [repo["title"] for repo in repos]
|
41 |
|
42 |
|
|
|
112 |
text_format=Response,
|
113 |
)
|
114 |
|
115 |
+
file_id = response.output_parsed.file_id
|
116 |
+
|
117 |
+
print(f"{topic} -> {file_id}")
|
118 |
|
119 |
# Create the documentation string using the file IDs and template
|
120 |
+
documentation_string = create_documentation_string([file_id], temp_folder)
|
121 |
|
122 |
# Clean up temporary folder
|
123 |
shutil.rmtree(temp_folder, ignore_errors=True)
|
|
|
135 |
content = f.read()
|
136 |
|
137 |
# Skip YAML frontmatter if it exists
|
138 |
+
lines = content.split("\n")
|
139 |
+
start_index = 0
|
140 |
+
|
141 |
if content.startswith("---"):
|
142 |
+
# Find the second '---' line to skip frontmatter
|
|
|
|
|
143 |
dash_count = 0
|
|
|
144 |
for i, line in enumerate(lines):
|
145 |
if line.strip() == "---":
|
146 |
dash_count += 1
|
147 |
if dash_count == 2:
|
148 |
start_index = i + 1
|
149 |
break
|
150 |
+
|
151 |
+
# Find the line that starts with "### The Problem: Your LLM is stuck in the past"
|
152 |
+
for i in range(start_index, len(lines)):
|
153 |
+
if lines[i].startswith("### The Problem: Your LLM is stuck in the past"):
|
154 |
+
start_index = i
|
155 |
+
break
|
156 |
+
|
157 |
+
# Join the lines from the target starting point
|
158 |
+
content = "\n".join(lines[start_index:])
|
159 |
return content
|
160 |
+
|
161 |
except FileNotFoundError:
|
162 |
return "README.md not found"
|
163 |
|
schemas.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
from pydantic import BaseModel
|
2 |
|
3 |
class Response(BaseModel):
|
4 |
-
|
|
|
1 |
from pydantic import BaseModel
|
2 |
|
3 |
class Response(BaseModel):
|
4 |
+
file_id: str
|
make_docs.py β scripts/make_docs.py
RENAMED
File without changes
|
make_rag_db.py β scripts/make_rag_db.py
RENAMED
File without changes
|
utils.py
CHANGED
@@ -18,17 +18,17 @@ choice_prompt = Template("""
|
|
18 |
|
19 |
The user has asked the following question: $question
|
20 |
|
21 |
-
The goal is get the user the
|
22 |
|
23 |
-
Here is the tree structure of the documentation. Your task is to return the numeric
|
24 |
-
associated with the
|
25 |
|
26 |
<tree>
|
27 |
$tree_structure
|
28 |
</tree>
|
29 |
|
30 |
-
Sample response:
|
31 |
-
Top
|
32 |
|
33 |
""".strip())
|
34 |
|
@@ -51,7 +51,7 @@ def create_documentation_string(file_ids, temp_folder):
|
|
51 |
# Find the corresponding file in the temp folder
|
52 |
docs_path = Path(temp_folder) / "docs"
|
53 |
for file_path in docs_path.rglob("*.md*"):
|
54 |
-
if file_id in str(file_path):
|
55 |
try:
|
56 |
with open(file_path, 'r', encoding='utf-8') as f:
|
57 |
content = f.read()
|
|
|
18 |
|
19 |
The user has asked the following question: $question
|
20 |
|
21 |
+
The goal is get the user the 1 most relevant documentation file to answer the question.
|
22 |
|
23 |
+
Here is the tree structure of the documentation. Your task is to return the numeric id \
|
24 |
+
associated with the most relevant .md and .mdx file.
|
25 |
|
26 |
<tree>
|
27 |
$tree_structure
|
28 |
</tree>
|
29 |
|
30 |
+
Sample response: "1.3.2"
|
31 |
+
Top 1 file id:
|
32 |
|
33 |
""".strip())
|
34 |
|
|
|
51 |
# Find the corresponding file in the temp folder
|
52 |
docs_path = Path(temp_folder) / "docs"
|
53 |
for file_path in docs_path.rglob("*.md*"):
|
54 |
+
if file_id + "." in str(file_path):
|
55 |
try:
|
56 |
with open(file_path, 'r', encoding='utf-8') as f:
|
57 |
content = f.read()
|