Ver Fonte

dashboard stable

Lukas Goldschmidt há 1 mês atrás
pai
commit
7725fb64c1
2 ficheiros alterados com 13 adições e 1 exclusões
  1. 12 1
      src/exec_mcp/repo.py
  2. 1 0
      src/exec_mcp/server.py

+ 12 - 1
src/exec_mcp/repo.py

@@ -1,6 +1,7 @@
 from __future__ import annotations
 
 import json
+import secrets
 from datetime import datetime, timezone
 from sqlite3 import IntegrityError
 from uuid import uuid4
@@ -80,8 +81,18 @@ def get_account_secrets(account_id: str) -> dict:
     return {"api_key": row["api_key"], "api_secret": row["api_secret"]}
 
 
+def _generate_account_id(length: int = 12) -> str:
+    alphabet = "abcdefghijklmnopqrstuvwxyz0123456789"
+    while True:
+        candidate = "".join(secrets.choice(alphabet) for _ in range(length))
+        with get_connection() as conn:
+            exists = conn.execute("SELECT 1 FROM accounts WHERE id = ?", (candidate,)).fetchone()
+        if exists is None:
+            return candidate
+
+
 def create_account(*, display_name: str, venue: str, venue_account_ref: str, api_key: str, api_secret: str, description: str | None = None, enabled: bool = True) -> dict:
-    account_id = str(uuid4())
+    account_id = _generate_account_id()
     now = utc_now_iso()
     with get_connection() as conn:
         try:

+ 1 - 0
src/exec_mcp/server.py

@@ -21,6 +21,7 @@ async def lifespan(_: FastAPI):
 
 
 app = FastAPI(title="exec-mcp", lifespan=lifespan)
+app.mount("/mcp", mcp.http_app(path="/sse", transport="sse"))
 SUPPORTED_VENUES = {"bitstamp"}