Sponsored by Deepsite.site

Python MCP Server - Documentation Search

Created By
sawantudayan8 months ago
MCP (Minimal Command Protocol) server that allows users to search for documentation from popular libraries such as LangChain, LlamaIndex, and OpenAI using the Serper API. The server fetches search results and extracts the relevant documentation from the web using HTTP requests and BeautifulSoup.
Content

Python MCP Server - Documentation Search

mcp_server.jpg

This is a simple MCP (Minimal Command Protocol) server that allows users to search for documentation from popular libraries such as LangChain, LlamaIndex, and OpenAI using the Serper API. The server fetches search results and extracts the relevant documentation from the web using HTTP requests and BeautifulSoup.

Features

  • Supports searching documentation for LangChain, LlamaIndex, and OpenAI.
  • Uses Serper API to perform web searches.
  • Extracts and returns the text from the relevant documentation pages.
  • Can be used interactively through MCP protocol.

Requirements

  • Python 3.12 or higher.
  • Serper API Key for performing web searches.
  • MCP library for the server and tool execution.
  • BeautifulSoup4 and httpx for HTTP requests and HTML parsing.

Installation

Step 1: Install Python Dependencies

To set up the project, clone this repository and install the required dependencies.

git clone <repository-url>
cd <repository-directory>
pip install -r requirements.txt

Or, if you're not using a requirements.txt file:

pip install httpx beautifulsoup4 mcp python-dotenv

Step 2: Set Up Environment Variables

Create a .env file in the root directory of the project with your Serper API Key.

SERPER_API_KEY=your-serper-api-key-here

Make sure the .env file is loaded using the dotenv package.

Step 3: Run the Server

Once the environment is set up, run the server using the following command:

uv run main.py

The server will start and wait for input.

Usage

Once the server is running, you can use it to query the latest documentation for specific libraries. Here’s an example of how to query the tool:

Example Query

Start your server with uv run main.py.

In another terminal or from within an interactive MCP client, invoke the get_docs tool to search for documentation:

 get_docs("Chroma DB", "langchain")

This will search for "Chroma DB" in the LangChain documentation and return the relevant content.

Available Libraries

  • LangChain: Documentation at langchain.com
  • LlamaIndex: Documentation at llamaindex.ai
  • OpenAI: Documentation at platform.openai.com

Code Overview

main.py

  • FastMCP: Initializes the MCP server.
  • Tools: The server has two tools:
  • dummy_tool: A simple tool that confirms the server is up and running.
  • get_docs: Fetches the latest documentation for a given query and library (LangChain, LlamaIndex, OpenAI).
  • search_web(): Handles searching using the Serper API.
  • fetch_url(): Fetches a URL and extracts the text content using BeautifulSoup.

dotenv and logging

  • Loads the Serper API Key from the .env file.
  • Provides debug-level logging for better visibility into server actions and potential issues.`````

Troubleshooting

  • Missing API Key: Make sure the Serper API Key is set correctly in the .env file. You’ll get an error if it's missing.
  • Timeout Issues: If a search or URL fetch times out, try increasing the timeout values or checking the network connectivity.
  • Package Installation Issues: Ensure all dependencies are installed and the correct Python environment is activated.

Contributor

Udayan Sawant

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
Serper MCP ServerA Serper MCP Server
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
Tavily Mcp
Playwright McpPlaywright MCP server
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
DeepChatYour AI Partner on Desktop
WindsurfThe new purpose-built IDE to harness magic
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Amap Maps高德地图官方 MCP Server
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
ChatWiseThe second fastest AI chatbot™
CursorThe AI Code Editor