Labsco
dragon1086 logo

KOSPI/KOSDAQ Stock Server

β˜… 73

from dragon1086

Provides KOSPI/KOSDAQ stock data, including ticker lookup, OHLCV, market capitalization, and fundamental data.

πŸ”₯πŸ”₯πŸ”₯βœ“ VerifiedFreeAdvanced setup

MseeP.ai Security Assessment Badge

kospi-kosdaq-stock-server

PyPI version smithery badge

<a href="https://glama.ai/mcp/servers/i1judi5h55"> <img width="380" height="200" src="https://glama.ai/mcp/servers/i1judi5h55/badge" /> </a>

An MCP server that provides KOSPI/KOSDAQ stock data from KRX Data Marketplace.

What's New in v0.3.0

Since December 27, 2024, KRX Data Marketplace requires Kakao/Naver login for data access. This version implements:

  • Direct KRX API integration with Kakao OAuth login
  • Playwright-based headless browser for authentication
  • Automatic session management with 4-hour timeout and auto re-login
  • No more pykrx dependency for core functionality

Features

  • Lookup KOSPI/KOSDAQ ticker symbols and names
  • Retrieve OHLCV (Open/High/Low/Close/Volume) data for stocks
  • Retrieve market capitalization data
  • Retrieve fundamental data (PER/PBR/Dividend Yield)
  • Retrieve trading volume by investor type (institutional, foreign, individual)
  • Retrieve index OHLCV data (KOSPI, KOSDAQ indices)

Environment Variables

Copy & paste β€” that's it
# Required: Kakao login credentials
KAKAO_ID=your_kakao_id
KAKAO_PW=your_kakao_password

Important: Your Kakao account must have 2-step verification (2FA) disabled. On first login, you may need to approve the login request via KakaoTalk.

Available Tools

load_all_tickers

Loads all ticker symbols and names for KOSPI and KOSDAQ.

  • No arguments required
  • Returns: Dictionary mapping ticker codes to stock names

get_stock_ohlcv

Retrieves OHLCV (Open/High/Low/Close/Volume) data for a specific stock.

  • fromdate (string, required): Start date (YYYYMMDD)
  • todate (string, required): End date (YYYYMMDD)
  • ticker (string, required): Stock ticker symbol (e.g., "005930")
  • adjusted (boolean, optional): Use adjusted prices (default: True)

get_stock_market_cap

Retrieves market capitalization data for a specific stock.

  • fromdate (string, required): Start date (YYYYMMDD)
  • todate (string, required): End date (YYYYMMDD)
  • ticker (string, required): Stock ticker symbol

get_stock_fundamental

Retrieves fundamental data (PER/PBR/Dividend Yield) for a specific stock.

  • fromdate (string, required): Start date (YYYYMMDD)
  • todate (string, required): End date (YYYYMMDD)
  • ticker (string, required): Stock ticker symbol

get_stock_trading_volume

Retrieves trading volume by investor type for a specific stock.

  • fromdate (string, required): Start date (YYYYMMDD)
  • todate (string, required): End date (YYYYMMDD)
  • ticker (string, required): Stock ticker symbol
  • detail (boolean, optional): If true, returns 12 investor types; if false (default), returns 5 aggregated types

get_index_ohlcv

Retrieves OHLCV data for market indices.

  • fromdate (string, required): Start date (YYYYMMDD)
  • todate (string, required): End date (YYYYMMDD)
  • ticker (string, required): Index ticker (e.g., "1001" for KOSPI, "2001" for KOSDAQ)
  • freq (string, optional): Frequency - "d" (daily), "m" (monthly), "y" (yearly). Default: "d"

Available Resources

stock://tickers

Returns all KOSPI/KOSDAQ ticker symbols and names.

stock://index-tickers

Returns index ticker information:

  • KOSPI: 1001, KOSPI 200: 1028, KOSPI 100: 1034, KOSPI 50: 1035
  • KOSDAQ: 2001, KOSDAQ 150: 2203

stock://data-sources

Returns current data source status.

Docker Support

Using Docker Compose

Copy & paste β€” that's it
# Build and run
docker-compose up -d

# View logs
docker-compose logs -f

Environment Variables for Docker

Create a .env file:

Copy & paste β€” that's it
KAKAO_ID=your_kakao_id
KAKAO_PW=your_kakao_password

Architecture

Copy & paste β€” that's it
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                MCP Server (FastMCP)                 β”‚
β”‚              kospi_kosdaq_stock_server.py           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β”‚
                       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚               KRXDataClient                         β”‚
β”‚  - get_market_ohlcv()                               β”‚
β”‚  - get_market_cap()                                 β”‚
β”‚  - get_market_fundamental()                         β”‚
β”‚  - get_market_trading_volume_by_date()              β”‚
β”‚  - get_index_ohlcv()                                β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β”‚
                       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚             KakaoAuthManager                        β”‚
β”‚  - Playwright headless browser                      β”‚
β”‚  - Kakao OAuth login                                β”‚
β”‚  - Session cookie management                        β”‚
β”‚  - Auto re-login on session expiry (4h)             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β”‚
                       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚           KRX Data Marketplace                      β”‚
β”‚             data.krx.co.kr                          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

License

MIT License

Contributing

Issues and pull requests are welcome!

Changelog

v0.3.0 (2025-01-04)

  • Breaking: Removed pykrx dependency for core functionality
  • Added KRX Data Marketplace direct integration with Kakao OAuth
  • Added Playwright-based headless authentication
  • Added automatic session management
  • Added index OHLCV support

v0.2.x

  • pykrx-based implementation (deprecated due to KRX login requirement)