inquery-stock-price
Retrieve real-time stock price data from Korea Investment & Securities using a specified stock symbol. Designed for trading and financial analysis on the KIS REST API MCP Server.
Instructions
Get current stock price information from Korea Investment & Securities
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | Yes |
Implementation Reference
- server.py:251-296 (handler)Full implementation of the 'inquery-stock-price' tool handler, including registration decorator, input schema via type hints and docstring, and the core logic to fetch real-time stock price data from Korea Investment & Securities API using access token authentication.@mcp.tool( name="inquery-stock-price", description="Get current stock price information from Korea Investment & Securities", ) async def inquery_stock_price(symbol: str): """ Get current stock price information from Korea Investment & Securities Args: symbol: Stock symbol (e.g. "005930" for Samsung Electronics) Returns: Dictionary containing stock price information including: - stck_prpr: Current price - prdy_vrss: Change from previous day - prdy_vrss_sign: Change direction (+/-) - prdy_ctrt: Change rate (%) - acml_vol: Accumulated volume - acml_tr_pbmn: Accumulated trade value - hts_kor_isnm: Stock name in Korean - stck_mxpr: High price of the day - stck_llam: Low price of the day - stck_oprc: Opening price - stck_prdy_clpr: Previous day's closing price """ async with httpx.AsyncClient() as client: token = await get_access_token(client) response = await client.get( f"{TrIdManager.get_domain('price')}{STOCK_PRICE_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("price") }, params={ "fid_cond_mrkt_div_code": "J", "fid_input_iscd": symbol } ) if response.status_code != 200: raise Exception(f"Failed to get stock price: {response.text}") return response.json()["output"]