Add jailbroken iPhone MCP screen app
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env python3
|
||||
import argparse
|
||||
import json
|
||||
import sys
|
||||
import urllib.request
|
||||
import urllib.error
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="MCP stdio bridge for the jailbroken iPhone MCP app")
|
||||
parser.add_argument("--ip", required=True, help="iPhone IP address")
|
||||
parser.add_argument("--port", type=int, default=8080, help="iPhone MCP HTTP port")
|
||||
args = parser.parse_args()
|
||||
|
||||
url = f"http://{args.ip}:{args.port}/api/mcp"
|
||||
sys.stderr.write(f"iPhone MCP bridge routing stdio to {url}\n")
|
||||
sys.stderr.flush()
|
||||
|
||||
for line in sys.stdin:
|
||||
try:
|
||||
request = json.loads(line)
|
||||
http_request = urllib.request.Request(
|
||||
url,
|
||||
data=json.dumps(request).encode("utf-8"),
|
||||
headers={"Content-Type": "application/json"},
|
||||
method="POST",
|
||||
)
|
||||
with urllib.request.urlopen(http_request, timeout=15.0) as response:
|
||||
sys.stdout.write(response.read().decode("utf-8") + "\n")
|
||||
sys.stdout.flush()
|
||||
except urllib.error.URLError as exc:
|
||||
write_error(-32000, f"Bridge failed to reach iPhone MCP app: {exc}", request if "request" in locals() else {})
|
||||
except Exception as exc:
|
||||
write_error(-32603, f"Bridge error: {exc}", request if "request" in locals() else {})
|
||||
|
||||
|
||||
def write_error(code, message, request):
|
||||
sys.stdout.write(json.dumps({
|
||||
"jsonrpc": "2.0",
|
||||
"error": {"code": code, "message": message},
|
||||
"id": request.get("id"),
|
||||
}) + "\n")
|
||||
sys.stdout.flush()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user