Docs MCP

Docs MCP

An MCP server that searches official documentation for popular libraries, scrapes pages, and returns clean, LLM-ready text.

Category
访问服务器

README

Docs MCP — AI-Powered Documentation Search

An MCP (Model Context Protocol) server that searches official documentation for popular libraries, scrapes the relevant pages, and returns clean, LLM-ready text. Connect it to Claude Desktop, Cursor, or any MCP-compatible client so your AI assistant can look up up-to-date docs on demand.

What it does

The project follows a three-step pipeline:

  1. Search the web — Uses the Serper API to run a Google search scoped to a library's official documentation site.
  2. Fetch and clean pages — Downloads the top result URLs and strips HTML noise using Groq LLM (openai/gpt-oss-20b).
  3. Return structured context — Sends back cleaned text with SOURCE: links so the calling agent can cite where the information came from.

The MCP server exposes a single tool, get_docs, that AI clients can call when they need documentation context.

Supported libraries

Library key Documentation site
langchain python.langchain.com/docs
lama-index docs.llamaindex.ai/en/stable
openai platform.openai.com/docs
uv docs.astral.sh/uv

Prerequisites

Project structure

web-scraping/
├── mcp_server.py   # MCP server (FastMCP) — exposes the get_docs tool
├── client.py       # Example MCP client that calls get_docs and summarizes results
├── utils.py        # LLM helpers (Groq) and HTML cleaning (trafilatura)
├── test.py         # Quick sanity check for the Groq API connection
├── pyproject.toml  # Project dependencies (managed by uv)
└── .env            # API keys (create this locally — do not commit)

Setup

1. Clone and enter the project

cd /path/to/web-scraping

2. Install dependencies with uv

uv sync

This creates a .venv virtual environment and installs all packages listed in pyproject.toml.

3. Create a .env file

Create a .env file in the project root with your API keys:

SERPER_API_KEY=your_serper_api_key_here
GROQ_API_KEY=your_groq_api_key_here

Both keys are required. The server loads them via python-dotenv.

4. Verify your Groq connection (optional)

uv run test.py

You should see API Key Found: True followed by a short LLM response.

Usage

Run the MCP server directly

uv run mcp_server.py

The server communicates over stdio (standard input/output), which is how MCP clients connect to it. Running it standalone will appear to hang — that is expected; it is waiting for an MCP client.

Run the example client

From the project root:

uv run client.py

This starts the MCP server as a subprocess, calls get_docs with a sample query ("How to publish a package with uv on gitlab"), and prints a human-readable answer generated by Groq.

Connect to Claude Desktop

Add the server to your Claude Desktop MCP config.

macOS config path:

~/Library/Application Support/Claude/claude_desktop_config.json

Recommended configuration — use --directory so the server works even when Claude Desktop does not honor the cwd field:

{
  "mcpServers": {
    "docs-mcp": {
      "command": "/opt/homebrew/bin/uv",
      "args": [
        "run",
        "--directory",
        "/Users/YOUR_USERNAME/Desktop/web-scraping",
        "mcp_server.py"
      ],
      "env": {
        "SERPER_API_KEY": "your_serper_api_key_here",
        "GROQ_API_KEY": "your_groq_api_key_here"
      }
    }
  }
}

Replace /Users/YOUR_USERNAME/Desktop/web-scraping with the absolute path to this project, and update the uv path if yours differs (which uv).

Alternative — run the venv Python directly (most reliable if cwd is ignored):

{
  "mcpServers": {
    "docs-mcp": {
      "command": "/Users/YOUR_USERNAME/Desktop/web-scraping/.venv/bin/python",
      "args": [
        "/Users/YOUR_USERNAME/Desktop/web-scraping/mcp_server.py"
      ],
      "env": {
        "SERPER_API_KEY": "your_serper_api_key_here",
        "GROQ_API_KEY": "your_groq_api_key_here"
      }
    }
  }
}

After saving the config, fully quit Claude Desktop (Cmd+Q) and reopen it. The docs-mcp server should appear as connected.

MCP tool reference

get_docs

Search official documentation for a library and return cleaned text.

Parameters:

Parameter Type Description
query string What to search for (e.g. "Publish a package")
library string One of: langchain, lama-index, openai, uv

Example call (from an MCP client):

{
  "query": "How to use async with LangChain",
  "library": "langchain"
}

Returns: Cleaned documentation text with SOURCE: <url> headers for each fetched page.

How it works internally

User / AI client
      │
      ▼
  get_docs(query, library)
      │
      ├─► Serper API  ──► Google search (site-scoped to official docs)
      │
      ├─► httpx       ──► Fetch top result URLs
      │
      └─► Groq LLM    ──► Clean HTML from each page (4000-char chunks)
                │
                ▼
         Structured text + source links
  • mcp_server.py — Defines the FastMCP server and the get_docs tool.
  • utils.py — get_response_from_llm() calls Groq; clean_html_to_txt() uses trafilatura (available as a fallback utility).
  • client.py — Demonstrates programmatic MCP usage with the official Python MCP SDK.

Troubleshooting

Failed to spawn: mcp_server.py — No such file or directory

Claude Desktop launched uv from the wrong working directory. Fix by using --directory with an absolute project path (see config above), or point directly at .venv/bin/python.

GROQ_API_KEY not found

Ensure .env exists in the project root with a valid key, or pass the key via the env block in your MCP config.

Server connects then immediately disconnects

Check Claude Desktop MCP logs for Python import errors. Run uv sync to reinstall dependencies, then test locally with uv run mcp_server.py.

Library X not supported by this tool

The library parameter must exactly match one of the supported keys: langchain, lama-index, openai, or uv.

Dependencies

Managed in pyproject.toml:

License

MIT License

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选