Logo di KOSPI/KOSDAQ Stock Data

KOSPI/KOSDAQ Stock Data

Community
dragon1086

An MCP server that provides KOSPI/KOSDAQ stock data using FastMCP

Autoredragon1086
Repositorykospi-kosdaq-stock-server
LinguaPython
Fork
32
Stelle
72
Strumenti disponibili
6
Tipo di trasportostdio, streamable-http
Categorie
LicenzaMIT
Link
  • Collega gli strumenti ai flussi di lavoro IA

    KOSPI/KOSDAQ Stock Data mette a disposizione funzionalità MCP utilizzabili da client e agenti IA compatibili.

  • 6 strumenti disponibili

    Esplora le azioni richiamabili qui sotto, con nomi e descrizioni quando forniti dal server.

  • Configurazione pronta da copiare

    Usa gli esempi di installazione per configurare questo server nel tuo client MCP preferito.

  • Indicatori di interesse open source

    72 stelle e 32 fork nel repository collegato.

MseeP.ai Security Assessment Badge

kospi-kosdaq-stock-server

PyPI version smithery badge

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)

Requirements

  • Python 3.10+
  • Kakao account (2FA must be disabled)
  • Playwright Chromium browser

Environment Variables

bash
# 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.

Installation

Prerequisites

bash
# Install Playwright and Chromium browser
pip install playwright
playwright install chromium

Installing via Smithery

bash
npx -y @smithery/cli install @dragon1086/kospi-kosdaq-stock-server --client claude

Manual Installation

bash
# Create and activate a virtual environment
uv venv .venv
source .venv/bin/activate  # On Unix/macOS
# .venv\Scripts\activate   # On Windows

# Install the package
uv pip install kospi-kosdaq-stock-server

# Install Playwright browser
playwright install chromium

Configuration for Claude Desktop

macOS

  1. Open the config file:
bash
code ~/Library/Application\ Support/Claude/claude_desktop_config.json
  1. Add the server configuration:
json
{
  "mcpServers": {
    "kospi-kosdaq": {
      "command": "uvx",
      "args": ["kospi_kosdaq_stock_server"],
      "env": {
        "KAKAO_ID": "your_kakao_id",
        "KAKAO_PW": "your_kakao_password"
      }
    }
  }
}

Windows

  1. Open the config file at %APPDATA%/Claude/claude_desktop_config.json

  2. Add the same configuration as above

  3. Restart Claude Desktop

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

bash
# Build and run
docker-compose up -d

# View logs
docker-compose logs -f

Environment Variables for Docker

Create a .env file:

bash
KAKAO_ID=your_kakao_id
KAKAO_PW=your_kakao_password

Troubleshooting

"KakaoTalk login notification" popup

On first login, Kakao may require approval via KakaoTalk:

  1. Run with headless=False to see the browser
  2. Approve the login in KakaoTalk
  3. Cookies will be saved for future sessions

401 Unauthorized / Session Expired

Session expires after ~4 hours. The server auto-renews, but if it fails:

  1. Delete ~/.krx_session.json
  2. Restart the server

Linux Headless Environment

bash
# Install required packages on Ubuntu/Debian
apt-get install -y libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 \
    libxkbcommon0 libxcomposite1 libxdamage1 libxfixes3 libxrandr2 libgbm1 libasound2

Architecture

┌─────────────────────────────────────────────────────┐
│                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                          │
└─────────────────────────────────────────────────────┘

Known Limitations

  • Kakao accounts with 2FA enabled are not supported
  • First login may require KakaoTalk approval
  • Session validity: ~4 hours (auto-renewal supported)
  • Naver login is not yet implemented

Usage Example

Human: Please load all available stock tickers.
Assistant: I'll load all KOSPI and KOSDAQ stock tickers.

> Using tool 'load_all_tickers'...
Successfully loaded 2,738 stock tickers.
Human: Show me Samsung Electronics' stock data for December 2024.
Assistant: I'll retrieve Samsung Electronics' (005930) OHLCV data.

> Using tool 'get_stock_ohlcv'...
Date        Open      High      Low       Close     Volume
2024-12-20  53,800    54,200    53,500    53,900    8,234,521
2024-12-19  54,000    54,300    53,700    53,800    7,123,456
...

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)

Installazione

TypingMind
Prerequisiti:

Node.js 18+

{
  "mcpServers": {
    "kospi-kosdaq": {
      "command": "uvx",
      "args": [
        "kospi_kosdaq_stock_server"
      ]
    }
  }
}

