> Source: https://ashareapi.com/en/docs/guides/mcp-claude-code/  ·  Markdown version for LLMs / AI agents

Tutorial

# Querying A-share data from Claude Code / Codex (MCP)
 MCP lets your AI Agent fetch real data instead of answering from memory. Set it up once — paste `https://api.ashareapi.com/mcp`; free tools need no key at all.

## What you can ask once it is connected
 After setup, just ask in the chat — the agent calls the tools instead of relying on training memory:

-
 What is the money flow for 太极实业 (600667) today?

-
 Which sectors gained the most in the last 5 sessions?

-
 Screen stocks with PE 15

-
 Is the CSI 300 expensive right now?

-
 What did institutions buy on the top-trader boards today?

## Claude Code: one command (fastest)
 Claude Code can add a remote MCP server with a single command (`--transport http` is our transport). Drop the `--header` half if you only want the **free tools**.

 Terminal (Claude Code)
```
# Free tools (no key needed)
claude mcp add --transport http ashareapi https://api.ashareapi.com/mcp

# Add the header when you want paid tools (financials / money flow / boards)
claude mcp add --transport http ashareapi https://api.ashareapi.com/mcp \
 --header "Authorization: Bearer ct-your-key"

# Check the connection (expect ✔ Connected)
claude mcp list
```

## Cursor / Claude Code: the JSON form
 Cursor reads `.cursor/mcp.json` (project) or `~/.cursor/mcp.json` (global); Claude Code also accepts `.mcp.json` (project root) or `~/.claude.json`.

 .cursor/mcp.json (or .mcp.json)
```
{
 "mcpServers": {
 "ashareapi": {
 "type": "http",
 "url": "https://api.ashareapi.com/mcp",
 "headers": { "Authorization": "Bearer ct-your-key" }
 }
 }
}
```

-
 **Key gotcha: a `url` must come with `"type": "http"`** — Claude Code reads an entry that has a `url` but no `type` as a **stdio server** and skips it (the official docs say it reports `has a "url" but no "type"`). The config above includes it; do not delete the line.

-
 Free tools only: delete the whole `headers` line and keep the rest.

-
 **VS Code uses a different key**: `"servers"` (not `mcpServers`), still with `"type": "http"` + `url`.

## Config for Codex / VS Code / Gemini CLI / OpenCode and friends
 **About Codex first**: since 2026-07-09 Codex has been merged into the ChatGPT desktop app (one app with Chat / Work / Codex modes; the standalone Codex app is gone), **but Codex CLI is unaffected** — MCP config still lives in `~/.codex/config.toml` (the official Developer settings page states the desktop app and the CLI **share the same config.toml**).
 Codex · ~/.codex/config.toml

```
[mcp_servers.ashareapi]
url = "https://api.ashareapi.com/mcp"
http_headers = { Authorization = "Bearer ct-your-key" }
```
 VS Code · .vscode/mcp.json

```
{
 "servers": {
 "ashareapi": {
 "type": "http",
 "url": "https://api.ashareapi.com/mcp",
 "headers": { "Authorization": "Bearer ct-your-key" }
 }
 }
}
```
 Gemini CLI · ~/.gemini/settings.json

```
{
 "mcpServers": {
 "ashareapi": {
 "httpUrl": "https://api.ashareapi.com/mcp",
 "headers": { "Authorization": "Bearer ct-your-key" }
 }
 }
}
```
 OpenCode · opencode.json

```
{
 "$schema": "https://opencode.ai/config.json",
 "mcp": {
 "ashareapi": {
 "type": "remote",
 "url": "https://api.ashareapi.com/mcp",
 "headers": { "Authorization": "Bearer ct-your-key" }
 }
 }
}
```
 Cline · ~/.cline/mcp.json

```
{
 "mcpServers": {
 "ashareapi": {
 "type": "streamableHttp",
 "url": "https://api.ashareapi.com/mcp",
 "headers": { "Authorization": "Bearer ct-your-key" }
 }
 }
}
```
 Windsurf · mcp_config.json

```
{
 "mcpServers": {
 "ashareapi": {
 "serverUrl": "https://api.ashareapi.com/mcp",
 "headers": { "Authorization": "Bearer ct-your-key" }
 }
 }
}
```
 CodeBuddy · ~/.codebuddy/.mcp.json

```
{
 "mcpServers": {
 "ashareapi": {
 "type": "http",
 "url": "https://api.ashareapi.com/mcp",
 "headers": { "Authorization": "Bearer ct-your-key" }
 }
 }
}
```
 WorkBuddy · ~/.workbuddy/mcp.json

```
{
 "mcpServers": {
 "ashareapi": {
 "type": "http",
 "url": "https://api.ashareapi.com/mcp",
 "headers": { "Authorization": "Bearer ct-your-key" }
 }
 }
}
```

