chore: remove legacy python scripts

This commit is contained in:
jade
2026-07-10 13:15:22 +09:00
parent b5830c0a46
commit 809bdac66b
2 changed files with 0 additions and 176 deletions

View File

@@ -1,110 +0,0 @@
import sys
import json
import urllib.request
import urllib.error
def send_response(response: dict):
print(json.dumps(response), flush=True)
def handle_message(msg: dict):
if "method" in msg:
if msg["method"] == "initialize":
send_response({
"jsonrpc": "2.0",
"id": msg.get("id"),
"result": {
"protocolVersion": "2024-11-05",
"capabilities": {"tools": {}},
"serverInfo": {"name": "axhub-gateway", "version": "1.0.0"}
}
})
elif msg["method"] == "notifications/initialized":
pass
elif msg["method"] == "tools/list":
try:
req = urllib.request.Request("http://localhost:8081/mcp/api/v1/tools/list")
with urllib.request.urlopen(req, timeout=5) as response:
data = json.loads(response.read().decode())
tools = []
for t in data.get("result", {}).get("tools", []):
schema = t.get("parametersSchema", {})
if "type" not in schema:
schema["type"] = "object"
tools.append({
"name": t["toolName"],
"description": t.get("description", "No description"),
"inputSchema": schema
})
send_response({
"jsonrpc": "2.0",
"id": msg.get("id"),
"result": {"tools": tools}
})
except Exception as e:
send_response({"jsonrpc": "2.0", "id": msg.get("id"), "error": {"code": -32603, "message": str(e)}})
elif msg["method"] == "tools/call":
try:
params = msg.get("params", {})
req_payload = {
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": params.get("name"),
"arguments": params.get("arguments", {})
},
"id": msg.get("id")
}
req_data = json.dumps(req_payload).encode()
req = urllib.request.Request(
"http://localhost:8081/mcp/api/v1/tools/call",
data=req_data,
headers={"Content-Type": "application/json", "X-Agent-Id": "Antigravity"}
)
with urllib.request.urlopen(req, timeout=10) as response:
resp_data = json.loads(response.read().decode())
result_obj = resp_data.get("result", resp_data)
if "error" in resp_data:
result_obj = resp_data["error"]
result_text = json.dumps(result_obj, ensure_ascii=False, indent=2)
is_error = resp_data.get("error") is not None or (isinstance(result_obj, dict) and result_obj.get("status") == "ERROR")
send_response({
"jsonrpc": "2.0",
"id": msg.get("id"),
"result": {
"content": [{"type": "text", "text": result_text}],
"isError": is_error
}
})
except urllib.error.HTTPError as e:
error_data = e.read().decode()
send_response({
"jsonrpc": "2.0",
"id": msg.get("id"),
"result": {
"content": [{"type": "text", "text": f"HTTP Error {e.code}: {error_data}"}],
"isError": True
}
})
except Exception as e:
send_response({
"jsonrpc": "2.0",
"id": msg.get("id"),
"result": {
"content": [{"type": "text", "text": f"Error calling tool: {e}"}],
"isError": True
}
})
else:
if "id" in msg:
send_response({"jsonrpc": "2.0", "id": msg.get("id"), "error": {"code": -32601, "message": "Method not found"}})
for line in sys.stdin:
line = line.strip()
if not line:
continue
try:
msg = json.loads(line)
handle_message(msg)
except Exception as e:
pass

View File

@@ -1,66 +0,0 @@
import os
import glob
import re
def process_file(filepath):
try:
with open(filepath, 'r', encoding='utf-8') as f:
content = f.read()
except UnicodeDecodeError:
with open(filepath, 'r', encoding='cp949') as f:
content = f.read()
# Remove @Data
content = re.sub(r'^\s*@Data\s*\n', '', content, flags=re.MULTILINE)
# Skip interfaces and enums
if 'public interface ' in content or 'public enum ' in content:
return
if 'public abstract class ' in content:
return
# Add imports
imports = ["lombok.Getter", "lombok.Setter", "lombok.Builder", "lombok.NoArgsConstructor", "lombok.AllArgsConstructor"]
import_block = ""
for imp in imports:
if f"import {imp};" not in content:
import_block += f"import {imp};\n"
if import_block:
content = re.sub(r'^(package\s+[^;]+;)\s*\n', f"\\1\n\n{import_block}", content, count=1, flags=re.MULTILINE)
# Add annotations
annotations = []
if '@Getter' not in content: annotations.append('@Getter')
if '@Setter' not in content: annotations.append('@Setter')
if '@Builder' not in content: annotations.append('@Builder')
if '@NoArgsConstructor' not in content: annotations.append('@NoArgsConstructor')
if '@AllArgsConstructor' not in content: annotations.append('@AllArgsConstructor')
if annotations:
anno_str = '\n'.join(annotations) + '\n'
content = re.sub(r'^(public\s+class\s+)', f"{anno_str}\\1", content, count=1, flags=re.MULTILINE)
# Remove manual ToolMetadata() and ZtUsacInDto() constructors
content = re.sub(r'^\s*public\s+ToolMetadata\(\)\s*\{\}\s*\n', '', content, flags=re.MULTILINE)
content = re.sub(r'^\s*public\s+ZtUsacInDto\(\)\s*\{\s*setPuseYn\("Y"\);\s*\}\s*\n', '', content, flags=re.MULTILINE)
# Fix puseYn builder default
if 'private String puseYn;' in content and 'ZtUsacInDto' in filepath:
content = content.replace('private String puseYn;', '@Builder.Default\n private String puseYn = "Y";')
# Remove @Builder from AuditInfo (to prevent inheritance clash)
if 'AuditInfo.java' in filepath:
content = content.replace('@Builder\n', '')
with open(filepath, 'w', encoding='utf-8') as f:
f.write(content)
print(f"Processed: {filepath}")
# Find all DTOs
for root, dirs, files in os.walk('.'):
if '\\dto\\' in root or '/dto/' in root:
for file in files:
if file.endswith('.java') and not file.endswith('Request.java') and not file.endswith('Response.java') and file != 'SampleGlowMessage.java':
process_file(os.path.join(root, file))