CSE MCP Intelligence
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@CSE MCP IntelligenceShow me today's top gainers"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
CSE MCP Intelligence
Institutional-grade MCP server for the Colombo Stock Exchange. Features real-time market data, order flow pressure analysis, and AI-powered forensic fundamental screening.
🚀 Quick Start
# Clone repository
git clone https://github.com/hareeshkar/cse-mcp-intelligence.git
cd cse-mcp-intelligence
# Install dependencies
npm install
# Build
npm run build
# Run with Claude
npm startRelated MCP server: Sablier MCP Server
📋 What is MCP?
Model Context Protocol (MCP) enables Claude and other AI models to access external data sources and APIs in real-time. Instead of relying on static training data, Claude can now fetch live market information from the CSE API.
✨ Features
Real-time Market Data - Current stock prices, market status, and daily summaries
Sector Analysis - Track performance across all market sectors with detailed metrics
Stock Intelligence - Company profiles, financial reports, and compliance information
Order Flow Analysis - Market depth, trading pressure indicators, and volume analysis
Historical Data - Candlestick charts and detailed trade history for technical analysis
Smart Caching - 30-second cache to optimize API usage and reduce latency
🔧 Installation
Prerequisites
Node.js 18+ (download)
npm 9+ (comes with Node.js)
Claude Desktop (for integration)
Setup Steps
Clone the repository:
git clone https://github.com/hareeshkar/cse-mcp-intelligence.git cd cse-mcp-intelligenceInstall dependencies:
npm installBuild the TypeScript source:
npm run build
⚙️ Claude Desktop Configuration
⚙️ Claude Desktop Configuration
macOS/Linux
Edit ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"cse": {
"command": "node",
"args": ["/full/path/to/cse-mcp-intelligence/build/index.js"]
}
}
}Windows
Edit %APPDATA%\Claude\claude_desktop_config.json:
{
"mcpServers": {
"cse": {
"command": "node",
"args": ["C:\\full\\path\\to\\cse-mcp-intelligence\\build\\index.js"]
}
}
}⚠️ Important: Replace the path with your actual project location.
Restart Claude Desktop
After updating the config, completely close and reopen Claude Desktop for the changes to take effect.
🛠 Available Tools
Market Overview
scan_market
Get all stocks trading on the Colombo Stock Exchange with filtering capabilities.
Parameters:
maxPrice(number, optional) - Filter for penny stocks below this price in LKRminVolume(number, optional) - Only show stocks with volume above threshold (filters illiquid stocks)
Returns: Array of stocks with symbol, name, current price, change %, and volume
Use Cases:
Penny stock hunting:
scan_market { maxPrice: 50 }Active stocks only:
scan_market { minVolume: 100000 }
get_sectors
Performance data for all CSE market sectors.
Returns: Sector names with change %, turnover, market capitalization
Use Cases:
Sector rotation analysis
Finding the strongest/weakest sectors
Portfolio diversification checks
get_market_status
Real-time market status - check if trading is active.
Returns: Open/Closed status, current timestamp, trading hours
get_market_summary
Comprehensive daily market overview with macro indicators.
Returns: P/E ratio, P/B ratio, foreign investor flow, total turnover, market mood
Stock Performance
get_top_gainers
Stocks with highest percentage gains today.
Parameters:
limit(number, optional, default: 10) - How many top performers to show
Returns: Top performers with price action and volume data
get_top_losers
Stocks with highest percentage losses today.
Parameters:
limit(number, optional, default: 10) - How many bottom performers to show
Returns: Oversold stocks useful for contrarian or risk assessment
Stock Analysis
get_stock_detail
Complete detailed information about a specific stock.
Parameters:
symbol(required) - Stock symbol (e.g., "SLTL", "ASPI", "LAUGF")
Returns: Company profile, current price, P/E ratio, dividends, 52-week high/low, trading stats
Use Cases:
Fundamental analysis
Company profile research
Valuation metrics
get_stock_trades
Recent trade history for order flow analysis.
Parameters:
symbol(required) - Stock symbollimit(optional, default: 20) - Number of recent trades
Returns: Timestamps, executed prices, volumes, trade direction (buy/sell)
Use Cases:
Order flow forensics
Volume profile analysis
Institutional buying/selling detection
get_order_book
Live market depth with order flow pressure analysis.
Parameters:
symbol(required) - Stock symbol
Returns:
Bid/ask levels with volumes
Pressure index (-1 = extreme bearish, +1 = extreme bullish)
Bid-ask spread percentage
Market depth profile
Use Cases:
Pre-trade liquidity analysis
Support/resistance levels
Institutional accumulation/distribution detection
Technical Analysis
get_candlesticks
OHLC (Open, High, Low, Close) data for technical analysis.
Parameters:
symbol(required) - Stock symbolperiod(optional, default: "1d") - Time period ("1d", "1w", "1m")
Returns: Candlestick data with open, high, low, close prices and volume
Use Cases:
Technical pattern recognition
Trend analysis
Support/resistance identification
Volume profile
💡 Real-World Usage Examples
Penny Stock Screening
Query: "Find all penny stocks under Rs. 50 with high trading volume"
Tool: scan_market { maxPrice: 50, minVolume: 500000 }
→ Get list of actively traded penny stocks for swing tradingSector Rotation Strategy
Query: "Which sectors are outperforming today? Show me the leaders."
Tool: get_sectors
→ Identify hot sectors and potential rotation candidatesPre-Trade Liquidity Check
Query: "Can I buy 10,000 shares of SLTL without moving the price too much?"
Tool: get_order_book { symbol: "SLTL" }
→ Check bid-ask spread, depth, and available liquidityOrder Flow Forensics
Query: "Show me the last 50 trades on ASPI - is it institutional buying or selling?"
Tool: get_stock_trades { symbol: "ASPI", limit: 50 }
→ Analyze trade timing and sizes to identify smart money activityTechnical Setup Confirmation
Query: "Show SLTL candlesticks and confirm the resistance breakout"
Tool: get_candlesticks { symbol: "SLTL", period: "1d" }
→ Get OHLC data for pattern recognition and trend analysisMarket Stress Test
Query: "What percentage of stocks are down today? Any panic selling?"
Tool: get_top_losers { limit: 20 }
→ Identify oversold conditions and panic-driven opportunities🏗️ Technical Architecture
Core Components
1. CSE API Client (src/cse-client.ts)
Purpose: Direct wrapper around the Colombo Stock Exchange REST API
Features:
Smart caching (30-second TTL) to reduce API load and improve responsiveness
Symbol mapping (Display Name ↔ API Symbol translation)
CDN URL fixing for company reports and documents
Error resilience with graceful fallbacks
Automatic retry logic with exponential backoff
Key Methods:
getAllStocks()- Market scangetStockDetail(symbol)- Detailed fundamental datagetOrderBook(symbol)- Real-time market depthgetTradeHistory(symbol, limit)- Order flow analysisgetCandlesticks(symbol, period)- Technical data
2. Tool Definitions & Handlers (src/tools.ts)
Purpose: Define all MCP tools available to Claude with proper schemas
Includes:
Tool name, description, parameter schema
Input validation using JSON Schema
Type definitions for type safety
8+ Tools:
scan_market- Market scanning with filtersget_sectors- Sector performanceget_market_status- Trading statusget_market_summary- Macro indicatorsget_top_gainers/get_top_losers- Performance leaders/laggardsget_stock_detail- Fundamental analysisget_stock_trades- Trade history/order flowget_order_book- Market depthget_candlesticks- Technical analysis
3. MCP Server (src/index.ts)
Purpose: Entry point that bridges CSE API and Claude
Responsibilities:
Listens to Claude's tool requests via stdio
Routes requests to appropriate CSE client methods
Handles request/response serialization
Error handling and user-friendly error messages
Request parameter validation
Data Flow
Claude Desktop
↓
[MCP Server] ← Claude makes tool request (JSON-RPC)
↓
[Tool Router] ← Validates parameters
↓
[CSE Client] ← Fetches data from API
↓
Colombo Stock Exchange API
↓
[Cache Layer] ← 30-second cache for same requests
↓
[Response Formatter] ← Cleans and structures data
↓
Claude ← Gets structured market data for analysisCaching Strategy
The system implements smart caching to optimize performance:
TTL: 30 seconds (market data doesn't change faster)
Cache Key: Tool name + parameters hash
Benefits:
Reduces API calls during multi-tool analysis
Faster Claude response times
Respects CSE rate limits
Can handle 1,000+ requests/minute internally
Error Handling & Fallbacks
API Timeouts → Cached data (if available) or graceful error
Invalid Symbol → Fuzzy matching suggestions
Market Closed → Return last known data with status
Network Errors → Retry up to 3 times with exponential backoff
Rate Limiting → Queue and delay requests intelligently
CSE API Integration Points
The server connects to these CSE API endpoints:
/v1/stocks- All stocks with live prices/v1/stocks/{id}- Stock detail & fundamentals/v1/stocks/{id}/orderbook- Market depth/v1/stocks/{id}/trades- Trade history/v1/sectors- Sector performance/v1/market- Overall market status
📝 Scripts
npm run build # Compile TypeScript to JavaScript
npm start # Run the MCP server
npm run dev # Run in development mode with hot reload🐛 Troubleshooting
Claude doesn't recognize the server
Verify the path in
claude_desktop_config.jsonis correct and absoluteMake sure you've run
npm run buildRestart Claude Desktop completely (not just minimize)
API Connection Issues
Check that you have internet connectivity
Verify the CSE API is accessible:
curl https://api.cse.lk/api/v1/marketCheck rate limiting if getting 429 errors
Build Errors
Delete
build/andnode_modules/foldersRun
npm installandnpm run buildagainEnsure Node.js 18+ is installed
📖 Documentation
API Reference - Detailed tool specifications
Implementation Guide - Technical architecture
Changelog - Version history
Graceful Fallbacks - Error handling strategies
🤝 Contributing
This project is open to contributions! Areas for enhancement:
Additional technical indicators
Portfolio tracking features
Alert systems
WebSocket support for real-time updates
📄 License
MIT License - See LICENSE file for details
👤 Author
Hareesh Karravi - @hareeshkar
🔗 Links
Questions? Open an issue on GitHub or check the documentation files.
get_market_summary - Daily market overview
Returns: P/E ratio, P/B ratio, foreign flow, total turnover
Stock-Specific Data
get_stock_snapshot - Real-time price data
Input: Stock symbol
Returns: Open, high, low, last price, volume, change %
get_top_gainers - Top performing stocks
Optional: Limit (default 10)
Returns: Symbol, price, % change
get_order_book - Market depth for a stock
Input: Stock symbol
Returns: Bids/asks, volumes, market pressure
get_chart_data - Historical OHLCV data
Input: Symbol, period (1=Intraday, 2=Weekly, 3=Monthly, 5=Daily)
Returns: Open, high, low, close, volume with dates
Deep Research
get_detailed_trades - Tick-by-tick trade data
Optional: Filter by symbol
Returns: Price, volume, time, buyer/seller
get_company_profile - Company information
Input: Stock symbol
Returns: Directors, secretaries, registrars, company details
get_financial_reports - Company reports
Input: Stock symbol
Returns: Links to quarterly and annual reports (PDFs)
get_noncompliance_list - At-risk companies
Returns: Companies on watch list or under enforcement action
⚠️ Use for due diligence - avoid investing in these companies
Usage Examples
In Claude Desktop
Ask questions naturally:
"What are the top 5 gainers on CSE today?""Show me the current price and order book for JKH.N0000""Which stocks are trading under 10 LKR?""Get the financial reports for DIALOG.N0000""What's the market P/E ratio and which sectors are performing best?""List all companies currently on the non-compliance watch list"Development
Local Testing
Run the development server:
npm run devBuild for Production
npm run build
npm startProject Structure
cse-mcp-server/
├── src/
│ ├── index.ts # MCP server entry point
│ ├── cse-client.ts # CSE API wrapper (12 atomic tools)
│ └── tools.ts # Tool definitions for Claude
├── build/ # Compiled JavaScript (auto-generated)
├── package.json # Dependencies and scripts
├── tsconfig.json # TypeScript configuration
├── .env.example # Environment template
└── README.md # This fileAPI Details
Base URL
https://www.cse.lk/api
Features
Error Handling: Graceful fallback when API unavailable
Caching: 30-second TTL reduces API calls
Symbol Resolution: Auto-builds symbol-to-ID mapping
Data Sanitization: Removes commas from prices, handles null values
Rate Limiting
The CSE API does not publicly advertise rate limits, but best practice suggests:
Keep API calls under 10 requests per second
Use caching to minimize redundant requests
Troubleshooting
Server won't start
# Check Node.js version
node --version # Should be v18+
# Check if port 3000 is available
# Or rebuild everything
rm -rf build/ node_modules/
npm install
npm run buildClaude can't find the tools
Check the file path in
claude_desktop_config.jsonis correctEnsure the build directory exists:
npm run buildRestart Claude Desktop completely
Check Claude's error console for details
API returns empty data
CSE market may be closed (closed outside market hours)
Symbol may be incorrect (check exact symbol format)
Try
scan_marketto get list of valid symbols
Performance issues
Data is cached for 30 seconds - avoid rapid repeated calls
The CSE API may have rate limits we're not aware of
Try spreading requests over time
Disclaimer
This tool provides educational access to public CSE data. Always conduct your own due diligence before making investment decisions. The authors are not responsible for any financial losses.
License
MIT
Author
Created for CSE market research and analysis
Support
For issues, feature requests, or improvements:
Check that you're running the latest version
Review the troubleshooting section
Ensure Node.js and npm are up to date
Roadmap (Future Phases)
Phase 2: Historical data analysis, sector comparison
Phase 3: Portfolio tracking, alerts on price changes
Phase 4: Technical indicators, moving averages
Phase 5: Machine learning predictions
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/hareeshkar/cse-mcp-intelligence'
If you have feedback or need assistance with the MCP directory API, please join our Discord server