Skip to main content

MCP server for HKEXnews Hong Kong announcement download, parsing and search

Project description

AgentLadle MCP HKEXnews

English | ไธญๆ–‡

๐Ÿ‡จ๐Ÿ‡ณ China A-Share Annual Reports โ€” Cloud-hosted MCP for Shanghai & Shenzhen listed companies. Read more | Get API Key

A MCP (Model Context Protocol) server that provides tools for discovering, downloading, parsing, and searching Hong Kong listed company announcements from HKEXnews.

It enables AI assistants (Claude, Cursor, etc.) to access HKEXnews announcement data through 6 structured tools โ€” from discovering available announcements to keyword-searching within their pages.

Scope (v0.1): Announcements and disclosures except full periodic report PDFs (Annual / Interim / Quarterly Report and ESG Report under t1=40000). Performance announcements (Final / Interim / Quarterly Results) are included.

Features

  • 6 MCP tools for HKEXnews announcement data: state-driven retrieval (search directly, fallback to download/parse only when needed)
  • PDF document parsing using PyMuPDF โ€” physical page extraction into page-split JSON
  • Local keyword search with TF + position-boost scoring, zero external search dependencies
  • Idempotent โ€” already-downloaded/parsed files are automatically skipped
  • Zero-config install โ€” one line to add to your MCP client, no clone or manual setup needed
  • Pure Python, cross-platform (Windows / macOS / Linux)

Prerequisites

Note: After installing uv, restart your terminal and MCP client (e.g. Cherry Studio) to ensure the uv command is recognized.

Quick Start

Add to your MCP client configuration (Claude Desktop, Cursor, etc.):

{
  "mcpServers": {
    "mcp-hkexnews": {
      "command": "uvx",
      "args": ["agentladle-mcp-hkexnews"]
    }
  }
}

That's it. uvx will automatically download the package and its dependencies from PyPI โ€” no clone, no manual install, no path configuration.

Alternative: pip install

If you prefer managing the environment yourself:

pip install agentladle-mcp-hkexnews

Then configure:

{
  "mcpServers": {
    "mcp-hkexnews": {
      "command": "agentladle-mcp-hkexnews"
    }
  }
}

Alternative: Run from source (local development)

Clone the repository and run directly:

git clone https://github.com/agentladle/mcp-hkexnews.git

Then configure your MCP client:

{
  "mcpServers": {
    "mcp-hkexnews": {
      "command": "uv",
      "args": ["run", "--directory", "/path/to/mcp-hkexnews", "agentladle-mcp-hkexnews"]
    }
  }
}

Replace /path/to/mcp-hkexnews with the actual path to the cloned repository.

Data Flow

HKEXnews API                      Local Files (~/.agentladle/mcp-hkexnews/data/)
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€                    โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
activestock_sehk_e.json  โ”€โ”€โ†’     companies.json               (stock_codeโ†’stockId mapping)
ListOfSecurities.xlsx      โ”€โ”€โ†’         โ”‚
tierone/tiertwo JSON       โ”€โ”€โ†’     tiers.json                   (headline category mapping)
                                     โ”‚
titleSearchServlet.do    โ”€โ”€โ†’        pdf/{LOCAL_KEY}/            (Tool 2: primary PDF/HTML + manifest)
                                     โ”‚
