psx-mcp
MCP server that exposes Pakistan Stock Exchange data (quotes, dividends, announcements, indices) as LLM-callable tools, enabling conversational market queries in plain English.
README
psx-mcp
<!-- mcp-name: io.github.revolutionarybukhari/psx-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)
| Tool | What 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-statuspsx://indicespsx://upcoming-dividends
Prompts (templated workflows)
analyze_dividend_play(symbol)— full dividend-trade analysisportfolio_review(symbols)— review a holdings listfind_dividend_opportunities(min_payout_pct)— screener + per-name analysis
Install
Requires Python 3.10+.
# From PyPI (once published)
pip install psx-mcp
# Or with uv (recommended)
uv tool install psx-mcp
# From source
git clone https://github.com/revolutionarybukhari/psx-mcp
cd psx-mcp
pip 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
{
"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:
{
"mcpServers": {
"psx": {
"command": "psx-mcp",
"args": []
}
}
}
Run as remote HTTP server
For shared/team use or hosted agents:
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:
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 have
paid every year for the last 3+ years with payouts above 30%."
"What's happening with FFC today? Pull the quote and the latest
3 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.AsyncClientso MCP calls don't block. - Symbol cache. The full PSX symbol list is cached for 24h to make
search_symbolsfast. - Trading-day math. Buy-deadline calculation uses
BC_From − 2 trading days, skipping weekends and configurable holidays individend_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 dividendspsx-cgt-calculator— Pakistan capital-gains-tax with FIFO lotspsx-zakat-calculator— zakat on stock holdings (zakatable assets method)psx-broker-statement-parser— normalize KTrade/AKD/JS Global PDFspsx-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_2026individend_calc.pyonce 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
marketdatarequest@psx.com.pkif you need one.
Contributing
- Add a tool: write the function in
scraper.py, expose it inserver.pywith@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.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。