File size: 6,716 Bytes
77e1196
 
b35cb9c
77e1196
 
 
c155b65
77e1196
 
 
b35cb9c
77e1196
 
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
---
title: DocsNavigatorMCP
emoji: πŸš€
colorFrom: purple
colorTo: indigo
sdk: gradio
sdk_version: 6.0.2
app_file: app.py
pinned: false
license: mit
short_description: AI-powered documentation assistant with Claude!
---

# Docs Navigator MCP
A powerful documentation assistant that combines **Model Context Protocol (MCP)** with **Claude AI** to provide intelligent Q&A over your documentation files. Built with FastMCP and Gradio for an easy-to-use web interface.

## ✨ Features

- πŸ” **Smart Document Search**: Full-text search across your documentation files
- πŸ€– **AI-Powered Responses**: Uses Claude AI to provide intelligent answers based on your docs
- πŸ“ **Multi-Format Support**: Works with `.md`, `.txt`, `.rst`, and `.pdf` files
- 🌐 **Web Interface**: Clean Gradio-based chat interface
- ⚑ **MCP Integration**: Leverages Model Context Protocol for seamless tool integration
- πŸ”§ **Easy Setup**: Simple configuration and deployment
- πŸ“„ **PDF Support**: Extract and analyze text from PDF documents

## πŸ—οΈ Architecture

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Gradio UI     │───▢│   Client Agent   │───▢│   Claude AI     β”‚
β”‚  (Chat Interface)β”‚    β”‚  (MCP Client)    β”‚    β”‚   (Anthropic)   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                β”‚
                                β–Ό
                       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                       β”‚   MCP Server     β”‚
                       β”‚  (FastMCP)       β”‚
                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                β”‚
                                β–Ό
                       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                       β”‚   docs/ folder   β”‚
                       β”‚  (.md, .txt,     β”‚
                       β”‚   .rst files)    β”‚
                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

## πŸš€ Quick Start

### Prerequisites

- Python 3.10 or higher
- An Anthropic API key
- UV package manager (recommended) or pip

### 1. Clone and Setup

```bash
git clone <your-repo-url>
cd docs-navigator
```

### 2. Install Dependencies

Using UV (recommended):
```bash
uv sync
```

Or using pip:
```bash
pip install -r requirements.txt
```

### 3. Configure Environment

Create a `.env` file:
```bash
echo "ANTHROPIC_API_KEY=your_api_key_here" > .env
```

### 4. Add Your Documentation

Place your documentation files in the `docs/` directory:
```
docs/
β”œβ”€β”€ overview.md
β”œβ”€β”€ setup.md
β”œβ”€β”€ troubleshooting.md
└── your-other-docs.txt
```

### 5. Launch the Application

```bash
# Using UV
uv run app_gradio.py

# Or directly with Python
python app_gradio.py
```

The app will be available at `http://127.0.0.1:7860`

## πŸ“š Usage Examples

Once the app is running, you can ask questions like:

- "How do I set up the authentication?"
- "What are the troubleshooting steps for connection issues?"
- "Where can I find information about API endpoints?"
- "Summarize the main features mentioned in the docs"

The AI will search through your documentation and provide contextual answers with references to the source files.

## πŸ› οΈ Development

### Project Structure

```
docs-navigator/
β”œβ”€β”€ app_gradio.py          # Gradio web interface
β”œβ”€β”€ client_agent.py        # MCP client and Claude integration
β”œβ”€β”€ server_docs.py         # MCP server with doc tools
β”œβ”€β”€ docs/                  # Your documentation files
β”œβ”€β”€ tests/                 # Test scripts
β”‚   β”œβ”€β”€ test_mcp.py       # Test MCP server functionality
β”‚   β”œβ”€β”€ test_anthropic.py # Test Claude API connection
β”‚   └── test_complete.py  # End-to-end functionality test
β”œβ”€β”€ .env                   # Environment variables
β”œβ”€β”€ pyproject.toml         # Project configuration
└── requirements.txt       # Python dependencies
```

### Available MCP Tools

The server exposes these tools to the AI:

1. **`list_docs()`**: Get a list of all available documentation files
2. **`search_docs(query, max_results)`**: Search for specific content across all docs

### Testing

Run the test suite:

```bash
# Test MCP server functionality
python test_mcp.py

# Test Claude API connection
python test_anthropic.py

# Test complete end-to-end functionality
python test_complete.py
```

## πŸ”§ Configuration

### Environment Variables

| Variable | Description | Required |
|----------|-------------|----------|
| `ANTHROPIC_API_KEY` | Your Anthropic Claude API key | Yes |

### Supported File Formats

- **Markdown**: `.md`
- **Text**: `.txt`
- **reStructuredText**: `.rst`
- **PDF Documents**: `.pdf` (text extraction)

### Model Configuration

The app currently uses `claude-3-haiku-20240307`. To change the model, edit the model name in `client_agent.py`:

```python
model="claude-3-haiku-20240307"  # Change to your preferred model
```

## πŸ› Troubleshooting

### Common Issues

1. **"Model not found" error**: Your API key may not have access to the specified Claude model. The app will automatically test available models.

2. **MCP connection issues**: Ensure the `server_docs.py` script is executable and in the correct location.

3. **No documents found**: Make sure your documentation files are in the `docs/` folder with supported extensions.

4. **Gradio interface not loading**: Check that port 7860 is available or modify the port in `app_gradio.py`.

### Debug Mode

Enable verbose logging by modifying the logging level in the respective files.

## 🀝 Contributing

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

## πŸ“„ License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## πŸ™ Acknowledgments

- Built with [FastMCP](https://github.com/modelcontextprotocol/mcp) for Model Context Protocol integration
- Powered by [Anthropic Claude](https://www.anthropic.com/) for AI responses
- UI created with [Gradio](https://gradio.app/)
- Package management with [UV](https://docs.astral.sh/uv/)

---

For more detailed instructions, see the [Getting Started Guide](/guides/GETTING_STARTED.md).