get_database_overview
Retrieve a complete overview of the Japanese horse racing database, detailing tables, columns, and relationships to facilitate data analysis without SQL.
Instructions
データベース全体の概要を取得
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/jvlink_mcp_server/server.py:688-692 (handler)The MCP tool handler for 'get_database_overview'. Decorated with @mcp.tool(), it opens a DatabaseConnection and delegates to _get_data_snapshot (which is an alias for get_data_snapshot from sample_data_provider).
@mcp.tool() def get_database_overview() -> dict: """データベース全体の概要を取得""" with DatabaseConnection() as db: return _get_data_snapshot(db) - The actual implementation function get_data_snapshot(). Iterates over 9 database tables (NL_RA, NL_SE, NL_UM, NL_KS, NL_CH, NL_HR, NL_O1, NL_RA_NAR, NL_SE_NAR) to count records and determine the data period from NL_SE. Returns table record counts, total_records, and data_period with earliest/latest dates.
def get_data_snapshot(db_connection) -> Dict[str, Any]: """データベース全体のスナップショット情報を取得 Args: db_connection: DatabaseConnectionインスタンス Returns: dict: { 'tables': テーブルごとの概要情報, 'total_records': 総レコード数, 'data_period': データ期間 } """ results = { "tables": {}, "total_records": 0, } # 各テーブルのレコード数を取得 for table_name in ["NL_RA", "NL_SE", "NL_UM", "NL_KS", "NL_CH", "NL_HR", "NL_O1", "NL_RA_NAR", "NL_SE_NAR"]: try: count_sql = f"SELECT COUNT(*) as cnt FROM {table_name}" df = db_connection.execute_safe_query(count_sql) count = int(df.iloc[0]["cnt"]) if not df.empty else 0 results["tables"][table_name] = { "record_count": count, "description": _get_table_description(table_name), } results["total_records"] += count except Exception: results["tables"][table_name] = {"record_count": 0, "error": "取得失敗"} # データ期間を取得(NL_SEから) try: period_sql = """ SELECT MIN(Year || '-' || MonthDay) as earliest, MAX(Year || '-' || MonthDay) as latest FROM NL_SE WHERE KakuteiJyuni IS NOT NULL """ df = db_connection.execute_safe_query(period_sql) if not df.empty: results["data_period"] = { "earliest": df.iloc[0]["earliest"], "latest": df.iloc[0]["latest"], } except Exception: results["data_period"] = {"error": "取得失敗"} return results - src/jvlink_mcp_server/server.py:688-688 (registration)The @mcp.tool() decorator registers 'get_database_overview' as an MCP tool on the FastMCP server instance.
@mcp.tool() - Helper function _get_table_description() used by get_data_snapshot to provide human-readable Japanese descriptions for each table.
def _get_table_description(table_name: str) -> str: """テーブルの説明を取得""" descriptions = { "NL_RA": "レース情報テーブル", "NL_SE": "出馬表・レース結果テーブル", "NL_UM": "馬マスタテーブル", "NL_KS": "騎手マスタテーブル", "NL_CH": "調教師マスタテーブル", "NL_HR": "払戻テーブル", "NL_O1": "単勝複勝オッズテーブル", } return descriptions.get(table_name, "不明") - Import statement: get_data_snapshot is imported from sample_data_provider and aliased as _get_data_snapshot for use in the handler.
from .database.sample_data_provider import ( get_sample_data as _get_sample_data, get_column_value_examples as _get_column_value_examples, get_data_snapshot as _get_data_snapshot, )