feat: implement visual UI builder, multi-device Android app, Ktor routing sync, and product roadmaps
This commit is contained in:
@@ -8,6 +8,27 @@ def log(msg):
|
||||
sys.stderr.write(f"[Meatbag MCP] {msg}\n")
|
||||
sys.stderr.flush()
|
||||
|
||||
import os
|
||||
|
||||
def get_api_key():
|
||||
if os.environ.get("MEATBAG_API_KEY"):
|
||||
return os.environ.get("MEATBAG_API_KEY")
|
||||
|
||||
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
paths = [
|
||||
os.path.join(script_dir, ".meatbag_key"),
|
||||
os.path.join(script_dir, "backend", ".meatbag_key"),
|
||||
os.path.join(script_dir, "..", ".meatbag_key")
|
||||
]
|
||||
for path in paths:
|
||||
if os.path.exists(path):
|
||||
try:
|
||||
with open(path, "r") as f:
|
||||
return f.read().strip()
|
||||
except Exception:
|
||||
pass
|
||||
return None
|
||||
|
||||
def handle_request_approval(prompt, target):
|
||||
log(f"Handling approval request. Target: {target}, Prompt: {prompt}")
|
||||
request_id = f"mcp_{uuid.uuid4().hex[:8]}"
|
||||
@@ -17,15 +38,23 @@ def handle_request_approval(prompt, target):
|
||||
"id": request_id,
|
||||
"prompt": prompt,
|
||||
"target": target
|
||||
}
|
||||
}
|
||||
|
||||
headers = {"Content-Type": "application/json"}
|
||||
api_key = get_api_key()
|
||||
if api_key:
|
||||
headers["X-Meatbag-API-Key"] = api_key
|
||||
log(f"Using API Key: {api_key[:6]}...")
|
||||
else:
|
||||
log("Warning: No API key found.")
|
||||
|
||||
try:
|
||||
url = "http://localhost:8080/api/request?attentionTier=OVERRIDE_SCREEN"
|
||||
log(f"Sending POST to {url}")
|
||||
req = urllib.request.Request(
|
||||
url,
|
||||
data=json.dumps(payload).encode("utf-8"),
|
||||
headers={"Content-Type": "application/json"}
|
||||
headers=headers
|
||||
)
|
||||
with urllib.request.urlopen(req) as response:
|
||||
res = json.loads(response.read().decode("utf-8"))
|
||||
@@ -35,12 +64,12 @@ def handle_request_approval(prompt, target):
|
||||
"content": [{"type": "text", "text": f"approved: {approved}"}],
|
||||
"isError": False
|
||||
}
|
||||
except Exception as e:
|
||||
log(f"Error communicating with Meatbag backend: {str(e)}")
|
||||
return {
|
||||
"content": [{"type": "text", "text": f"Error contacting Meatbag backend: {str(e)}"}],
|
||||
"isError": True
|
||||
}
|
||||
except Exception as e:
|
||||
log(f"Error communicating with Meatbag backend: {str(e)}")
|
||||
return {
|
||||
"content": [{"type": "text", "text": f"Error contacting Meatbag backend: {str(e)}"}],
|
||||
"isError": True
|
||||
}
|
||||
|
||||
def main():
|
||||
log("Starting Meatbag MCP Server...")
|
||||
|
||||
Reference in New Issue
Block a user