Add local helper script for cookie uploading
All checks were successful
Build and Push Docker Image / build (push) Successful in 34s

This commit is contained in:
2026-04-24 02:01:38 +00:00
parent 5f038b753f
commit e14e060576
3 changed files with 60 additions and 0 deletions

View File

@@ -9,6 +9,7 @@ dependencies = [
"fastmcp>=0.4.1",
"starlette>=0.41.0",
"uvicorn>=0.32.0",
"httpx>=0.27.0",
"aiohttp>=3.9.0",
"fastapi>=0.136.1",
"greenlet>=3.2.3",

57
upload_cookies.py Executable file
View File

@@ -0,0 +1,57 @@
#!/usr/bin/env python3
import json
import sys
import argparse
import httpx
import asyncio
async def upload_cookies(url, cookie_file):
try:
with open(cookie_file, 'r') as f:
cookies = json.load(f)
cookies_str = json.dumps(cookies)
except Exception as e:
print(f"Error reading {cookie_file}: {e}")
return
# MCP tool call payload
payload = {
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "upload_cookies",
"arguments": {
"cookies_json": cookies_str
}
}
}
# Construct the /mcp endpoint if not provided
if not url.endswith('/mcp'):
url = url.rstrip('/') + '/mcp'
print(f"Uploading cookies to {url}...")
async with httpx.AsyncClient(timeout=30.0) as client:
try:
response = await client.post(url, json=payload)
response.raise_for_status()
result = response.json()
if "error" in result:
print(f"Error from server: {result['error']}")
else:
print(f"Server response: {result['result']['content'][0]['text']}")
except Exception as e:
print(f"Failed to upload cookies: {e}")
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Upload cookies.json to Schwab MCP server")
parser.add_argument("file", help="Path to cookies.json")
parser.add_argument("--url", default="http://localhost:8160", help="MCP server URL (default: http://localhost:8160)")
args = parser.parse_args()
asyncio.run(upload_cookies(args.url, args.file))

2
uv.lock generated
View File

@@ -1715,6 +1715,7 @@ dependencies = [
{ name = "fastapi" },
{ name = "fastmcp" },
{ name = "greenlet" },
{ name = "httpx" },
{ name = "mcp" },
{ name = "pdfplumber" },
{ name = "playwright" },
@@ -1730,6 +1731,7 @@ requires-dist = [
{ name = "fastapi", specifier = ">=0.136.1" },
{ name = "fastmcp", specifier = ">=0.4.1" },
{ name = "greenlet", specifier = ">=3.2.3" },
{ name = "httpx", specifier = ">=0.27.0" },
{ name = "mcp", specifier = ">=1.2.0" },
{ name = "pdfplumber", specifier = ">=0.11.4" },
{ name = "playwright", specifier = "==1.54.0" },