MCP Server for Up-to-Date Library Documentation
Provides Large Language Models with real-time access to the latest documentation for Python libraries like Langchain, LlamaIndex, and OpenAI, enabling accurate and up-to-date code suggestions.
README
MCP Server for Up-to-Date Library Documentation
<!-- Update license if different -->
This project implements a Model Context Protocol (MCP) server in Python. Its primary function is to provide Large Language Models (LLMs) like Anthropic's Claude with real-time access to the latest documentation for specified Python libraries (Langchain, LlamaIndex, OpenAI) before they generate code suggestions.
Problem Solved
LLMs often possess knowledge based on their training data cutoffs. This can lead to outdated code suggestions, especially for rapidly evolving libraries common in the AI/ML space. This MCP server addresses this challenge by acting as a tool that allows the LLM to dynamically fetch and incorporate the most current documentation snippets into its context before responding to coding queries.
Features
- MCP Standard: Implements the Model Context Protocol for seamless integration with compatible clients (e.g., Claude Desktop, Claude Code).
get_docsTool: Exposes a specific tool that searches official documentation sites.- Targeted Search: Uses the Serper API to perform site-specific Google searches, ensuring results come directly from the official docs for:
- Langchain (
python.langchain.com/docs) - LlamaIndex (
docs.llamaindex.ai/en/stable) - OpenAI (
platform.openai.com/docs)
- Langchain (
- Content Fetching: Retrieves and parses the text content from the top search results using
httpxandBeautifulSoup. - Modern Tooling: Built with Python 3.11+,
asyncio,FastMCP, and managed using theuvpackage manager.
Architecture Overview
This server functions as a specialized "toolbox" within the MCP ecosystem:
- An MCP Host (e.g., Claude Desktop, IDE with Claude Code) initiates a request requiring coding assistance for a supported library.
- The MCP Client within the Host connects to this running MCP Server.
- The LLM, recognizing the need for potentially up-to-date information, decides to use the
get_docstool provided by this server. - The Client invokes the
get_docstool on this server, passing the user's query and the target library. - This MCP Server constructs a site-specific search query (e.g.,
site:python.langchain.com/docs <user_query>). - It queries the Serper API to get the top documentation page links.
- It fetches the content of these pages using
httpxand extracts the relevant text usingBeautifulSoup. - The extracted text (context) is returned to the MCP Client/Host.
- The LLM uses this fresh context alongside the original prompt to generate a more accurate and up-to-date response/code suggestion.
Prerequisites
- Python 3.11+
uvPackage Manager: Install from Astral.sh.- Serper API Key: Obtain a free or paid key from serper.dev.
- Node.js/npx: Required only if you plan to use the MCP Inspector for debugging.
Installation & Setup
-
Clone the Repository (if applicable):
git clone <your-repository-url> cd <your-repository-name> -
Initialize Project (if starting fresh):
# If you haven't cloned a repo with pyproject.toml uv init mcp-server cd mcp-server -
Create and Activate Virtual Environment:
uv venv # Activate (Linux/macOS): source .venv/bin/activate # Activate (Windows PowerShell): . \.venv\Scripts\Activate.ps1 # Activate (Windows Cmd): .\.venv\Scripts\activate.bat -
Install Dependencies:
uv add "mcp[cli]" httpx python-dotenv bs4 # Or, if dependencies are listed in pyproject.toml: # uv sync
Configuration
-
Create a file named
.envin the root directory of the project. -
Add your Serper API key to this file:
SERPER_API_KEY=your_actual_serper_api_key_here(The
.gitignorefile is already configured to prevent committing this file)
Usage
-
Run the MCP Server: Make sure your virtual environment is activated.
uv run main.pyThe server will start and listen for connections via standard input/output (stdio), as configured in
main.py. -
Integrate with MCP Clients:
-
Claude Desktop:
- Go to Settings > Developer > Edit Configuration.
- Add an entry under
mcpServers. You'll need to provide the full path to youruvexecutable and specify the command arguments. - Example structure (adjust paths accordingly):
{ "mcpServers": [ { "name": "docs-helper", // Or any name you prefer "command": [ "/full/path/to/your/.venv/bin/python", // Or full path to uv binary "-m", // If using python -m uv ... "uv", "run", "main.py" ], "workingDirectory": "/full/path/to/your/mcp-server/project" } ] } - Restart Claude Desktop. A tool hammer icon should appear.
-
Claude Code (CLI):
- Use the
claude mcp addcommand interactively or with flags. - Example interactive session prompts:
- Server Name:
documentation-fetcher(or your choice) - Project Type:
local - Command: Specify the full path to
uvand arguments, similar to Claude Desktop (e.g.,/full/path/to/uv run main.pywithin the project directory). - Working Directory:
/full/path/to/your/mcp-server/project
- Server Name:
- Use
claude mcp listto verify. - Run
claude- the tool should be listed.
- Use the
-
Refer to the official Anthropic MCP documentation for the most up-to-date client configuration details.
-
Development & Debugging
The MCP Inspector is a valuable tool for testing your server's capabilities without needing a full client integration.
- Ensure Node.js and npx are installed.
- Run the inspector, pointing it to your server's run command:
# Ensure your .venv is activated first npx @model-context-protocol/inspector "uv run main.py" - Open your web browser to
http://localhost:5173. - Connect to the server via the Inspector interface.
- Navigate to the "Tools" section, select
get_docs, provide test values forqueryandlibrary, and click "Run Tool" to see the output.
License
This project is licensed under the MIT License - see the LICENSE file for details. (You'll need to add a LICENSE file with the MIT license text if you choose this)
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。