Strumenti disponibili

  • load_all_tickers

    Loads all ticker symbols and names for KOSPI and KOSDAQ into memory.

    Returns:
        Dict[str, str]: A dictionary mapping tickers to stock names.
        Example: {"005930": "삼성전자", "035720": "카카오", ...}
    
  • get_stock_ohlcv

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

    Args:
        fromdate (str): Start date for retrieval (YYYYMMDD)
        todate   (str): End date for retrieval (YYYYMMDD)
        ticker   (str): Stock ticker symbol
        adjusted (bool, optional): Whether to use adjusted prices (True: adjusted, False: unadjusted). Defaults to True.
    
    Returns:
        DataFrame:
            >> get_stock_ohlcv("20210118", "20210126", "005930")
                            Open     High     Low    Close   Volume
            Date
            2021-01-26  89500  94800  89500  93800  46415214
            2021-01-25  87300  89400  86800  88700  25577517
            2021-01-22  89000  89700  86800  86800  30861661
            2021-01-21  87500  88600  86500  88100  25318011
            2021-01-20  89000  89000  86500  87200  25211127
            2021-01-19  84500  88000  83600  87000  39895044
            2021-01-18  86600  87300  84100  85000  43227951
    
  • get_stock_market_cap

    Retrieves market capitalization data for a specific stock.

    Args:
        fromdate (str): Start date for retrieval (YYYYMMDD)
        todate   (str): End date for retrieval (YYYYMMDD)
        ticker   (str): Stock ticker symbol
    
    Returns:
        DataFrame:
            >> get_stock_market_cap("20150720", "20150724", "005930")
                              Market Cap  Volume      Trading Value  Listed Shares
            Date
            2015-07-24  181030885173000  196584  241383636000  147299337
            2015-07-23  181767381858000  208965  259446564000  147299337
            2015-07-22  184566069261000  268323  333813094000  147299337
            2015-07-21  186039062631000  194055  244129106000  147299337
            2015-07-20  187806654675000  128928  165366199000  147299337
    
  • get_stock_fundamental

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

    Args:
        fromdate (str): Start date for retrieval (YYYYMMDD)
        todate   (str): End date for retrieval (YYYYMMDD)
        ticker   (str): Stock ticker symbol
    
    Returns:
        DataFrame:
            >> get_stock_fundamental("20210104", "20210108", "005930")
                              BPS        PER       PBR   EPS       DIV   DPS
                Date
                2021-01-08  37528  28.046875  2.369141  3166  1.589844  1416
                2021-01-07  37528  26.187500  2.210938  3166  1.709961  1416
                2021-01-06  37528  25.953125  2.189453  3166  1.719727  1416
                2021-01-05  37528  26.500000  2.240234  3166  1.690430  1416
                2021-01-04  37528  26.218750  2.210938  3166  1.709961  1416
    
  • get_stock_trading_volume

    Retrieves trading volume by investor type for a specific stock.

    Args:
        fromdate (str): Start date for retrieval (YYYYMMDD)
        todate   (str): End date for retrieval (YYYYMMDD)
        ticker   (str): Stock ticker symbol
    
    Returns:
        DataFrame with columns:
        - Volume (Sell/Buy/Net Buy)
        - Trading Value (Sell/Buy/Net Buy)
        Broken down by investor types (Financial Investment, Insurance, Trust, etc.)
    
  • get_index_ohlcv

    Retrieves OHLCV data for a specific index.

    Args:
        fromdate (str): Start date for retrieval (YYYYMMDD)
        todate   (str): End date for retrieval (YYYYMMDD)
        ticker   (str): Index ticker symbol (e.g., 1001 for KOSPI, 2001 for KOSDAQ)
        freq     (str, optional): d - daily / m - monthly / y - yearly. Defaults to 'd'.
    
    Returns:
        DataFrame:
            >> get_index_ohlcv("20210101", "20210130", "1001")
                           Open     High      Low    Close       Volume    Trading Value
            Date
            2021-01-04  2874.50  2946.54  2869.11  2944.45  1026510465  25011393960858
            2021-01-05  2943.67  2990.57  2921.84  2990.57  1519911750  26548380179493
            2021-01-06  2993.34  3027.16  2961.37  2968.21  1793418534  29909396443430
            2021-01-07  2980.75  3055.28  2980.75  3031.68  1524654500  27182807334912
            2021-01-08  3040.11  3161.11  3040.11  3152.18  1297903388  40909490005818
    

