feat(mcp): initialisation serveur MCP Treblo musique (nyora-2026-10-216)
This commit is contained in:
commit
424d8d13a5
9 files changed
+726
No files matched your search
Executable
+52
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
import os
|
||||
import json
|
||||
import datetime
|
||||
|
||||
def count_today(sphere: str, journal_path: str) -> int:
|
||||
if not os.path.exists(journal_path):
|
||||
return 0
|
||||
today = datetime.datetime.now(datetime.timezone.utc).strftime("%Y-%m-%d")
|
||||
count = 0
|
||||
try:
|
||||
with open(journal_path, "r", encoding="utf-8") as f:
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
if not line:
|
||||
continue
|
||||
try:
|
||||
entry = json.loads(line)
|
||||
if entry.get("sphere") == sphere:
|
||||
entry_date = entry.get("date", "")
|
||||
if entry_date.startswith(today):
|
||||
count += 1
|
||||
except Exception:
|
||||
continue
|
||||
except Exception:
|
||||
pass
|
||||
return count
|
||||
|
||||
def main():
|
||||
sphere = sys.argv[1] if len(sys.argv) > 1 else "nyora"
|
||||
sphere = sphere.lower().strip()
|
||||
cap_str = os.environ.get("TREBLO_DAILY_CAP", "5")
|
||||
try:
|
||||
daily_cap = int(cap_str)
|
||||
except ValueError:
|
||||
daily_cap = 5
|
||||
|
||||
journal_path = "/app/data/journal.jsonl"
|
||||
if not os.path.exists(journal_path):
|
||||
local_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data", "journal.jsonl")
|
||||
if os.path.exists(local_path):
|
||||
journal_path = local_path
|
||||
|
||||
current_count = count_today(sphere, journal_path)
|
||||
if current_count >= daily_cap:
|
||||
print("CAP_REFUSED")
|
||||
else:
|
||||
print("CAP_OK")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in new issue
Block a user