VnExpress Tool

VnExpress Tool

Enables fetching latest news from VnExpress.net, including categories, search, and article content retrieval.

Category
Visit Server

README

VnExpress Tool - Công cụ Tin tức MCP

Công cụ MCP để lấy tin tức mới nhất từ VnExpress.net và các chức năng tìm kiếm tin tức.

Tổng quan

MCP (Model Context Protocol) là một giao thức cho phép máy chủ cung cấp các công cụ có thể được gọi bởi các mô hình ngôn ngữ. Các công cụ cho phép mô hình tương tác với các hệ thống bên ngoài, chẳng hạn như truy vấn cơ sở dữ liệu, gọi API hoặc thực hiện các phép tính. Mỗi công cụ được xác định duy nhất bởi một tên và bao gồm siêu dữ liệu mô tả lược đồ của nó.

  • 🔌 Giao tiếp hai chiều giữa AI và các công cụ bên ngoài
  • 🔄 Tự động kết nối lại với thời gian chờ tăng dần
  • 📊 Truyền dữ liệu thời gian thực
  • 🛠️ Giao diện tạo công cụ dễ sử dụng
  • 🔒 Giao tiếp WebSocket an toàn
  • ⚙️ Hỗ trợ nhiều loại truyền tải (stdio/sse/http)

Tính năng

  • 📰 Tin tức mới nhất: Lấy tin nổi bật từ trang chủ VnExpress
  • 🏷️ Phân loại tin tức: Hỗ trợ nhiều chuyên mục
  • 🔍 Tìm kiếm: Tìm kiếm tin tức theo từ khóa
  • 📖 Nội dung chi tiết: Lấy toàn bộ nội dung bài viết
  • ⚡ Real-time: Cập nhật tin tức theo thời gian thực

Yêu cầu cài đặt

Cài Python phiên bản mới nhất

1. Cài đặt các phụ thuộc:

pip install -r requirements.txt
pip install requests beautifulsoup4 lxml

2. Thiết lập các biến môi trường:

export MCP_ENDPOINT=<your_mcp_endpoint>
# Windows (PowerShell): $env:MCP_ENDPOINT = "<ws_endpoint>"
pip install requests beautifulsoup4 lxml

3. Cách chạy

Chạy riêng lẻ

python mcp_pipe.py VnExpress.py

Chạy cùng các tool khác

Cập nhật file mcp_config.json:

{
  "mcpServers": {
    "calculator": {
      "command": "python",
      "args": ["calculator.py"],
      "type": "stdio"
    },
    "VnExpress": {
      "command": "python",
      "args": ["VnExpress.py"],
      "type": "stdio"
    }
  }
}

Yêu cầu tệp cấu hình mcp_config.json với các định nghĩa máy chủ (hỗ trợ các loại truyền tải stdio/sse/http)

Cấu trúc dự án

  • mcp_pipe.py: Ống giao tiếp chính xử lý các kết nối WebSocket và quản lý quy trình
  • VnExpress.py: Triển khai Công cụ MCP để lấy tin tức mới nhất từ VnExpress.net và các chức năng tìm kiếm tin tức
  • requirements.txt: Các phụ thuộc của dự án

Máy chủ điều khiển bằng cấu hình

Chỉnh sửa tệp mcp_config.json để cấu hình danh sách máy chủ (cũng có thể đặt biến môi trường MCP_CONFIG trỏ đến tệp cấu hình khác).

Hướng dẫn cấu hình:

  • Không có tham số sẽ khởi động tất cả các máy chủ đã cấu hình (tự động bỏ qua các mục disabled: true)
  • Có tham số sẽ chạy một tệp kịch bản cục bộ duy nhất
  • type=stdio khởi động trực tiếp; type=sse/http thông qua proxy python -m mcp_proxy

Các công cụ có sẵn

1. get_vnexpress_news - Lấy tin tức theo chuyên mục

Cú pháp:

get_vnexpress_news(category: str = "home", limit: int = 10)

Chuyên mục hỗ trợ:

  • home: Trang chủ (tin nổi bật)
  • thoi-su: Thời sự
  • goc-nhin: Góc nhìn
  • the-gioi: Thế giới
  • kinh-doanh: Kinh doanh
  • bat-dong-san: Bất động sản
  • khoa-hoc: Khoa học
  • giai-tri: Giải trí
  • the-thao: Thể thao
  • phap-luat: Pháp luật
  • giao-duc: Giáo dục
  • suc-khoe: Sức khỏe
  • doi-song: Đời sống
  • du-lich: Du lịch
  • so-hoa: Số hóa
  • xe: Xe

