open-trading-api
Korea Investment & Securities Open API Github
claude mcp add --transport stdio koreainvestment-open-trading-api uvx koreainvestment/open-trading-api
How to use
This MCP server provides a Python-based integration layer for Korea Investment & Securities Open API samples. The repository organizes sample code into modules you can explore with an LLM or run directly to understand how to call the KIS Open API, authenticate, and manage real or simulated trading flows. Key components include examples_llm for function-by-function exploration, examples_user for end-to-end usage per product category (domestic and overseas stocks, bonds, ETFs/ETN, and derivatives), and a strategy/tools stack (strategy_builder and backtester) that demonstrates strategy design, backtesting, and order execution via the Open API. Use kis_auth.py for token handling and shared API call routines, and configure kis_devlp.yaml with your App Key/Secret, HTS ID, and account numbers to enable real or simulated trading workflows. The architecture supports a full pipeline: design strategies, backtest them, export a Kis YAML file, and execute trades through the KIS Open API once credentials are configured.
How to install
Prerequisites:
- Python 3.9 or newer
- uv package manager (recommended for dependency management)
Install and run this MCP server:
-
Install uv (if not already installed):
- Windows (PowerShell): powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
- macOS/Linux: curl -LsSf https://astral.sh/uv/install.sh | sh
- Verify: uv --version
-
Clone the repository and navigate to it: git clone https://github.com/koreainvestment/open-trading-api cd open-trading-api/kis_github
-
Install dependencies with uv: uv sync
-
Configure Open API credentials and environment:
- Open kis_devlp.yaml and populate: my_app, my_sec for real trading; or paper_app, paper_sec for simulated trading my_htsid, my_acct_stock, my_acct_future, my_paper_stock, my_paper_future, my_prod (adjust as needed for your accounts)
- Ensure kis_auth.py paths and config roots match your environment
-
Run the MCP server using the configured package entry (as defined by the mcp_config):
- The MCP runtime will load the package koreainvestment/open-trading-api via uvx and expose the server functionality described in the repository.
-
Optional: Explore examples and documentation within the repository to understand how to call specific API features (domestic_stock, overseas_stock, domestic_bond, etc.), how to authenticate, and how to integrate with strategy_builder/backtester for automated trading workflows.
Additional notes
Tips and common considerations:
- Ensure your kis_devlp.yaml contains valid keys for both real and simulated trading if you plan to switch between prod and paper modes.
- The code samples rely on uv for dependency management; use uv sync to install required Python packages listed in the project dependencies.
- For automated trading, you can export a .kis.yaml from strategy_builder and import it into backtester for validation before live execution.
- Validate environment variables and paths for kis_auth.py and the config_root to prevent file-not-found errors.
- When using real accounts, keep app keys and secrets secure and avoid committing kis_devlp.yaml to version control.
- If you encounter API rate limits or changes in KIS Open API, refer to the official API portal linked in the repository for updated usage and limits.
Related MCP Servers
metatrader
Model Context Protocol (MCP) to enable AI LLMs to trade using MetaTrader platform
openapi
OpenAPI definitions, converters and LLM function calling schema composer.
workflowy
Powerful CLI and MCP server for WorkFlowy: reports, search/replace, backup support, and AI integration (Claude, LLMs)
omega-memory
Persistent memory for AI coding agents
gtm
An MCP server for Google Tag Manager. Connect it to your LLM, authenticate once, and start managing GTM through natural language.
ebay
Open source local MCP server providing AI assistants with comprehensive access to eBay's Sell APIs. Includes 325 tools for inventory management, order fulfillment, marketing campaigns, analytics, developer tools, and more.