inquery-stock-info
Retrieve daily stock price data for specified Korean securities using KIS REST API. Input symbol, start date, and end date to access accurate stock information.
Instructions
Get daily stock price information from Korea Investment & Securities
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| end_date | Yes | ||
| start_date | Yes | ||
| symbol | Yes |
Implementation Reference
- server.py:513-557 (handler)Full handler function for 'inquery-stock-info' tool: registers the tool with MCP, defines input parameters (symbol, start_date, end_date), fetches daily stock price data via KIS API using prepared params, authentication token, and specific TR_ID/path.@mcp.tool( name="inquery-stock-info", description="Get daily stock price information from Korea Investment & Securities", ) async def inquery_stock_info(symbol: str, start_date: str, end_date: str): """ Get daily stock price information from Korea Investment & Securities Args: symbol: Stock symbol (e.g. "005930") start_date: Start date (YYYYMMDD) end_date: End date (YYYYMMDD) Returns: Dictionary containing daily stock price information """ async with httpx.AsyncClient() as client: token = await get_access_token(client) # Prepare request data request_data = { "FID_COND_MRKT_DIV_CODE": "J", # 시장구분 "FID_INPUT_ISCD": symbol, # 종목코드 "FID_INPUT_DATE_1": start_date, # 시작일자 "FID_INPUT_DATE_2": end_date, # 종료일자 "FID_PERIOD_DIV_CODE": "D", # 기간분류코드 "FID_ORG_ADJ_PRC": "0", # 수정주가원구분 } response = await client.get( f"{TrIdManager.get_domain('stock_info')}{STOCK_INFO_PATH}", headers={ "content-type": CONTENT_TYPE, "authorization": f"{AUTH_TYPE} {token}", "appkey": os.environ["KIS_APP_KEY"], "appsecret": os.environ["KIS_APP_SECRET"], "tr_id": TrIdManager.get_tr_id("stock_info") }, params=request_data ) if response.status_code != 200: raise Exception(f"Failed to get stock info: {response.text}") return response.json()
- server.py:513-516 (registration)MCP tool registration decorator specifying the tool name 'inquery-stock-info' and description.@mcp.tool( name="inquery-stock-info", description="Get daily stock price information from Korea Investment & Securities", )
- server.py:517-527 (schema)Input schema defined by function parameters (symbol: str, start_date: str, end_date: str) and docstring describing args and return type (dict from API).async def inquery_stock_info(symbol: str, start_date: str, end_date: str): """ Get daily stock price information from Korea Investment & Securities Args: symbol: Stock symbol (e.g. "005930") start_date: Start date (YYYYMMDD) end_date: End date (YYYYMMDD) Returns: Dictionary containing daily stock price information