Usa MCP KOSPI/KOSDAQ Stock Data con più modelli IA

TypingMind collega gli strumenti MCP a livello di area di lavoro: una volta connesso KOSPI/KOSDAQ Stock Data, puoi usarlo con diversi modelli IA in TypingMind, senza configurarlo separatamente per ogni modello. Puoi eseguire MCP localmente sul tuo dispositivo o connetterti all'URL di un server MCP remoto.

Opzione 1: usa il connettore locale

Usa questo metodo quando il server MCP deve accedere a file locali, app o risorse private sul tuo computer.

1

Apri le impostazioni MCP

In TypingMind, vai su Impostazioni, Impostazioni avanzate, poi su Model Context Protocol e scegli Configura MCP.

  1. Apri TypingMind nel tuo browser.
  2. Fai clic sull'icona Impostazioni.
  3. Vai a Impostazioni avanzate.
  4. Apri la sezione Model Context Protocol.
  5. Fai clic su Configura MCP e scegli Questo dispositivo.
Schermata di configurazione del connettore MCP di TypingMind con Questo dispositivo selezionato
2

Esegui il comando del connettore

Scegli Questo dispositivo, copia il comando da TypingMind ed eseguilo nel terminale. Lascia il processo in esecuzione mentre usi MCP.

  1. Copia il comando di configurazione mostrato da TypingMind.
  2. Apri Terminale su macOS o Windows Terminal su Windows.
  3. Incolla ed esegui il comando.
  4. Conferma l'installazione del pacchetto se il terminale ti chiede di procedere.
  5. Tieni aperta la finestra del terminale con il processo in esecuzione mentre usi gli strumenti MCP.
3

Aggiungi KOSPI/KOSDAQ Stock Data come server

Quando lo stato del connettore è Pronto, fai clic su Modifica server e incolla la configurazione del server MCP.

  1. Attendi che lo stato del connettore sia Pronto.
  2. Fai clic su Modifica server.
  3. Incolla la configurazione del server MCP di KOSPI/KOSDAQ Stock Data.
  4. Salva l'elenco dei server.
  5. Aggiorna per verificare che il connettore sia ancora pronto.
Impostazioni MCP di TypingMind con un server attivo e il pulsante Modifica server
{
  "mcpServers": {
    "kospi-kosdaq-stock-data": {
      "command": "npx",
      "args": [
        "-y",
        "kospi-kosdaq-stock-server"
      ]
    }
  }
}
4

Usa la connessione con diversi modelli

Salva l'elenco dei server, apri Plugin, abilita gli strumenti MCP di KOSPI/KOSDAQ Stock Data, poi seleziona un modello IA supportato in TypingMind e usa gli strumenti in chat o assegnali a un agente IA.

  1. Apri la pagina Plugin in TypingMind.
  2. Abilita gli strumenti MCP di KOSPI/KOSDAQ Stock Data.
  3. Avvia una chat e scegli il modello IA che vuoi usare.
  4. Usa gli strumenti MCP in chat o assegnali a un agente IA.
  5. Passa a un altro modello IA quando serve, senza riconnettere MCP.
Chat di TypingMind che usa gli strumenti MCP abilitati con un modello IA selezionato
Puoi usare KOSPI/KOSDAQ Stock Data per aiutarmi con questa attività?
KOSPI/KOSDAQ Stock Data
Certo. Ho letto.
Ecco cosa ho trovato con KOSPI/KOSDAQ Stock Data.

Opzione 2: aggiungi l'URL di un server MCP

Usa questo metodo se KOSPI/KOSDAQ Stock Data è già ospitato in remoto o se il tuo team vuole un unico connettore condiviso accessibile a più utenti.

1

Apri Connettori MCP

In TypingMind, vai su Plugin, apri Connettori MCP e scegli Aggiungi URL.

  1. Apri TypingMind nel tuo browser.
  2. Vai a Plugin.
  3. Apri Connettori MCP.
  4. Fai clic su Aggiungi URL.
Modulo di TypingMind per aggiungere l'URL di un server MCP personalizzato
2

Incolla l'URL del server