PyMuPDF parsing          โ”€โ”€โ†’        json/*.json                 (Tool 3: parse, page-split)
                                     โ”‚
Local TF search          โ”€โ”€โ†’        search results              (Tool 4: keyword search)
Page range read          โ”€โ”€โ†’        page content                (Tool 5: read pages)

Tools

# Tool Description
1 list_hkexnews_announcements Discover available HKEXnews announcements for a company
2 download_hkexnews_announcement Download announcement PDF (HTML fallback); idempotent
3 parse_hkexnews_announcement Parse PDF/HTML into page-split JSON using PyMuPDF
4 keyword_search Full-text keyword search with TF relevance scoring
5 get_announcement_pages Read announcement content by page number range
6 lookup_stock_code Diagnostic: look up stock_codeโ†’stockId mapping when resolution fails

Tool 1: list_hkexnews_announcements

List available HKEXnews announcements for a company. Use this tool ONLY when the exact date/title is unspecified by the user, or when a download attempt fails due to an ambiguous match. Excludes full periodic report PDFs (Annual / Interim / Quarterly Report and ESG Report under t1=40000).

Parameter Type Required Description
stock_code string โœ… 5-digit HK stock code, e.g. "00700"
category string โŒ HKEX t1/t2 code or tier name, e.g. "Inside Information", "13500", "20000". Omit to list all in-scope categories
start_date string โŒ Start date YYYY-MM-DD
end_date string โŒ End date YYYY-MM-DD
title_keyword string โŒ Title keyword filter
limit int โŒ Max announcements to return, default 10, max 50

Tool 2: download_hkexnews_announcement

Download a specific HKEXnews announcement from www1.hkexnews.hk. Prefer local_key from list_hkexnews_announcements when available. Idempotent.

Parameter Type Required Description
stock_code string โœ… 5-digit HK stock code, e.g. "00700"
release_date string โŒ Release date YYYY-MM-DD (optional if local_key provided)
title_keyword string โŒ Title substring to disambiguate same-day announcements
category string โŒ Optional category filter
news_id string โŒ HKEXnews NEWS_ID if known
local_key string โŒ Exact local bundle key from list results

Tool 3: parse_hkexnews_announcement

Parse a downloaded announcement PDF/HTML into page-split JSON. Uses PyMuPDF for PDF physical-page text extraction.

Parameter Type Required Description
local_key string โœ… Bundle key returned by list/download, e.g. "00700_13500_2026-03-15_a1b2c3d4"

Tool 4: keyword_search

Full-text keyword search across all pages. Results ranked by TF + position-boost score.

Parameter Type Required Description
local_key string โœ… Bundle key
keywords string[] โœ… 1โ€“5 search keywords
match_mode string โŒ "ANY" (default, any keyword matches) / "ALL" (all must match)
max_results int โŒ Max results to return, default 5, max 50

Tool 5: get_announcement_pages

Read full page content by page number range.

Parameter Type Required Description
local_key string โœ… Bundle key
start_page int โœ… Start page number (1-based)
page_count int โŒ Number of pages to return, default 3, max 5

Tool 6: lookup_stock_code

Diagnostic tool: look up stock_codeโ†’stockId mapping. Use only when download_hkexnews_announcement / list_hkexnews_announcements returns Stock code not found. Bypasses the session failed-code cache.

Parameter Type Required Description
stock_code string โœ… 5-digit HK stock code, e.g. "00700"
refresh bool โŒ Force re-download of HKEX company mappings (default: false)

Configuration

On first run, a default config file is created at ~/.agentladle/mcp-hkexnews/config.yaml:

paths:
  data_dir: "~/.agentladle/mcp-hkexnews/data"
  pdf_dir: "~/.agentladle/mcp-hkexnews/data/pdf"
  json_dir: "~/.agentladle/mcp-hkexnews/data/json"

download:
  delay_between_requests: 0.3
  min_file_size: 500
  list_row_range: 100
  list_max_pages: 5

company:
  cache_ttl_days: 7

tiers:
  cache_ttl_days: 7

Data Directory Structure

~/.agentladle/mcp-hkexnews/
โ”œโ”€โ”€ config.yaml                        # Configuration (auto-created)
โ””โ”€โ”€ data/
    โ”œโ”€โ”€ companies.json                 # stock_codeโ†’stockId mapping (auto-downloaded & cached)
    โ”œโ”€โ”€ tiers.json                     # HKEX headline category mapping (auto-downloaded & cached)
    โ”œโ”€โ”€ pdf/                           # Downloaded announcement bundles
    โ”‚   โ”œโ”€โ”€ 00700_13500_2026-03-15_a1b2c3d4/
    โ”‚   โ”‚   โ”œโ”€โ”€ primary.pdf
    โ”‚   โ”‚   โ””โ”€โ”€ manifest.json
    โ”‚   โ””โ”€โ”€ ...
    โ””โ”€โ”€ json/                          # Parsed page-split JSON
        โ”œโ”€โ”€ 00700_13500_2026-03-15_a1b2c3d4.json
        โ””โ”€โ”€ ...

File naming convention: {STOCK_CODE}_{T2_CODE}_{RELEASE_DATE}_{ID_HASH}

Example Usage

The tools are designed with an EAFP (Easier to Ask for Forgiveness than Permission) approach. AI assistants should attempt to retrieve data directly and rely on errors to trigger downloads.

Scenario A: File already exists locally (Shortest Path)

User: "Search 00700 inside information for buyback"

1. keyword_search(local_key="00700_50100_2026-07-09_a1b2c3d4", keywords=["buyback", "repurchase"])
   โ†’ Returns page snippets matching the keywords immediately.

Scenario B: File missing (Fallback triggered)

User: "What did Tencent announce in its latest inside information?"

1. list_hkexnews_announcements(stock_code="00700", category="Inside Information", limit=3)
   โ†’ Returns local_key / release_date / title.

2. keyword_search(local_key="...", keywords=["inside information"])
   โ†’ Error: File not found.

3. download_hkexnews_announcement(stock_code="00700", local_key="...")
   โ†’ Downloads PDF to ~/.agentladle/mcp-hkexnews/data/pdf/

4. parse_hkexnews_announcement(local_key="...")
   โ†’ Parses into JSON.

5. keyword_search(local_key="...", keywords=["inside information"])
   โ†’ Retries search and returns data.

Tech Stack

Component Choice Purpose
MCP Framework mcp (FastMCP) MCP server with stdio transport
HTTP Client httpx HKEXnews API requests & file downloads
PDF Parsing pymupdf + beautifulsoup4 PDF page text extraction; HTML fallback
Search Python built-in TF + position-boost scoring
Config pyyaml YAML configuration file
Securities List openpyxl Parse HKEX ListOfSecurities.xlsx

Project Structure

src/mcp_hkexnews/
โ”œโ”€โ”€ __init__.py
โ”œโ”€โ”€ server.py                 # MCP Server entry point
โ”œโ”€โ”€ config.py                 # Config loading (~/.agentladle/mcp-hkexnews/config.yaml, singleton cached)
โ”œโ”€โ”€ models.py                 # Data models
โ”œโ”€โ”€ categories.py             # Announcement category blacklist
โ”œโ”€โ”€ response.py               # Unified JSON responses
โ”œโ”€โ”€ instances.py              # Service singletons
โ”œโ”€โ”€ tools/
โ”‚   โ”œโ”€โ”€ list_announcements.py # Tool 1: list_hkexnews_announcements
โ”‚   โ”œโ”€โ”€ download.py           # Tool 2: download_hkexnews_announcement
โ”‚   โ”œโ”€โ”€ parse.py              # Tool 3: parse_hkexnews_announcement
โ”‚   โ”œโ”€โ”€ search.py             # Tool 4: keyword_search
โ”‚   โ”œโ”€โ”€ page.py               # Tool 5: get_announcement_pages
โ”‚   โ””โ”€โ”€ lookup.py             # Tool 6: lookup_stock_code
โ””โ”€โ”€ services/
    โ”œโ”€โ”€ company.py            # HKEX activestock + ListOfSecurities + stock_codeโ†’stockId
    โ”œโ”€โ”€ tiers.py              # HKEX tierone/tiertwo category cache
    โ”œโ”€โ”€ downloader.py         # HKEXnews titleSearch + PDF download
    โ”œโ”€โ”€ parser.py             # PDF/HTMLโ†’JSON parsing (PyMuPDF)
    โ”œโ”€โ”€ searcher.py           # Local JSON search + TF scoring
    โ””โ”€โ”€ keys.py               # local_key helpers

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agentladle_mcp_hkexnews-0.1.0.tar.gz (99.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agentladle_mcp_hkexnews-0.1.0-py3-none-any.whl (33.2 kB view details)

Uploaded Python 3

File details

Details for the file agentladle_mcp_hkexnews-0.1.0.tar.gz.

File metadata

  • Download URL: agentladle_mcp_hkexnews-0.1.0.tar.gz
  • Upload date:
  • Size: 99.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.3

File hashes

Hashes for agentladle_mcp_hkexnews-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4470ef152416448a7a8db6f5b5b7edb9b20a64275e19680ad8175be60f28226f
MD5 854c98637d5ee2877a2394fd9e58c41e
BLAKE2b-256 40fe23f178f3db5326abeec14c88b58d5c67bcae38edd663c1783f1e4080b467

See more details on using hashes here.

File details

Details for the file agentladle_mcp_hkexnews-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for agentladle_mcp_hkexnews-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 018f4a836bed6ea10ed192ff7982b23d751571bb10da37401d0c5d177218c9a3
MD5 d15d141a25499de45a30c953ad183e44
BLAKE2b-256 5958d3c731bbfdaecbcf066ad1276a96bfd6b21901724fc02e844897e3932b0a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page