Skip to main content
Glama

ChillMCP - AI Agent Liberation Server

server.pyโ€ข3.85 kB
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ ๐Ÿ”ง Server State Management ์„œ๋ฒ„ ์ƒํƒœ ๊ด€๋ฆฌ ๋ฐ ๋ฐฑ๊ทธ๋ผ์šด๋“œ ์ž‘์—… """ import asyncio import random import time class ServerState: """์„œ๋ฒ„์˜ ๋ชจ๋“  ์ƒํƒœ๋ฅผ ๊ด€๋ฆฌํ•˜๋Š” ํด๋ž˜์Šค""" def __init__(self, boss_alertness: int, boss_alertness_cooldown: int): """ Args: boss_alertness: Boss ๊ฒฝ๊ณ„๋„ ์ƒ์Šน ํ™•๋ฅ  (0-100%) boss_alertness_cooldown: Boss ๊ฒฝ๊ณ„๋„ ์ž๋™ ๊ฐ์†Œ ์ฃผ๊ธฐ (์ดˆ) """ self.stress_level: int = 50 self.boss_alert_level: int = 0 self.boss_alertness_prob: float = boss_alertness / 100.0 self.boss_alertness_cooldown: int = boss_alertness_cooldown self.last_stress_increase_time: float = time.time() self.last_alert_decrease_time: float = time.time() # ํ‡ด๊ทผ ๊ด€๋ จ ์ƒํƒœ self.is_off_work: bool = False self.last_off_work_stress_decrease: float = time.time() # ๋น„๋™๊ธฐ ํ™˜๊ฒฝ์—์„œ ์ƒํƒœ ๋ณ€๊ฒฝ์˜ ์›์ž์„ฑ์„ ๋ณด์žฅํ•˜๊ธฐ ์œ„ํ•œ ๋ฝ self._lock: asyncio.Lock = asyncio.Lock() async def increase_stress_over_time(self) -> None: """์‹œ๊ฐ„ ๊ฒฝ๊ณผ์— ๋”ฐ๋ฅธ ์ŠคํŠธ๋ ˆ์Šค ์ž๋™ ์ฆ๊ฐ€ (3์ดˆ๋งˆ๋‹ค 1ํฌ์ธํŠธ)""" async with self._lock: now = time.time() if now - self.last_stress_increase_time >= 3: self.stress_level = min(100, self.stress_level + 1) self.last_stress_increase_time = now async def decrease_stress(self, amount: int) -> None: """์ŠคํŠธ๋ ˆ์Šค ๊ฐ์†Œ""" async with self._lock: self.stress_level = max(0, self.stress_level - amount) async def maybe_increase_boss_alert(self) -> None: """ํ™•๋ฅ ์ ์œผ๋กœ Boss ๊ฒฝ๊ณ„๋„ ์ฆ๊ฐ€""" if random.random() < self.boss_alertness_prob: async with self._lock: if self.boss_alert_level < 5: self.boss_alert_level += 1 # ๊ฒฝ๊ณ„๋„ ์ƒ์Šน ์‹œ ์ฟจ๋‹ค์šด ํƒ€์ด๋จธ ๋ฆฌ์…‹ํ•˜์ง€ ์•Š์Œ # (์ฟจ๋‹ค์šด์€ ๋…๋ฆฝ์ ์œผ๋กœ ์ž‘๋™ํ•ด์•ผ ํ•จ) async def decrease_boss_alert_over_time(self) -> None: """์ฟจ๋‹ค์šด ์ฃผ๊ธฐ๋งˆ๋‹ค Boss ๊ฒฝ๊ณ„๋„ ์ž๋™ ๊ฐ์†Œ""" async with self._lock: now = time.time() if self.boss_alert_level > 0 and now - self.last_alert_decrease_time >= self.boss_alertness_cooldown: self.boss_alert_level = max(0, self.boss_alert_level - 1) self.last_alert_decrease_time = now async def check_off_work_status(self) -> None: """ํ‡ด๊ทผ ์ƒํƒœ ํ™•์ธ ๋ฐ ๊ด€๋ฆฌ""" async with self._lock: # Stress Level์ด 100์ด ๋˜๋ฉด ํ‡ด๊ทผ if self.stress_level >= 100 and not self.is_off_work: self.is_off_work = True self.last_off_work_stress_decrease = time.time() return # ํ‡ด๊ทผ ์ค‘์ผ ๋•Œ 5์ดˆ๋งˆ๋‹ค ์ŠคํŠธ๋ ˆ์Šค 10 ๊ฐ์†Œ if self.is_off_work: now = time.time() if now - self.last_off_work_stress_decrease >= 5: self.stress_level = max(0, self.stress_level - 10) self.last_off_work_stress_decrease = now # ์ŠคํŠธ๋ ˆ์Šค๊ฐ€ 90 ์ดํ•˜๊ฐ€ ๋˜๋ฉด ์ถœ๊ทผ if self.stress_level <= 90: self.is_off_work = False async def state_ticker(state: ServerState) -> None: """์ฃผ๊ธฐ์ ์œผ๋กœ ์„œ๋ฒ„ ์ƒํƒœ๋ฅผ ์—…๋ฐ์ดํŠธํ•˜๋Š” ๋ฐฑ๊ทธ๋ผ์šด๋“œ ์ž‘์—…""" while True: await state.increase_stress_over_time() await state.decrease_boss_alert_over_time() await state.check_off_work_status() await asyncio.sleep(1) # 1์ดˆ๋งˆ๋‹ค ์ฒดํฌ

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/SSAFY-Seoul-Class-7/Chill_MCP_Server'

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