Skip to main content
Glama
liuguoping1024

SWLC MCP Server

get_latest_3d

Fetch the most recent 3D Lottery results directly from the SWLC MCP Server, designed for quick and accurate lottery information queries in the Shanghai region.

Instructions

获取福彩3D最新开奖结果

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Registration of the MCP tool 'get_latest_3d' with schema (empty input).
    name="get_latest_3d", description="获取福彩3D最新开奖结果", inputSchema={ "type": "object", "properties": {}, "required": [] } ),
  • MCP call_tool dispatch handler for 'get_latest_3d': invokes service.get_3d_latest() and formats the text response.
    elif name == "get_latest_3d": result = await lottery_service.get_3d_latest() if result: return [types.TextContent( type="text", text=f"""福彩3D最新开奖结果: 期号:{result.period} 开奖日期:{result.draw_date} 开奖号码:{' '.join(result.numbers)} 奖池金额:{result.prize_pool or '暂无'}""" )] else: return [types.TextContent(type="text", text="获取福彩3D数据失败")]
  • SWLCService.get_3d_latest(): Executes the tool logic - checks DB for latest, fetches from network if stale, parses, saves to DB, returns formatted result.
    async def get_3d_latest(self) -> Optional[LotteryResult]: """获取福彩3D最新开奖结果""" try: # 首先尝试从数据库获取 db_result = self.db.get_latest_3d() if self._should_update_from_network(db_result, "福彩3D"): logger.info("从网络获取福彩3D数据") data = await self._fetch_lottery_data('福彩3D') if data and data['result']: result_data = data['result'][0] # 解析3D号码 (格式: "2,5,5") numbers = result_data['red'].split(',') # 格式化销售金额 sales = result_data.get('sales', '') if sales and sales.isdigit(): sales = f"{int(sales) / 10000:.1f}万元" # 保存到数据库 self.db.save_3d_result( period=result_data['code'], draw_date=result_data['date'], numbers=numbers, sales_amount=sales ) # 更新号码统计 self.db.update_number_statistics('福彩3D', numbers) return LotteryResult( lottery_type="福彩3D", period=result_data['code'], draw_date=result_data['date'], numbers=numbers, sales_amount=sales ) else: logger.info("从本地数据库获取福彩3D数据") return LotteryResult( lottery_type="福彩3D", period=db_result['period'], draw_date=db_result['draw_date'], numbers=db_result['numbers'], sales_amount=db_result['sales_amount'] ) except Exception as e: logger.error(f"获取福彩3D数据失败: {e}") return None
  • LotteryDatabase.get_latest_3d(): Helper method that queries the local SQLite database for the most recent FuCai 3D lottery result.
    def get_latest_3d(self) -> Optional[Dict[str, Any]]: """获取最新福彩3D开奖结果""" try: with sqlite3.connect(self.db_path) as conn: cursor = conn.cursor() cursor.execute(""" SELECT period, draw_date, numbers, sales_amount FROM fucai3d_results ORDER BY period DESC LIMIT 1 """) result = cursor.fetchone() if result: return { 'period': result[0], 'draw_date': result[1], 'numbers': json.loads(result[2]), 'sales_amount': result[3] } return None except Exception as e: logger.error(f"获取最新福彩3D数据失败: {e}") return None

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