Spaces:
Sleeping
Sleeping
File size: 8,557 Bytes
f639a6f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 |
# Getting Started with Docs Navigator MCP
Welcome! This guide will walk you through setting up and using the Docs Navigator MCP system step by step. By the end, you'll have a working AI assistant that can answer questions about your documentation.
## π Prerequisites
Before you begin, make sure you have:
- **Python 3.10+** installed on your system
- **An Anthropic API key** (sign up at [console.anthropic.com](https://console.anthropic.com))
- **Command line access** (Terminal on macOS/Linux, Command Prompt on Windows)
- **UV package manager** (recommended) or pip
### Installing UV (Recommended)
UV provides faster dependency management than pip:
**macOS/Linux:**
```bash
curl -LsSf https://astral.sh/uv/install.sh | sh
```
**Windows:**
```powershell
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
```
## π οΈ Step-by-Step Setup
### Step 1: Get the Code
Clone or download this repository:
```bash
git clone <your-repo-url>
cd docs-navigator
```
### Step 2: Set Up Python Environment
**Using UV (recommended):**
```bash
uv sync
```
**Using pip:**
```bash
# Create virtual environment
python -m venv .venv
# Activate it
# On Windows:
.venv\Scripts\activate
# On macOS/Linux:
source .venv/bin/activate
# Install dependencies
pip install -r requirements.txt
```
### Step 3: Configure Your API Key
Create a `.env` file in the project root:
```bash
# Create the file
touch .env # On macOS/Linux
# Or just create the file manually on Windows
```
Add your Anthropic API key to the `.env` file:
```
ANTHROPIC_API_KEY= your-actual-api-key-here
```
**Important**: Never commit your `.env` file to version control!
### Step 4: Verify Your API Key
Test that your API key works:
```bash
# Using UV
uv run test_anthropic.py
# Using Python directly
python test_anthropic.py
```
You should see output like:
```
Testing model: claude-3-haiku-20240307
β
claude-3-haiku-20240307: API working
Done testing models.
```
### Step 5: Add Your Documentation
Place your documentation files in the `docs/` folder. The system supports:
- **Markdown files** (`.md`)
- **Text files** (`.txt`)
- **reStructuredText files** (`.rst`)
Example structure:
```
docs/
βββ getting-started.md
βββ api-reference.md
βββ troubleshooting.txt
βββ faq.md
βββ installation.rst
```
**Sample content to try**: The project already includes sample docs you can test with:
- `overview.md`
- `setup.md`
- `troubleshooting.md`
- `prompting-guidelines.md`
- `auroraai_report.txt`
### Step 6: Test the MCP Server
Verify that the MCP server can read your docs:
```bash
# Using UV
uv run test_mcp.py
# Using Python directly
python test_mcp.py
```
Expected output:
```
Connecting to MCP server...
Listing available docs...
Available tools: ['list_docs', 'search_docs']
Available docs: [overview.md, setup.md, ...]
Search results for 'setup': [{"path": "setup.md", "snippet": "..."}]
β
MCP connection and tools working correctly!
```
### Step 7: Test End-to-End Functionality
Run a complete test:
```bash
# Using UV
uv run test_complete.py
# Using Python directly
python test_complete.py
```
This will ask the AI a question about your docs and show you the response.
### Step 8: Launch the Web Interface
Start the Gradio app:
```bash
# Using UV
uv run app_gradio.py
# Using Python directly
python app_gradio.py
```
You'll see:
```
* Running on local URL: http://127.0.0.1:7860
* To create a public link, set `share=True` in `launch()`.
```
Open http://127.0.0.1:7860 in your browser.
## π¬ Using the Chat Interface
Once the web interface opens, you can:
### Example Questions to Try:
1. **Discovery**: "What documentation do you have available?"
2. **Specific lookup**: "How do I set up authentication?"
3. **Troubleshooting**: "What should I do if I get connection errors?"
4. **Summarization**: "Give me an overview of the main features"
5. **Search**: "Find information about API endpoints"
### How It Works:
1. **You ask a question** in the chat interface
2. **The AI agent** receives your question
3. **MCP tools search** through your documentation files
4. **Claude AI analyzes** the search results
5. **You get an answer** with references to source files
## π Understanding the Components
### Files You'll Work With:
- **`app_gradio.py`**: The web interface (you probably won't need to modify this)
- **`client_agent.py`**: Connects to Claude AI and MCP server
- **`server_docs.py`**: Provides document search tools to the AI
- **`docs/`**: Your documentation files go here
- **`.env`**: Your API key and other secrets
### What Happens When You Ask a Question:
```
Your Question β Gradio β Client Agent β Claude AI
β
"I need to search docs"
β
MCP Server β docs/ folder
β
Search Results
β
Claude AI (generates answer)
β
Gradio β Your Answer
```
## βοΈ Customization Options
### Change the AI Model
Edit `client_agent.py` and modify the model name:
```python
model="claude-3-haiku-20240307" # Current model
model="claude-3-5-sonnet-20241022" # Higher quality (requires API access)
```
### Change the Port
Edit `app_gradio.py`:
```python
demo.launch() # Default port 7860
demo.launch(server_port=8080) # Custom port
```
### Add More File Types
Edit `server_docs.py`:
```python
exts = {".md", ".txt", ".rst"} # Current formats
exts = {".md", ".txt", ".rst", ".pdf", ".docx"} # Add more (requires additional code)
```
## π Troubleshooting Common Issues
### "Model not found" Error
**Problem**: Your API key doesn't have access to the specified Claude model.
**Solution**: The system will automatically test and find a working model. If this fails, check that your API key is valid.
### "No such file or directory" Error
**Problem**: Python path or virtual environment issues.
**Solution**:
```bash
# Make sure you're in the right directory
pwd # Should show /path/to/docs-navigator
# Make sure virtual environment is activated
which python # Should show .venv path
```
### No Documents Found
**Problem**: The system can't find your documentation files.
**Solution**:
- Check that files are in the `docs/` folder
- Verify file extensions (`.md`, `.txt`, `.rst`)
- Check file permissions
### Port Already in Use
**Problem**: Port 7860 is already taken.
**Solution**:
- Stop other applications using the port
- Or change the port in `app_gradio.py`
### Connection Refused
**Problem**: MCP server can't start.
**Solution**:
- Check that `server_docs.py` is executable
- Verify all dependencies are installed
- Check for Python syntax errors
## π Next Steps
Once you have the basic system working:
1. **Add more documentation**: Populate the `docs/` folder with your content
2. **Customize prompts**: Modify the system prompts in `client_agent.py` to better suit your use case
3. **Improve search**: Enhance the search functionality in `server_docs.py`
4. **Add more tools**: Create additional MCP tools for specific documentation tasks
5. **Deploy**: Set up the system on a server for team access
## π‘ Tips for Better Results
### Organizing Your Docs:
- Use clear, descriptive filenames
- Include section headings in markdown
- Keep related information in the same file
- Use consistent terminology
### Writing Good Questions:
- Be specific about what you need
- Reference topics from your documentation
- Ask for examples when appropriate
- Request sources for verification
### Optimizing Performance:
- Keep individual doc files reasonably sized
- Use markdown headers for better structure
- Remove irrelevant or outdated content
- Test questions regularly to improve prompts
## π Getting Help
If you run into issues:
1. **Check the test scripts**: Run `test_mcp.py` and `test_anthropic.py`
2. **Review the logs**: Look for error messages in the terminal
3. **Verify your setup**: Double-check API keys and file paths
4. **Start fresh**: Create a new virtual environment if needed
## π Success!
You should now have a working documentation assistant! The AI can search through your docs and provide intelligent answers to your questions.
Try asking: "What can you help me with?" to get started! |