Skip to main content
Glama
liuguoping1024

SWLC MCP Server

get_latest_3d

Retrieve the most recent winning numbers for the 3D lottery game from the Shanghai Welfare Lottery Center's official data service.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Registration of the 'get_latest_3d' tool in the MCP server's list_tools() function, including name, description, and empty input schema.
    name="get_latest_3d", description="获取福彩3D最新开奖结果", inputSchema={ "type": "object", "properties": {}, "required": [] } ),
  • Input schema for the 'get_latest_3d' tool: empty object (no parameters).
    "properties": {}, "required": [] } ),
  • Primary handler function in SWLCService.get_3d_latest() that executes the tool logic: checks database cache, fetches from network if stale, parses, saves, and 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
  • MCP dispatch handler in call_tool() that invokes the service method and formats response as TextContent.
    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数据失败")]
  • Database helper method LotteryDatabase.get_latest_3d() that queries the latest 3D result from local SQLite database.
    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

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