Chartink MCP Server
An MCP (Model Context Protocol) server that lets Claude — or any MCP-compatible AI agent — run Chartink stock screeners and backtests for the Indian (NSE/BSE) market directly from a chat.
You describe a strategy in plain English, the agent writes the Chartink scan clause, and this server runs it against Chartink and returns the matching stocks.
Bundled with a
chartink-queryskill (seeskills/) that teaches the agent the full Chartink scan-clause syntax — every indicator, function, and gotcha — so it writes correct queries on the first try.
Features
Requirements
- Python 3.10+ (developed on 3.11) — required by the
mcppackage; your system's defaultpython3may be older, see Installation - A Chartink account (free works for most scans; some features need premium)
- An MCP-compatible client: Claude Desktop, Claude Code, or any agent that speaks MCP over stdio
Installation
⚠️ Check your Python version first. The
mcppackage requires Python 3.10+. On many machines the defaultpython3is older (e.g. macOS ships 3.9), andpip install mcpwill fail with a dependency/SyntaxError. Verify:python3 --version # must be 3.10 or newerIf it's older, use one of the options below to get a 3.10+ interpreter.
# 1. Clone
git clone https://github.com/<your-username>/chartink-mcp.git
cd chartink-mcp
Option A — using uv (recommended; handles the Python version for you)
uv auto-downloads a suitable Python, so you don't need a system 3.10+:
uv venv venv --python 3.11 # creates ./venv with Python 3.11
uv pip install --python venv/bin/python -r requirements.txt
Option B — plain venv + pip
# Use a 3.10+ interpreter. If `python3` is too old, call a specific one,
# e.g. python3.11 / python3.12 (install via Homebrew: `brew install [email protected]`).
python3.11 -m venv venv # or: python3 -m venv venv (only if 3.10+)
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
Dependencies (requirements.txt): mcp, requests, beautifulsoup4.
Verify the install:
venv/bin/python --version # should print 3.10+
venv/bin/python -c "import server; print('OK')" # deps load, server importable
Note the absolute path to the venv's Python and to server.py — you'll need them for the client config:
echo "$(pwd)/venv/bin/python" # → command
echo "$(pwd)/server.py" # → args[0]
Configuration
The server runs over stdio. Point your MCP client at the venv Python + server.py. Ready-to-edit templates live in config-examples/.
Claude Desktop
Edit the config file:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"chartink": {
"command": "/absolute/path/to/chartink-mcp/venv/bin/python",
"args": ["/absolute/path/to/chartink-mcp/server.py"]
}
}
}
Restart Claude Desktop. You should see the chartink tools appear.
Claude Code
Create (or edit) .mcp.json in your project root:
{
"mcpServers": {
"chartink": {
"command": "/absolute/path/to/chartink-mcp/venv/bin/python",
"args": ["/absolute/path/to/chartink-mcp/server.py"]
}
}
}
Or add it via the CLI:
claude mcp add chartink -- /absolute/path/to/chartink-mcp/venv/bin/python /absolute/path/to/chartink-mcp/server.py
Any other MCP client
Use the generic stdio form — run the command below and speak MCP to its stdin/stdout:
/absolute/path/to/chartink-mcp/venv/bin/python /absolute/path/to/chartink-mcp/server.py
Authentication (one-time per session)
Chartink's scan endpoints need a valid session, so you pass it your browser cookies once.
-
Log in to chartink.com in Chrome.
-
Open DevTools → Network tab.
-
Click any request to
chartink.com, go to Headers → Request Headers, and copy the entireCookie:value (it containsXSRF-TOKEN=...; ci_session=...; ...). -
In your AI chat, tell the agent to set the cookies, e.g.:
"Set my Chartink cookies:
XSRF-TOKEN=...; ci_session=...; ..."(This calls
set_cookies.) You'll get back "XSRF-TOKEN found ✓" if it worked.
Cookies live for the duration of the server process. Re-run set_cookies if requests start failing (session expired).
⚠️ Never commit your cookies. They are credentials. The
.gitignorealready excludes common secret/cache files, but treat the cookie string like a password.
Usage examples
Once configured and authenticated, just talk to the agent:
"Find NSE stocks within 5% of their 52-week high with rising volume."
"Run this scan clause and show me the matches:
( {cash} ( latest rsi( 14 ) > 60 and latest close > latest sma( latest close , 50 ) ) )"
"Run the saved screener
short-term-breakouts."
"Compare two strategies: an RSI breakout vs a MACD crossover."
The agent writes the scan clause (using the bundled skill), the server runs it, and you get the stock list back.
Scan-clause shape (quick primer)
( {cash} ( <condition> [and|or <condition>] ... ) )
{cash} = all NSE cash stocks. Conditions use Chartink's English-like grammar, e.g.
latest close > latest sma( latest close , 50 ). See the bundled skill for the full syntax.
The chartink-query skill
The skills/chartink-query/ folder is a portable Claude skill that documents the entire Chartink scan-clause language — price/volume attributes, timeframes & candle offsets, every indicator (SMA, EMA, RSI, MACD, ADX, Bollinger, Stochastic, Supertrend, Donchian, VWAP, OBV, pivots…), functions (max/min/count/abs), crossover construction, segments, and the supported fundamental fields — plus a library of ready-to-use example queries.
With the skill installed, the agent writes valid scan clauses on the first try and can produce both the MCP/API form and the copy-paste form for chartink.com.
Install the skill
Claude Code — copy it into either location:
# user-level (available in every project)
cp -r skills/chartink-query ~/.claude/skills/
# or project-level
mkdir -p .claude/skills && cp -r skills/chartink-query .claude/skills/
Claude Desktop / other agents — point your skills directory at skills/chartink-query/, or paste the contents of SKILL.md into your system prompt / project knowledge.
Then just ask: "write a chartink query for stocks breaking a 20-day high with a volume surge" and the skill handles the syntax.
Project structure
chartink-mcp/
├── server.py # the MCP server
├── requirements.txt
├── README.md
├── LICENSE
└── skills/
└── chartink-query/ # portable Claude skill for Chartink syntax
├── SKILL.md
├── reference.md # full keyword/indicator/function catalog
└── examples.md # ready-to-use query patterns
Troubleshooting
Disclaimer
This project is for educational and research purposes only. It is not investment advice, and the authors are not SEBI-registered advisers. Screener output and any backtests are not recommendations to buy or sell. Always do your own due diligence and manage your own risk. Use in accordance with Chartink's terms of service.
Contributing
Issues and PRs welcome. Ideas: caching, richer backtest parsing, more example skills, tests.