PSX
PSX MCP Server: A Model Context Protocol server that provides 12 powerful tools for scraping Pakistan Stock Exchange (PSX) market data including real-time quotes, historical data, sector analysis, and OHLCV data. Built with FastMCP and ready for Gemini CLI integration
claude mcp add --transport stdio ahad-raza24-psx-mcp-server python /your/actual/path/scripts/start_server.py \ --env PYTHONPATH="/your/actual/path/src"
How to use
PSX MCP Server provides a suite of tools to scrape and access Pakistan Stock Exchange market data through a Model Context Protocol (MCP) interface. It exposes 12 tools for retrieving current market data, intraday time series, end-of-day history, sector-based searches, and advanced queries like OHLCV data, multi-symbol data, and volume analysis. You can use these tools with any MCP client (for example Gemini CLI) by invoking the corresponding method names such as market_data(), intraday(symbol), history(symbol), sector(sector), gainers(limit), losers(limit), date_range(symbol, start, end), time_range(symbol, start, end), ohlcv(symbol), multi_ohlcv(symbols), price_at_time(symbol, timestamp), and volume_analysis(symbol, days). The server scrapes data from PSX endpoints and returns structured JSON that your client can parse and present in dashboards, alerts, or analyses. To start, deploy the Python server and connect your MCP client to the configured endpoint; then call the tools with the required parameters to fetch the data you need.
How to install
Prerequisites:
- Python 3.8+ and pip installed on your system
- Access to the project repository with start scripts and dependencies
Option A: Direct installation
- Install dependencies
pip install -r requirements.txt
- Prepare configuration (example shown in templates):
cp gemini_config.template.json gemini_config.json
# Edit gemini_config.json to point to your local paths
- Run the MCP server:
python scripts/start_server.py
Option B: Development installation
- Install development tools
make setup
# or
pip install -e ".[dev]"
- Start the server with Makefile:
make run-server
Option C: Docker (if you prefer containerized deployment)
- Build the Docker image
docker build -t psx-mcp-server .
- Run the container
docker run -it psx-mcp-server
Additional notes
Tips and notes:
- The server uses the following data sources: https://dps.psx.com.pk/market-watch, https://dps.psx.com.pk/timeseries/int/{SYMBOL}, and https://dps.psx.com.pk/timeseries/eod/{SYMBOL} for data retrieval.
- Ensure PYTHONPATH and project paths in your mcp_config.json correctly point to your local source and modules.
- If you see JSON parsing or network errors, verify that the PSX endpoints are reachable from your deployment environment and that your environment variables are correctly set.
- For large symbol lists in multi_ohlcv, consider batching requests if you encounter timeouts.
- Use the template-based configuration to quickly set up Gemini CLI with your project path using gemini_config.json.
- The server is designed to be MCP-compatible, so any MCP client should be able to query the provided tools and handle the JSON responses.
Related MCP Servers
mcp-vegalite
MCP server from isaacwasserman/mcp-vegalite-server
github-chat
A Model Context Protocol (MCP) for analyzing and querying GitHub repositories using the GitHub Chat API.
nautex
MCP server for guiding Coding Agents via end-to-end requirements to implementation plan pipeline
pagerduty
PagerDuty's official local MCP (Model Context Protocol) server which provides tools to interact with your PagerDuty account directly from your MCP-enabled client.
futu-stock
mcp server for futuniuniu stock
mcp -boilerplate
Boilerplate using one of the 'better' ways to build MCP Servers. Written using FastMCP