From 5f038b753fa9b32495d2a2319afb5038bd6f6e27 Mon Sep 17 00:00:00 2001 From: b3nw Date: Fri, 24 Apr 2026 01:54:45 +0000 Subject: [PATCH] Add upload_cookies tool for manual session provision --- server.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/server.py b/server.py index 3abe7ae..0f7d15a 100644 --- a/server.py +++ b/server.py @@ -94,6 +94,23 @@ async def get_morningstar_data(ticker: str, debug: bool = False) -> str: result = await api.get_morningstar_data(ticker, debug=debug) return json.dumps(result) +@mcp.tool() +async def upload_cookies(cookies_json: str) -> str: + """Upload session cookies to the server to assist with authentication. + + Args: + cookies_json: JSON string of cookies exported from a browser (Playwright format) + """ + try: + # Validate JSON + cookies = json.loads(cookies_json) + # Write to cookies.json + with open("cookies.json", "w") as f: + json.dump(cookies, f) + return json.dumps({"status": "success", "message": "cookies.json updated successfully"}) + except Exception as e: + return json.dumps({"status": "error", "message": str(e)}) + @mcp.tool() async def api_call(endpoint: str, method: str = "GET", params: str = "{}") -> str: """Executes a raw API call to the Schwab service (Dummy implementation).