Trafilatura MCP Server
Enables web scraping and content extraction from URLs using the Trafilatura library. Extracts main text content and metadata (title, author, date) from web pages with configurable options for comments and tables.
README
Trafilatura MCP Server
This repository contains a Model Context Protocol (MCP) server that provides a tool-based interface to the Trafilatura library, a powerful tool for web scraping. It is designed for use with MCP-compatible clients, allowing developers and models to extract main content and metadata from web pages programmatically.
Features
- Web Scraping: Utilizes Trafilatura to extract the main text content from a given URL.
- Metadata Extraction: Retrieves metadata such as title, author, date, and more.
- Configurable Extraction: Options to include or exclude comments and tables from the output.
- Simple Tool: Exposes a single, easy-to-use
fetch_and_extracttool. - Asynchronous: Built with an asynchronous architecture for efficient I/O operations.
- MCP Standard: Communicates over standard I/O, making it compatible with various MCP clients.
Prerequisites
Before running the server, you need to have Python 3.12+ and uv installed. You will also need Node.js and npx to run the MCP Inspector tool for testing.
Installation
-
Clone the repository.
git clone <repository-url> cd trafilatura_mcp -
Create a virtual environment and install the required dependencies:
# Create a virtual environment uv venv # Activate the virtual environment source .venv/bin/activate # Install the dependencies uv sync
Running and Testing the Server
The MCP server is a command-line application that communicates over standard I/O. To use it, a client (like an IDE, a coding agent, or an inspector tool) must launch the server process.
Running for Diagnostics
You can run the script directly from your terminal to see if it starts without errors. This is a quick way to validate your Python environment and the script's basic syntax.
python3 trafilatura_mcp.py
The server will start and wait for input, but you won't be able to interact with it directly from your terminal.
Testing with MCP Inspector
The recommended way to test the server interactively is with MCP Inspector. It provides an interactive shell for sending requests to your server.
-
Launch the Inspector: You can run the inspector without a permanent installation using
npx. The inspector will launch your MCP server script for you. From your project directory, run:npx @modelcontextprotocol/inspector uv run -- python3 trafilatura_mcp.py -
Interact with the Server: Once the inspector starts, you can connect to the server and use commands like
list_toolsandcall_tool.Example session:
# List the available tool > list_tools # Call the 'fetch_and_extract' tool with a URL > call_tool fetch_and_extract '''{"url": "https://www.theguardian.com/us-news/2025/sep/28/mass-shootings-north-carolina-texas-new-orleans"}'''
Configuration
This server does not require any external API keys or configuration files.
Usage with an MCP Client (VS Code Example)
You can connect to this server from any standard MCP client. Here’s how to do it in a VS Code environment that supports MCP:
-
Configure Your MCP Client: In your IDE's MCP client settings (e.g., in
mcp.jsonfor VS Code), configure a new MCP server that points to the script.Example
mcp.jsonentry:{ "servers": { "trafilatura_scraper": { "command": "uv", "args": [ "run", "python3", "trafilatura_mcp.py" ], "cwd": "/path/to/your/project/trafilatura_mcp" } } }Note: Replace
/path/to/your/project/trafilatura_mcpwith the absolute path to the project directory. -
Use the Tool: Once connected, you can use the exposed tool in your chat or agent interactions. For example, to extract content from a news article, you could send the following structured tool call:
{ "tool": "fetch_and_extract", "arguments": { "url": "https://apnews.com/article/elon-musk-x-twitter-hate-speech-antisemitism-0d35c5a69fd5c6183b729f7f3c87064a", "include_comments": false, "include_tables": true } }The server will fetch the URL, extract the main content and metadata, and return it as a JSON object.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。