cse-mcp
An open-source MCP server that gives Claude and other AI tools live Colombo Stock Exchange data: prices, indices, foreign flow and company announcements.
- Period
- 2026
- Stack
- Python, MCP, httpx, uv, pytest, GitHub Actions, PyPI
- Links
- Live site ↗Source ↗
Banks beat the market today, led by COMB on 1.5M shares.
as of 14:30 SLT · read-only
AI assistants are good at explaining markets and bad at knowing what happened in them today. Ask one about the Colombo Stock Exchange and you get stale numbers or a polite refusal, so the workaround is copying prices from cse.lk into the chat by hand. cse-mcp removes that step. It's an MCP server, a standard plug that lets AI apps call tools, and it connects them to the public data behind cse.lk so their answers use current prices, indices and announcements.
You: How did banks do today vs the ASPI? Anything interesting from COMB?
Claude: The ASPI closed +2.75% at 22,123. Banks did even better (+3.7%).
COMB ended at LKR 225.25 (+4.3%) on 1.5M shares...
Ten Tools, All Read-Only
The server exposes ten tools, each a small function that answers one kind of question:
- Market: status and headline indices (ASPI, S&P SL20), top gainers, losers and most active stocks, and every sector index ranked best to worst.
- Stocks: search all listed companies by name or ticker, a full profile of one stock (price ranges from a week to all-time, market cap, foreign holding, beta), price history from 15-minute intraday bars to a year, and today's volume at each price level with the VWAP.
- Context: net foreign buying and selling, market P/E and dividend yield, index history, and company announcements with links to the PDF filings.
Every tool is marked read-only. It can't place trades or change anything, which matters when the caller is a model.
Shaped for a Model to Read
The cse.lk API is public but undocumented, and its raw JSON is written for the website, not for a model. Field names are cryptic, numbers carry long decimals, and timestamps are epoch milliseconds. Each tool reshapes its response into something compact: readable names, rounded numbers, Sri Lanka time, and no logo or ID noise. Intraday trades are grouped into 15-minute OHLC bars, and long histories are sampled down so they don't flood the model's context.
Small details make it forgiving to use. jkh, JKH and JKH.N0000 all resolve to the same stock. Errors are written for the AI to act on ("check the symbol") rather than hidden as a generic crash. The server also ships instructions that teach the model the basics: prices are in LKR, trading runs 09:30 to 14:30 on weekdays, and it should start with the market overview for "how's the market?" questions.
Being a Good Guest
The server runs on your own computer and talks straight to cse.lk. It collects nothing and has no backend of its own. Since an AI often calls several tools in a row, responses are cached for 30 seconds: still live for any human purpose, and far gentler on the CSE's servers.
One Tag, Every Install Path
An MCP server is only useful if people can install it, so most of the work went into distribution. Pushing a version tag runs the tests, publishes to PyPI with trusted publishing (no stored API tokens), creates a GitHub release with a one-click Claude Desktop extension, and registers the server in the official MCP Registry. From there it installs in a single step in Claude Desktop, with one command in Claude Code, or from a config snippet in Cursor, VS Code and other MCP apps. A Claude Code plugin adds a market-analyst skill on top: playbooks for a market wrap or a stock deep dive, and ground rules like fetching before answering and stating the data's timestamp.
The test suite runs offline against canned API responses, so it's fast and works anywhere, with an opt-in live test that hits the real cse.lk API to catch changes in the upstream data.
Limits
cse-mcp is unofficial and not affiliated with the Colombo Stock Exchange. Because the API it relies on is undocumented, it can change without notice and break a tool. It runs locally, so it doesn't yet work in claude.ai on the web or phone unless you host it yourself over HTTP. And it's market data, not advice: data can be delayed, and models can misread numbers.