MCP Document Fetcher
March 16, 2025 ยท View on GitHub
A Multi-Context Protocol (MCP) server that fetches, caches, and analyzes webpage content. This tool creates hierarchical representations of websites and enables semantic querying of their content.
Features
- ๐ Webpage content fetching and caching
- ๐ Hierarchical site structure generation
- ๐ Semantic content querying using Gemini AI
- ๐ฒ Tree-based visualization of website structure
- ๐ Efficient caching system for repeated queries
Installation
- Clone the repository:
git clone <your-repo-url>
cd mcps
- Create and activate a virtual environment using
uv:
uv venv
source .venv/Scripts/activate (just `.venv/Scripts/activate on windows)
- Install dependencies:
uv sync
- Set up environment variables:
export GEMINI_API_KEY="your-api-key" # For Windows, use 'set' instead of 'export'
Usage
- Copy the contents of ./src/doc_fetcher to your local folder containing mcp servers Add the MCP server to your mcp.json (either cursor/windsurf)
{
"mcpServers": {
"doc-fetcher-mcp": {
"command": "uv",
"args": [
"--directory",
"<path_to_mcp_server_folder>",
"run",
"server.py"
]
}
}
}
- Use the available MCP tools:
- Test it by chatting with your IDE. E.g: I'd like to build a simple chatbot using langgraph and use memory. Use the docs site: @https://langchain-ai.github.io/langgraph/ to understand the framework (The URL MUST be provided to the LLM. It won't do any guess work for you and this is an intentional choice)
Project Structure
src/
โโโ mcp_server/
โ โโโ server.py # Main MCP server implementation
โ โโโ cache/ # Cached webpage content (gitignored)
โโโ link_fetcher/ # Link extraction and tree building
โโโ extract/ # HTML content extraction
Cache Management
The server maintains a cache directory (src/mcp_server/cache/) that stores:
- Webpage content
- Site structure trees (JSON and Markdown)
- Extracted links
- Page content in JSON format
The cache is gitignored to prevent committing large amounts of data.
Contributing
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
License
[MIT]