Get the FREE Ultimate OpenClaw Setup Guide →

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

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
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

  1. Install dependencies
pip install -r requirements.txt
  1. Prepare configuration (example shown in templates):
cp gemini_config.template.json gemini_config.json
# Edit gemini_config.json to point to your local paths
  1. Run the MCP server:
python scripts/start_server.py

Option B: Development installation

  1. Install development tools
make setup
# or
pip install -e ".[dev]"
  1. Start the server with Makefile:
make run-server

Option C: Docker (if you prefer containerized deployment)

  1. Build the Docker image
docker build -t psx-mcp-server .
  1. 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

Sponsor this space

Reach thousands of developers