Inserisci URL del tuo server nel campo URL del server. Aggiungi un nome per la connessione, una descrizione, un'icona, header HTTP personalizzati o le impostazioni del client OAuth se richiesti dal server.

  1. Incolla URL del tuo server nel campo URL del server.
  2. Inserisci un nome per la connessione a KOSPI/KOSDAQ Stock Data.
  3. Aggiungi una descrizione e un'icona per riconoscere più facilmente la connessione.
  4. Aggiungi header HTTP personalizzati o i dati del client OAuth se il server richiede l'autenticazione.
3

Crea la connessione

Fai clic su Crea connessione, poi torna all'elenco dei plugin e verifica che la nuova connessione MCP sia attiva.

  1. Fai clic su Crea connessione.
  2. Torna all'elenco dei connettori MCP.
  3. Verifica che la connessione KOSPI/KOSDAQ Stock Data risulti attiva.
  4. Aggiorna l'elenco dei plugin se la connessione non appare subito.
4

Cambia modello senza riconnetterti

Avvia una chat con il tuo modello preferito, abilita gli strumenti di KOSPI/KOSDAQ Stock Data dalla sezione Plugin e passa a un altro modello quando serve. La connessione MCP rimane disponibile nell'area di lavoro di TypingMind.

  1. Avvia una nuova chat in TypingMind.
  2. Seleziona il modello IA che vuoi usare.
  3. Abilita gli strumenti di KOSPI/KOSDAQ Stock Data dalla sezione Plugin.
  4. Chiedi al modello di usare lo strumento quando serve.
  5. Passa a un altro modello IA e riutilizza la stessa connessione MCP.
Chat di TypingMind che usa gli strumenti MCP abilitati con un modello IA selezionato
Puoi usare KOSPI/KOSDAQ Stock Data per aiutarmi con questa attività?
KOSPI/KOSDAQ Stock Data
Certo. Ho letto.
Ecco cosa ho trovato con KOSPI/KOSDAQ Stock Data.

Domande frequenti

A cosa serve il server MCP KOSPI/KOSDAQ Stock Data?

KOSPI/KOSDAQ Stock Data è un server MCP che consente ai client IA compatibili di accedere a strumenti e informazioni di contesto esterni. In TypingMind puoi aggiungere questo server MCP una sola volta e rendere disponibili i suoi strumenti nella tua area di lavoro IA.

Posso usare KOSPI/KOSDAQ Stock Data MCP con più modelli IA in TypingMind?

Sì. TypingMind collega gli strumenti MCP a livello di area di lavoro, quindi puoi usare KOSPI/KOSDAQ Stock Data con diversi modelli IA come Claude, ChatGPT, Gemini o altri modelli che hai configurato in TypingMind, senza dover configurare il server MCP separatamente per ogni modello.

Perché usare il connettore MCP KOSPI/KOSDAQ Stock Data con TypingMind?

TypingMind è una delle migliori interfacce per chattare con gli LLM perché riunisce più modelli IA, prompt, plugin, agenti IA, chiavi API e strumenti MCP in un'unica area di lavoro. Collegando KOSPI/KOSDAQ Stock Data, puoi usare i suoi strumenti MCP con i tuoi modelli preferiti e mantenere organizzato il tuo flusso di lavoro in chat su TypingMind.

Come collego KOSPI/KOSDAQ Stock Data MCP a TypingMind?

Puoi collegare KOSPI/KOSDAQ Stock Data a TypingMind con il connettore MCP locale oppure aggiungendo l'URL di un server MCP remoto. Usa il connettore locale quando il server deve accedere a file, app o risorse private sul tuo dispositivo; usa invece l'URL del server quando il server MCP è ospitato in remoto.

Quali strumenti offre KOSPI/KOSDAQ Stock Data MCP in TypingMind?

KOSPI/KOSDAQ Stock Data mette a disposizione 6 strumenti MCP che puoi attivare dalla pagina Plugin di TypingMind e usare in chat o assegnare agli agenti IA.

Devo condividere le mie chiavi API con TypingMind per usare KOSPI/KOSDAQ Stock Data MCP?

No. TypingMind privilegia il funzionamento in locale e ti permette di mantenere il controllo su fornitori di modelli, chiavi API, prompt e configurazione MCP. Se KOSPI/KOSDAQ Stock Data richiede l'autenticazione, aggiungi le intestazioni, le impostazioni OAuth o la configurazione locale necessarie per quel server MCP quando crei la connessione.

Server MCP correlati

Vedi tutti

Crea subito la tua area di lavoro IA

Iscriviti alla nostra newsletter per ricevere aggiornamenti sulle nuove funzionalità e sulle prossime iniziative a premi 👇