This file is written for LLM agents and MCP-aware clients. It describes the smallest reliable setup for running this repository as an MCP server.
- MCP server name suggestion:
kis-mcp-server - Runtime: Python 3.13+ with
uv - Default transport:
stdio - Main entrypoint:
uv run python server.py - Tool profiles:
catalog: 3 tools, recommended for LLM agents to reduce tool-schema contextfull: 15 tools, exposes convenience tools directly
- Trading safety:
- Order, amend, and cancel APIs are blocked unless
KIS_ENABLE_TRADING=trueis explicitly set. - Do not set
KIS_ENABLE_TRADING=truefor read-only account or quote usage.
- Order, amend, and cancel APIs are blocked unless
Recommended LLM default:
KIS_MCP_TOOLSET=catalogThe catalog profile still supports all 166 cataloged APIs through call-kis-api.
Required:
python --version # must be 3.13 or newer
uv --versionIf uv is missing:
pip install uvgit clone https://github.com/migusdn/KIS_MCP_Server.git
cd KIS_MCP_Server
uv syncIf the repository is already cloned, run only:
cd <project-root>
uv syncCreate .env from the example:
cp .env.example .env
chmod 600 .envEdit .env:
KIS_APP_KEY="<app-key>"
KIS_APP_SECRET="<app-secret>"
KIS_ACCOUNT_TYPE="REAL" # REAL or VIRTUAL
KIS_CANO="<account-first-8-digits>"
KIS_ACNT_PRDT_CD="01"
KIS_MCP_TOOLSET="catalog" # recommended for LLM agents
KIS_MCP_LOG_LEVEL="WARNING"Notes for LLM agents:
- Never write real credentials into tracked files.
.envandtoken.jsonmust stay untracked.- Keep
.envpermission at600when possible. KIS_TOKEN_FILEdefaults totoken.json.
Run the server in stdio mode:
uv run python server.pyA stdio MCP server waits for MCP messages, so it may appear idle. Stop it with Ctrl+C after confirming it starts.
Optional import/config test:
uv run python -m compileall main.py server.py example.py tests
uv run python -m unittest discover -vUse this when the client pays context for every loaded MCP tool schema.
KIS_MCP_TOOLSET=catalog uv run python server.pyExposed tools:
| Tool | Purpose |
|---|---|
list-kis-api-specs |
Search API catalog by group/query |
get-kis-api-spec |
Read endpoint, TR_ID candidates, params, labels, examples, values |
call-kis-api |
Call any cataloged API by group, api_type, and params |
LLM workflow in catalog mode:
- Use
list-kis-api-specsto find a candidate API. - Use
get-kis-api-specto inspect required params and examples. - Use
call-kis-apito execute the API. - For state-changing APIs, expect a safety block unless
KIS_ENABLE_TRADING=trueis set.
Use this when the user wants convenience tools directly visible.
KIS_MCP_TOOLSET=full uv run python server.pyThis exposes catalog tools plus convenience tools such as domestic balance, stock price, ask price, and order wrappers.
Recommended low-context registration:
codex mcp add kis-mcp-server \
--env KIS_MCP_TOOLSET=catalog \
--env KIS_MCP_LOG_LEVEL=WARNING \
-- uv --directory <project-root> run python server.pyCheck registration:
codex mcp list
codex mcp get kis-mcp-serverRemove registration:
codex mcp remove kis-mcp-serverIf using the default full toolset, either omit KIS_MCP_TOOLSET or set it to full.
Recommended low-context registration:
claude mcp add kis-mcp-server \
-e KIS_MCP_TOOLSET=catalog \
-e KIS_MCP_LOG_LEVEL=WARNING \
-- uv --directory <project-root> run python server.pyCheck registration:
claude mcp list
claude mcp get kis-mcp-serverRemove registration:
claude mcp remove kis-mcp-serverAlternative JSON registration for Claude Code:
claude mcp add-json kis-mcp-server '{
"type": "stdio",
"command": "uv",
"args": ["--directory", "<project-root>", "run", "python", "server.py"],
"env": {
"KIS_MCP_TOOLSET": "catalog",
"KIS_MCP_LOG_LEVEL": "WARNING"
}
}'Add an MCP server entry to the Claude Desktop configuration file.
Typical macOS path:
~/Library/Application Support/Claude/claude_desktop_config.json
Example config:
{
"mcpServers": {
"kis-mcp-server": {
"command": "uv",
"args": ["--directory", "<project-root>", "run", "python", "server.py"],
"env": {
"KIS_MCP_TOOLSET": "catalog",
"KIS_MCP_LOG_LEVEL": "WARNING"
}
}
}
}Restart Claude Desktop after editing the config.
Any stdio MCP client can use this shape:
{
"mcpServers": {
"kis-mcp-server": {
"command": "uv",
"args": ["--directory", "<project-root>", "run", "python", "server.py"],
"env": {
"KIS_MCP_TOOLSET": "catalog",
"KIS_MCP_LOG_LEVEL": "WARNING"
}
}
}
}If the client supports cwd but not uv --directory, this also works:
{
"mcpServers": {
"kis-mcp-server": {
"command": "uv",
"args": ["run", "python", "server.py"],
"cwd": "<project-root>",
"env": {
"KIS_MCP_TOOLSET": "catalog",
"KIS_MCP_LOG_LEVEL": "WARNING"
}
}
}
}Tool: list-kis-api-specs
{
"group": "overseas_stock",
"query": "잔고",
"limit": 10
}Tool: get-kis-api-spec
{
"group": "overseas_stock",
"api_type": "inquire_balance"
}Tool: call-kis-api
{
"group": "overseas_stock",
"api_type": "inquire_balance",
"params": {
"ovrs_excg_cd": "NASD",
"tr_crcy_cd": "USD"
}
}Tool: call-kis-api
{
"group": "overseas_stock",
"api_type": "inquire_psamount",
"params": {
"ovrs_excg_cd": "NASD",
"item_cd": "QQQ",
"ovrs_ord_unpr": "1"
}
}Tool: call-kis-api
{
"group": "domestic_stock",
"api_type": "inquire_price",
"params": {
"fid_cond_mrkt_div_code": "J",
"fid_input_iscd": "005930"
}
}| Name | Required | Default | Description |
|---|---|---|---|
KIS_APP_KEY |
yes | - | App key |
KIS_APP_SECRET |
yes | - | App secret |
KIS_ACCOUNT_TYPE |
yes | - | REAL or VIRTUAL |
KIS_CANO |
for account APIs | - | First 8 digits of account number |
KIS_ACNT_PRDT_CD |
for account APIs | 01 |
Account product code |
KIS_TOKEN_FILE |
no | token.json |
Token cache path |
KIS_ENABLE_TRADING |
no | disabled | Set to true only to allow order/amend/cancel APIs |
KIS_MCP_TOOLSET |
no | full |
catalog or full |
KIS_MCP_LOG_LEVEL |
no | INFO |
Use WARNING for quieter MCP clients |
MCP_TYPE |
no | stdio |
stdio, sse, or streamable-http |
MCP_HOST |
no | 127.0.0.1 |
HTTP/SSE host |
MCP_PORT |
no | 8000 |
HTTP/SSE port |
MCP_PATH |
no | /mcp |
HTTP/SSE path |
Install Python 3.13 or configure uv to use an available Python 3.13+ interpreter.
Check:
uv --directory <project-root> run python server.pyThen verify client registration points to the same <project-root>.
Set:
KIS_MCP_TOOLSET=catalogThen restart the MCP client session.
Check .env includes:
KIS_APP_KEY="<app-key>"
KIS_APP_SECRET="<app-secret>"
KIS_ACCOUNT_TYPE="REAL"
KIS_CANO="<account-first-8-digits>"
KIS_ACNT_PRDT_CD="01"Use get-kis-api-spec and pass parameters by the lowercase name field or uppercase wire_name field. Unknown parameters are rejected by default.
This is expected unless explicitly enabled:
KIS_ENABLE_TRADING=trueDo not enable this for read-only usage.