Ví dụ sử dụng:

get_vnexpress_news("home", 5)          # 5 tin nổi bật
get_vnexpress_news("thoi-su", 10)      # 10 tin thời sự
get_vnexpress_news("the-thao", 8)      # 8 tin thể thao

2. get_article_content - Lấy nội dung chi tiết bài viết

Cú pháp:

get_article_content(url: str)

Ví dụ:

get_article_content("https://vnexpress.net/title-123456.html")

3. search_vnexpress_news - Tìm kiếm tin tức

Cú pháp:

search_vnexpress_news(keyword: str, limit: int = 5)

Ví dụ:

search_vnexpress_news("covid", 10)
search_vnexpress_news("bóng đá", 5)
search_vnexpress_news("kinh tế", 8)

Ví dụ kết quả

Tin tức mới nhất

{
  "success": true,
  "category": "thoi-su",
  "total_articles": 10,
  "articles": [
    {
      "title": "Thủ tướng: 'Chính phủ quyết tâm thực hiện mục tiêu tăng trưởng 6,5-7%'",
      "url": "https://vnexpress.net/thu-tuong-chinh-phu-quyet-tam-thuc-hien-muc-tieu-tang-truong-6-5-7-4567890.html",
      "description": "Thủ tướng Phạm Minh Chính cho biết Chính phủ sẽ tập trung nguồn lực...",
      "time": "2 giờ trước",
      "category": "thoi-su"
    }
  ],
  "timestamp": "2024-11-03 15:30:00",
  "source": "VnExpress.net"
}

Nội dung bài viết

{
  "success": true,
  "title": "Tiêu đề bài viết",
  "description": "Mô tả ngắn gọn...",
  "content": "Nội dung đầy đủ của bài viết...",
  "author": "Tên tác giả",
  "publish_time": "Thứ 7, 3/11/2024, 15:30",
  "url": "https://vnexpress.net/...",
  "timestamp": "2024-11-03 15:30:00"
}

Ví dụ tích hợp với AI

AI: "Tin tức mới nhất hôm nay?"
→ get_vnexpress_news("home", 5)

AI: "Có tin gì về bóng đá không?"
→ search_vnexpress_news("bóng đá", 5)

AI: "Tin tức kinh tế mới nhất?"
→ get_vnexpress_news("kinh-doanh", 8)

AI: "Đọc chi tiết bài này giúp tôi: [URL]"
→ get_article_content(url)

Xử lý lỗi

Lỗi kết nối

{
  "success": false,
  "error": "Network error: Connection timeout"
}

Lỗi parsing

{
  "success": false, 
  "error": "Unexpected error: No articles found"
}

Lưu ý quan trọng

1. Tuân thủ robots.txt

Tool được thiết kế để lấy thông tin công khai và không vi phạm robots.txt của VnExpress.

2. Rate Limiting

Tránh gọi quá nhiều request trong thời gian ngắn để không bị chặn IP.

3. Cấu trúc website có thể thay đổi

VnExpress có thể thay đổi cấu trúc HTML, tool sẽ cần cập nhật selector tương ứng.

4. Mã hóa UTF-8

Tool đã xử lý encoding UTF-8 cho tiếng Việt trên Windows.

Troubleshooting

1. Module không tìm thấy

pip install beautifulsoup4 lxml requests

2. Không tìm thấy bài viết

  • Kiểm tra kết nối internet
  • VnExpress có thể đã thay đổi cấu trúc
  • Thử chuyên mục khác

3. Encoding lỗi

Code đã xử lý UTF-8 tự động.

4. Blocked IP

Nếu bị chặn, đợi một thời gian hoặc thay đổi User-Agent.

Phát triển thêm

Có thể mở rộng:

  • Hỗ trợ nhiều trang tin tức khác
  • Lưu cache tin tức
  • Phân tích sentiment
  • Tóm tắt tin tức tự động
  • Export PDF/Word

Khuyến nghị sử dụng

  1. Sử dụng có trách nhiệm: Không spam request
  2. Tôn trọng bản quyền: Chỉ lấy thông tin cần thiết
  3. Cập nhật thường xuyên: Check code khi website thay đổi
  4. Backup data: Lưu tin tức quan trọng

License

MIT License - Sử dụng cho mục đích học tập và nghiên cứu.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured