Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add instructions/twjackysu/twsemcpserver/claude-mdgit clone --depth 1 https://github.com/twjackysu/TWSEMCPServerWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/instructions/twjackysu/twsemcpserver/claude-md)<a href="https://agentmods.dev/instructions/twjackysu/twsemcpserver/claude-md"><img src="https://agentmods.dev/badge/instructions/twjackysu/twsemcpserver/claude-md.svg" alt="Measured on agentmods" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.03379 | $0.03379 |
| Opus 5 | $0.01690 | $0.01690 |
| Sonnet 5 | $0.00676 | $0.00676 |
| Haiku 4.5 | $0.00338 | $0.00338 |
Grade A, and why
TWSEMCPServer CLAUDE.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 161 lines — stays where its author put it; the contents beside it link to each section on GitHub.
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
TWStockMCPServer is a Model Context Protocol (MCP) server for Taiwan stock market data analysis. Built with FastMCP (Python) and requests. Data sources:
- TWSE OpenAPI (
openapi.twse.com.tw) — 143 tools: 公司治理、ESG、財報、交易、指數、券商 - TWSE Web API (
twse.com.tw) — 16 tools: 歷史日K、月均價、融資融券(/exchangeReport);估值(/rwd/zh/afterTrading/BWIBBU_d——/exchangeReport/BWIBBU_ALL會忽略date參數,只回最新交易日,不可用於歷史查詢);三大法人買賣超日報、個股明細(/rwd/zh/fund/T86);三大法人買賣金額、全市場收盤行情、市場成交量值、加權指數歷史、外資持股歷史(/rwd/zh/...,可查任意過去日期,與同名 openapi.twse.com.tw 端點僅回傳最近約12個交易日不同);個股月/年成交彙總、鉅額交易明細(無伺服器端股票篩選,本地端過濾)、融券借券餘額/成交(/rwd/zh/...)(legacy JSON,非 Swagger) - MIS 即時報價 (
mis.twse.com.tw) — 1 tool: 盤中多股即時報價 - TPEx OpenAPI (
tpex.org.tw/openapi) — 3 tools: 上櫃日收盤、三大法人、本益比 - TAIFEX OpenAPI (
openapi.taifex.com.tw) — 16 tools: 三大法人系列、大額交易人部位、每日行情、選擇權分析(Delta/OI增減)、保證金、年月統計 - TAIFEX 網站下載 (
www.taifex.com.tw) — 9 tools: 期貨每日OHLC歷史、三大法人期貨部位歷史、Put/Call Ratio歷史、三大法人選擇權買賣權分計歷史、大額交易人未沖銷部位歷史(無伺服器端契約篩選,本地端過濾)、選擇權每日OHLC歷史、三大法人期貨+選擇權總表歷史、三大法人期貨/選擇權分計歷史、三大法人各選擇權契約歷史(HTML表單下載頁面,非 openapi.taifex.com.tw;後者無任何歷史查詢功能,僅回傳最新一個交易日)
Development Commands
| Task | Command |
|---|---|
| Install dependencies | uv sync |
| Install with test deps | uv sync --extra dev |
| Run server (dev) | uv run fastmcp dev server.py |
| Run server (prod) | uv run fastmcp run server.py |
| Run all tests | uv run pytest |
| Run specific test file | uv run pytest tests/e2e/test_history_api.py -v |
| Run tests by category | python run_tests.py history (also: realtime, otc, taifex, institutional, e2e) |
| Quick test (fail fast) | python run_tests.py quick |
| Tests with coverage | python run_tests.py cov (opens HTML report) |
| Run server directly | python server.py (HTTP on port 8000) |
Code Architecture
High-Level Structure
server.py # Thin entrypoint: FastMCP init, prompt registration, tool registration
models/ # Pydantic-style data models (MarketInfo, BrokerInfo, RealTimeStats)
utils/
├── api_client.py # TWSEAPIClient - all TWSE HTTP calls
├── config.py # APIConfig, DisplayConfig, TestConfig (env var overrides)
├── constants.py # Localized message templates (Chinese)
├── decorators.py # @handle_api_errors
├── formatters.py # Data → string formatting functions
├── tool_factory.py # create_company_tool() for dynamically named tools
└── types.py # TWSEDataItem TypedDict, DataFormatter Protocol
tools/
├── __init__.py # register_all_tools() - auto-discovers and registers all tool modules
├── broker.py # Broker data tools (top-level module)
├── other.py # Misc tools: funds, bonds, holidays (top-level module)
├── company/ # Company tools: basic_info, financials, esg, listing, news
├── trading/ # Trading tools: daily, periodic, valuation, dividend_schedule, etf, market, warrants
├── market/ # Market tools: indices, statistics, foreign
├── history/ # TWSE legacy: stock_day, stock_day_avg, margin_balance (exchangeReport); bwibbu_all (rwd/*);
# institutional (T86);
# institutional_amounts, all_stocks_daily_close, market_turnover, taiex_index_history,
# foreign_holdings_history, stock_monthly_yearly_history, block_trades_detail,
# short_sale_lending (rwd/* endpoints — accept arbitrary past dates, unlike the
# openapi.twse.com.tw equivalents which only return a rolling ~12-day window)
├── realtime/ # MIS real-time quotes: stock_info
├── otc/ # TPEx OTC market: daily_close, institutional, peratio
└── taifex/ # TAIFEX derivatives: futures_position, put_call_ratio, institutional_general,
# institutional_details, daily_market_report, large_traders_oi,
# options_analytics, margin, trading_statistics, futures_daily_history,
# institutional_futures_history, put_call_ratio_history,
# options_institutional_history, large_traders_futures_history,
# options_daily_history, institutional_total_history,
# institutional_fut_opt_split_history,
# options_institutional_by_contract_history (latter nine scrape
# www.taifex.com.tw's HTML-form download endpoints for multi-day
# history; openapi.taifex.com.tw has no historical query support —
# every openapi endpoint returns only the latest trading day,
# confirmed by testing all 135 of its endpoints)
prompts/ # 9 prompt templates registered in server.py
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 5d ago First seen · 161 lines · 3,379 tokens per session scan A 77bb77a5d377
TWSEMCPServer CLAUDE.md is an instructions file published in the GitHub repository twjackysu/TWSEMCPServer (159 stars, last pushed 7d ago), licensed MIT. It adds 3,379 tokens to every session, about $0.0169 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other instructions, from other repositories
longbridge-mcp CLAUDE.md
Claude Code instructions for longbridge/longbridge-mcp, covering code formatting, code style, generic bounds, imports and comments.
CasualMarket CLAUDE.md
Instructions for sacahan/CasualMarket, covering claude.md, project overview, development commands, server execution and stdio mode (local/desktop).
oathscore CLAUDE.md
Claude Code instructions for moxiespirit/oathscore, covering oathscore - claude code instructions, project overview, architecture, key directories and environment variables (railway).
CasualMarket GEMINI.md
Instructions for sacahan/CasualMarket, a project described as: 功能完整的台灣股票交易 Model Context Protocol (MCP) Server,提供即時股價查詢、財務分析、市場資訊等多種功能.
jesse AGENTS.md
AGENTS.md instructions for jesse-ai/jesse, covering jesse repository guide for ai agents, skills, key characteristics, central framework and technology stack.
maverick-mcp AGENTS.md
AGENTS.md instructions for wshobson/maverick-mcp, covering repository guidelines, project overview, project structure, documentation map and build, test, and development commands.