PSX MCP

io.github.revolutionarybukhari由 GitHub 帳號 revolutionarybukhari 發布v0.1.1更新於 Oct 27, 2026

Pakistan Stock Exchange in plain English — quotes, dividends, announcements, and indices.

已驗證STDIO僅桌面網頁搜尋與抓取金融

概覽

AI 產生的概覽

唯讀的 MCP 伺服器,讓助理用自然語言查詢巴基斯坦證券交易所的報價、股利、公告與指數。

可以做什麼
  • 查詢個股目前價格快照,並依公司名稱模糊比對股票代號
  • 列出即將發放的股利與推算的買進截止日,查看歷年配息,並依最低配息比例篩選股票
  • 取得近期公司公告與文件,附 PDF 連結
  • 讀取 KSE100、KSE30、KMI30、ALLSHR、PSXDIV20 等指數點位,並判斷市場目前是否開市
  • 提供市場狀態、指數、即將發放股利等唯讀資源,以及股利交易分析、持股檢視、機會篩選等範本化提示
適用情境
適合巴基斯坦市場研究:查看報價、依 T+2 買進截止日規劃股利交易、檢視持股組合,或彙整某公司近期公告。
執行需求
以本機 Python 套件形式執行(需 Python 3.10 以上),可從 PyPI 或使用 uv 安裝;不需要 API 金鑰或驗證。需要連線至公開的 PSX 資料入口網站(以擷取網頁方式取得資料)。也可啟動為本機 HTTP 伺服器供共用。
安裝前請注意
資料延遲約 5 分鐘,且來自對公開 PSX 網頁的擷取,網站改版可能導致解析失效。買進截止日計算依賴佔位版假日清單,在開齋節與獨立日前後可能不準。設計上為唯讀,不提供下單功能。PSX 條款限制未經授權商業性再散布市場資料。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 PSX MCP,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

psx-mcp

[CI] [PyPI] [Python] [License] [MCP]

mcp-name: io.github.revolutionarybukhari/psx-mcp

Talk to the Pakistan Stock Exchange in plain English.

psx-mcp is a Model Context Protocol server that exposes PSX market data — quotes, dividends, announcements, indices — as tools any MCP-compatible AI client can call. Connect it to Claude Desktop, Cursor, ChatGPT, or your own agent, and ask questions like:

"What are the upcoming dividends on PSX with payouts above 100%?"

"Should I buy MEBL today to collect the dividend?"

"Pull recent announcements for OGDC and summarize anything material."

"How has FFC's dividend history looked over the past 5 years?"

The LLM picks the right tools automatically and answers in your language.

Why MCP?

Existing PSX tools are libraries — you import them, write code, get data. MCP servers are tools an LLM calls for you. You ask in English, the model invokes get_quote, get_upcoming_dividends, get_dividend_history, and synthesizes an answer. No Python required for the end user.

This is also the first PSX MCP server published. If you're building agents, financial copilots, or AI-augmented research workflows for Pakistani markets, this gives them eyes.

What's exposed

Tools (LLM-callable)

ToolWhat it does
get_quote(symbol)Current price snapshot for a symbol
get_upcoming_dividends(symbol?)Payouts table, optionally filtered, with computed buy deadlines
get_buy_deadline(symbol)Last day to buy and still collect the dividend (T+2 settlement)
get_dividend_history(symbol, years)Historical payouts
get_announcements(symbol?, limit)Recent corporate filings + PDF links
search_symbols(query)Fuzzy match company names → tickers
get_indices()KSE100, KSE30, KMI30, ALLSHR, PSXDIV20, etc.
get_market_status()Is PSX open right now? When does it open next?
screen_dividend_stocks(min_payout_pct)Filter upcoming dividends by payout size

Resources (read-only context)

  • psx://market-status
  • psx://indices
  • psx://upcoming-dividends

Prompts (templated workflows)

  • analyze_dividend_play(symbol) — full dividend-trade analysis
  • portfolio_review(symbols) — review a holdings list
  • find_dividend_opportunities(min_payout_pct) — screener + per-name analysis

Install

Requires Python 3.10+.

