get_melon_chart
Fetch Melon music chart data for real-time, hot100, daily, or weekly rankings. Set the number of songs to retrieve, up to 100.
Instructions
Fetch the Melon music chart (멜론 차트).
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "get_melon_chart"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chart_type | No | Chart to fetch — 'realtime' (실시간), 'hot100', 'daily', or 'weekly' | realtime |
| limit | No | Number of songs to return (default 100, max 100) |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/korean_data_mcp/server.py:90-109 (handler)The main handler function for the 'get_melon_chart' tool. It calls an Apify actor (melon-chart-scraper) with chart_type and limit parameters.
@mcp.tool() async def get_melon_chart( chart_type: str = "realtime", limit: int = 100, ) -> list[dict]: """ Fetch the Melon music chart (멜론 차트). Args: chart_type: Chart to fetch — 'realtime' (실시간), 'hot100', 'daily', or 'weekly' limit: Number of songs to return (default 100, max 100) Returns: List of song objects with rank, title, artist, album fields. """ limit = min(limit, 100) return await _run_actor( f"{APIFY_ACCOUNT}/melon-chart-scraper", {"chartType": chart_type, "limit": limit}, ) - src/korean_data_mcp/server.py:91-109 (schema)The function signature defines the schema: chart_type (str, default 'realtime') and limit (int, default 100, max 100). Returns list[dict].
async def get_melon_chart( chart_type: str = "realtime", limit: int = 100, ) -> list[dict]: """ Fetch the Melon music chart (멜론 차트). Args: chart_type: Chart to fetch — 'realtime' (실시간), 'hot100', 'daily', or 'weekly' limit: Number of songs to return (default 100, max 100) Returns: List of song objects with rank, title, artist, album fields. """ limit = min(limit, 100) return await _run_actor( f"{APIFY_ACCOUNT}/melon-chart-scraper", {"chartType": chart_type, "limit": limit}, ) - src/korean_data_mcp/server.py:88-89 (registration)Tool registration via @mcp.tool() decorator on line 90, which registers the function as an MCP tool named 'get_melon_chart'.
# --------------------------------------------------------------------------- - src/korean_data_mcp/server.py:34-43 (helper)The _run_actor helper function used by get_melon_chart to run the Apify actor and return dataset items.
async def _run_actor(actor_id: str, input_data: dict, timeout_secs: int = 60) -> list[dict]: """Run an Apify actor synchronously and return dataset items.""" token = _get_token() url = f"{APIFY_BASE}/acts/{actor_id}/run-sync-get-dataset-items" params = {"token": token} async with httpx.AsyncClient(timeout=timeout_secs + 10) as client: resp = await client.post(url, json=input_data, params=params) resp.raise_for_status() return resp.json()