
PSX MCP
io.github.revolutionarybukhari由 GitHub 账号 revolutionarybukhari 发布v0.1.1更新于 Oct 27, 2026
Pakistan Stock Exchange in plain English — quotes, dividends, announcements, and indices.
概览
只读的 MCP 服务器,让助手用自然语言查询巴基斯坦证券交易所的报价、股息、公告和指数。
- 可以做什么
- 查询个股当前价格快照,并按公司名模糊匹配股票代码
- 列出即将派发的股息及推算的买入截止日,查看历史派息,并按最低派息比例筛选股票
- 获取近期公司公告与文件,附 PDF 链接
- 读取 KSE100、KSE30、KMI30、ALLSHR、PSXDIV20 等指数点位,并判断市场当前是否开市
- 提供市场状态、指数、即将派息等只读资源,以及股息交易分析、持仓回顾、机会筛选等模板化提示
- 适用场景
- 适合巴基斯坦市场研究:查看报价、围绕 T+2 买入截止日规划股息交易、回顾持仓组合,或汇总某公司近期公告。
- 运行要求
- 以本地 Python 包形式运行(需 Python 3.10 及以上),可从 PyPI 或使用 uv 安装;无需 API 密钥或认证。需要访问公开的 PSX 数据门户网站(通过抓取网页获取数据)。也可作为本地 HTTP 服务器启动以供共享使用。
安装
在 SourceWeft 中
- 打开 控制台中的 PSX MCP,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
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)
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+.
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
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:
Run as remote HTTP server
For shared/team use or hosted agents:
The server is then reachable at http://localhost:8000/mcp. Test it with the MCP Inspector:
Example prompts to try
Once connected:
How it works
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
[email protected]if 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.
来源:README.md,提交 4beac6c
工具
0版本历史
1- v0.1.1最新Sep 16, 2026
评分
已满足适用检查项的 40%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分
请在仓库或注册中心条目中声明许可证。