bash
# From PyPI (once published)pip install psx-mcp
# Or with uv (recommended)uv tool install psx-mcp
# From sourcegit clone https://github.com/revolutionarybukhari/psx-mcpcd psx-mcppip install -e .

Connect to Claude Desktop

Edit your Claude Desktop config:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
json
{  "mcpServers": {    "psx": {      "command": "uvx",      "args": ["psx-mcp"]    }  }}

Restart Claude Desktop. You should see the PSX tools listed in the connection icon. Try:

"What dividends are coming up this week on PSX?"

Connect to Cursor

Settings → MCP → add server:

json
{  "mcpServers": {    "psx": {      "command": "psx-mcp",      "args": []    }  }}

Run as remote HTTP server

For shared/team use or hosted agents:

bash
psx-mcp --transport http --host 0.0.0.0 --port 8000

The server is then reachable at http://localhost:8000/mcp. Test it with the MCP Inspector:

bash
npx @modelcontextprotocol/inspector# point it at http://localhost:8000/mcp

Example prompts to try

Once connected:

"List all PSX stocks paying more than 50% dividend right now,sorted by buy deadline."
"For each stock in my portfolio (HBL, OGDC, PSO, ENGRO, MEBL),tell me if there's an upcoming dividend and what the buy deadline is."
"Find me consistent dividend payers on PSX — companies that havepaid every year for the last 3+ years with payouts above 30%."
"What's happening with FFC today? Pull the quote and the latest3 announcements."
"Walk me through the dividend trade for MARI step by step."

How it works

   ┌──────────────────────┐         ┌─────────────────┐   │  Claude / Cursor /   │  MCP    │   psx-mcp       │   │  ChatGPT / Agent     │ ──────► │   server        │   └──────────────────────┘         └────────┬────────┘                                             │ httpx + bs4                                             ▼                                    ┌─────────────────┐                                    │ dps.psx.com.pk  │                                    └─────────────────┘

Tools call the public PSX Data Portal, parse HTML with BeautifulSoup, normalize into structured JSON, and return to the LLM. No keys, no auth, no scraping headaches for the consumer.

Architecture notes

  • Async everywhere. All scraper functions use httpx.AsyncClient so MCP calls don't block.
  • Symbol cache. The full PSX symbol list is cached for 24h to make search_symbols fast.
  • Trading-day math. Buy-deadline calculation uses BC_From − 2 trading days, skipping weekends and configurable holidays in dividend_calc.PSX_HOLIDAYS_2026.
  • No persistence. This server is stateless. State (alerts, watchlists) belongs in your client.

Pairs well with

This is one server in a wider PSX open-source toolkit:

  • psx-dividend-alert — proactive Telegram alerts for upcoming dividends
  • psx-cgt-calculator — Pakistan capital-gains-tax with FIFO lots
  • psx-zakat-calculator — zakat on stock holdings (zakatable assets method)
  • psx-broker-statement-parser — normalize KTrade/AKD/JS Global PDFs
  • psx-announcements-summarizer — LLM-powered summaries of every PSX filing

The MCP server makes all of these LLM-callable. Pair them and you have a complete conversational PSX research stack.

Limitations / honest notes

  • PSX data is delayed ~5 minutes. Same as the public Data Portal.
  • Scraping is fragile. If PSX changes their HTML, parsers will need updating. PRs welcome.
  • No order placement. This is read-only. There's no path here that puts trades on the wire — by design.
  • Holiday list is stub. Edit PSX_HOLIDAYS_2026 in dividend_calc.py once PSX publishes the annual calendar. Without it, the buy-deadline math correctly skips weekends but will be off during Eid/Independence Day weeks.
  • Personal use. PSX terms restrict commercial redistribution of market data without a license. Email [email protected] if you need one.

Contributing

  • Add a tool: write the function in scraper.py, expose it in server.py with @mcp.tool(), add a docstring (the docstring becomes the LLM's tool description — make it clear).
  • Add a test: drop async tests in tests/. The MCP SDK supports in-memory testing.
  • File issues for HTML parser breakage with the failing URL and a snippet.

License

MIT. See LICENSE.

來源:README.md,提交 4beac6c

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.1.1最新Sep 16, 2026

評分

已滿足適用檢查項的 40%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分

    請在儲存庫或註冊中心條目中宣告授權條款。