-
 **Keys differ — do not copy blindly**: VS Code uses `servers` · Gemini CLI uses `httpUrl` · Cline needs `"type":"streamableHttp"` · Windsurf uses `serverUrl` · OpenCode / Kilo Code / ZCode use an `mcp` key · **Codex is TOML, not JSON**

-
 The remaining clients (Trae / Kimi Code / MiMo Code / Manus / Devin / OpenClaw / Hermes) are listed per client on the [MCP page](https://ashareapi.com/en/mcp/)

-
 **ChatGPT itself (web / desktop app)** can also take remote MCP servers, but through a different path: **Developer mode → Apps → Create custom connector** (endpoint → authentication → Scan Tools), currently aimed at **Business / Enterprise / Edu** workspaces — nothing to do with `config.toml`.

-
 **China platforms** (Alibaba Bailian / Coze / Tencent Yuanqi / Tencent Cloud Agent Platform / Volcengine Ark): see the [China platform guide](https://ashareapi.com/en/docs/mcp-china/). Bailian and Coze do not document custom headers, so only free tools work there.

## Verify in 30 seconds
 Restart the client, then ask "What is the price of 太极实业 (600667) right now?". Judge by **whether it actually called a tool** (you will see a tool call such as `ashare_quote`), not by whether the answer looks plausible — invented numbers look plausible too.
 You can also check the client MCP list directly: in Claude Code, `/mcp` or `claude mcp list` (expect `√ Connected`). To see the tool list, just ask in-session.

## No data coming back? Check these

-
 **URL typo**: it must be `https://api.ashareapi.com/mcp` (note the `api.` host and the `/mcp` path)

-
 **Free quota shared**: anonymous limits are per calling source (5/min; 60/min after one PoW challenge) — a shared egress IP (office, platform) hits it fast; add a key

-
 **Symbol prefix missing**: `sh600667` / `sz000001` / `hk00700` / `usAAPL`; a bare 6-digit code will not resolve

-
 **`url` without `type` in Claude Code**: it is read as stdio and skipped (see the gotcha above)

-
 **Tool list is synced when you save**: tools we add later need a re-save / refresh of the config

-
 **Free tools only**: make sure the `Authorization` line is actually removed (paid tools without a key return an explicit message, not a silent failure)

## FAQ
 What is MCP, and how is it different from calling the API?
 MCP (Model Context Protocol) is the protocol AI Agents use to call external tools. The difference is who writes the code: with an API you write the fetching code and feed the result to the AI; with MCP you configure it once and the AI fetches data on its own as you ask. Both sit on the same backend (32 endpoints) — MCP just exposes 24 tools to the agent.

 Can I use it without a key?
 Yes. Five tools need no key: quote / K-line / hot list / market overview / up-down distribution. The other 19 (financials / money flow / top-trader boards / sector valuation / macro / convertibles / factor screening…) need one (from ¥9.9).

 How is the free quota counted?
 Per calling source: anonymous 5/min, up to 60/min after solving one PoW challenge (GET /v1/challenge). Shared egress IPs hit it fast, so for real use add a key (tier-based limits; Standard allows 120/min).

 Which clients are supported besides Claude Code / Codex?
 Nineteen: Claude Code · Cursor · VS Code · Codex · OpenCode · Gemini CLI · Cline · Windsurf · CodeBuddy · WorkBuddy · Trae · Kimi Code · ZCode · MiMo Code · Kilo Code · Manus · Devin · OpenClaw · Hermes. Per-client config (and key-name differences such as servers / mcp / httpUrl) is on the MCP page.

 Do China platforms (Bailian / Coze / Yuanbao) work?
 Alibaba Bailian, Coze, Tencent Yuanqi, Tencent Cloud Agent Platform and Volcengine Ark all work — see the China platform guide for per-platform steps. Note that Bailian and Coze do not document custom request headers, so only the five free tools work there; for paid tools use Tencent Cloud Agent Platform, Yuanqi, Volcengine Ark (Responses API), or header-capable clients such as Claude Code / Cursor.

 Last updated: 2026-09-21
 Config forms were checked against each client’s official docs (2026-09-21: Claude Code MCP docs — `claude mcp add --transport http`, `.mcp.json` `"type": "http"`, and the official note that a `url` entry without `type` is read as stdio and skipped). The tool list follows the live `tools/list` (24 tools).

 Read next

-
[MCP page (config for 19 clients)](/en/mcp)

-
[China platform guide (Bailian / Coze / Yuanqi / Ark)](/en/docs/mcp-china)

-
[Getting A-share quotes with Python (three approaches)](/en/docs/guides/python-ashare-quotes)

-
[Endpoint reference](/en/endpoints)

 [← All tutorials](/en/docs/guides)
