Add local helper script for cookie uploading
All checks were successful
Build and Push Docker Image / build (push) Successful in 34s
All checks were successful
Build and Push Docker Image / build (push) Successful in 34s
This commit is contained in:
@@ -9,6 +9,7 @@ dependencies = [
|
|||||||
"fastmcp>=0.4.1",
|
"fastmcp>=0.4.1",
|
||||||
"starlette>=0.41.0",
|
"starlette>=0.41.0",
|
||||||
"uvicorn>=0.32.0",
|
"uvicorn>=0.32.0",
|
||||||
|
"httpx>=0.27.0",
|
||||||
"aiohttp>=3.9.0",
|
"aiohttp>=3.9.0",
|
||||||
"fastapi>=0.136.1",
|
"fastapi>=0.136.1",
|
||||||
"greenlet>=3.2.3",
|
"greenlet>=3.2.3",
|
||||||
|
|||||||
57
upload_cookies.py
Executable file
57
upload_cookies.py
Executable 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
2
uv.lock
generated
@@ -1715,6 +1715,7 @@ dependencies = [
|
|||||||
{ name = "fastapi" },
|
{ name = "fastapi" },
|
||||||
{ name = "fastmcp" },
|
{ name = "fastmcp" },
|
||||||
{ name = "greenlet" },
|
{ name = "greenlet" },
|
||||||
|
{ name = "httpx" },
|
||||||
{ name = "mcp" },
|
{ name = "mcp" },
|
||||||
{ name = "pdfplumber" },
|
{ name = "pdfplumber" },
|
||||||
{ name = "playwright" },
|
{ name = "playwright" },
|
||||||
@@ -1730,6 +1731,7 @@ requires-dist = [
|
|||||||
{ name = "fastapi", specifier = ">=0.136.1" },
|
{ name = "fastapi", specifier = ">=0.136.1" },
|
||||||
{ name = "fastmcp", specifier = ">=0.4.1" },
|
{ name = "fastmcp", specifier = ">=0.4.1" },
|
||||||
{ name = "greenlet", specifier = ">=3.2.3" },
|
{ name = "greenlet", specifier = ">=3.2.3" },
|
||||||
|
{ name = "httpx", specifier = ">=0.27.0" },
|
||||||
{ name = "mcp", specifier = ">=1.2.0" },
|
{ name = "mcp", specifier = ">=1.2.0" },
|
||||||
{ name = "pdfplumber", specifier = ">=0.11.4" },
|
{ name = "pdfplumber", specifier = ">=0.11.4" },
|
||||||
{ name = "playwright", specifier = "==1.54.0" },
|
{ name = "playwright", specifier = "==1.54.0" },
|
||||||
|
|||||||
Reference in New Issue
Block a user