Skip to main content
Glama
liuguoping1024

SWLC MCP Server

get_database_info

Retrieve local database statistics from the SWLC MCP Server to access and analyze lottery information, including winning numbers for games like Double Color Ball and Seven Happiness Lottery.

Instructions

获取本地数据库统计信息

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • MCP tool handler implementation for 'get_database_info' that retrieves database stats via the helper method and returns formatted text content.
    elif name == "get_database_info": try: info = lottery_service.db.get_database_info() text_lines = ["本地数据库统计信息:\n"] # 各表记录数 text_lines.append("各彩票类型记录数:") for table, count in info.items(): if table != 'last_sync': lottery_name = { 'ssq_results': '双色球', 'fucai3d_results': '福彩3D', 'qilecai_results': '七乐彩', 'kuaile8_results': '快乐8' }.get(table, table) text_lines.append(f"- {lottery_name}: {count}期") # 最新同步时间 if 'last_sync' in info and info['last_sync']: text_lines.append("\n最新同步时间:") for lottery_type, sync_time in info['last_sync'].items(): text_lines.append(f"- {lottery_type}: {sync_time}") return [types.TextContent(type="text", text="\n".join(text_lines))] except Exception as e: return [types.TextContent(type="text", text=f"获取数据库信息失败:{str(e)}")]
  • Tool registration in the MCP server's list_tools() method, defining name, description, and empty input schema.
    name="get_database_info", description="获取本地数据库统计信息", inputSchema={ "type": "object", "properties": {}, "required": [] } )
  • Core helper method in LotteryDatabase class that queries SQLite for record counts across lottery tables and last sync times.
    def get_database_info(self) -> Dict[str, Any]: """获取数据库统计信息""" try: with sqlite3.connect(self.db_path) as conn: cursor = conn.cursor() info = {} # 统计各表记录数 tables = ['ssq_results', 'fucai3d_results', 'qilecai_results', 'kuaile8_results'] for table in tables: cursor.execute(f"SELECT COUNT(*) FROM {table}") count = cursor.fetchone()[0] info[table] = count # 获取最新同步时间 cursor.execute(""" SELECT lottery_type, MAX(sync_date) FROM sync_logs GROUP BY lottery_type """) sync_info = {row[0]: row[1] for row in cursor.fetchall()} info['last_sync'] = sync_info return info except Exception as e: logger.error(f"获取数据库信息失败: {e}") return {}

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/liuguoping1024/swlc-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server