Spaces:
Sleeping
A newer version of the Gradio SDK is available:
6.1.0
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)
- 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:
curl -LsSf https://astral.sh/uv/install.sh | sh
Windows:
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:
git clone <your-repo-url>
cd docs-navigator
Step 2: Set Up Python Environment
Using UV (recommended):
uv sync
Using pip:
# 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:
# 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:
# 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.mdsetup.mdtroubleshooting.mdprompting-guidelines.mdauroraai_report.txt
Step 6: Test the MCP Server
Verify that the MCP server can read your docs:
# 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:
# 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:
# 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:
Discovery: "What documentation do you have available?"
Specific lookup: "How do I set up authentication?"
Troubleshooting: "What should I do if I get connection errors?"
Summarization: "Give me an overview of the main features"
Search: "Find information about API endpoints"
How It Works:
- You ask a question in the chat interface
- The AI agent receives your question
- MCP tools search through your documentation files
- Claude AI analyzes the search results
- 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 serverserver_docs.py: Provides document search tools to the AIdocs/: 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:
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:
demo.launch() # Default port 7860
demo.launch(server_port=8080) # Custom port
Add More File Types
Edit server_docs.py:
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:
# 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.pyis executable - Verify all dependencies are installed
- Check for Python syntax errors
π Next Steps
Once you have the basic system working:
Add more documentation: Populate the
docs/folder with your contentCustomize prompts: Modify the system prompts in
client_agent.pyto better suit your use caseImprove search: Enhance the search functionality in
server_docs.pyAdd more tools: Create additional MCP tools for specific documentation tasks
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:
- Check the test scripts: Run
test_mcp.pyandtest_anthropic.py - Review the logs: Look for error messages in the terminal
- Verify your setup: Double-check API keys and file paths
- 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!